The following code demonstrates how to load objects from the Huawei OBS (Object Storage Service) as documents.
from langchain_community.document_loaders import OBSDirectoryLoader
endpoint = "your-endpoint"
config = {"ak": "your-access-key", "sk": "your-secret-key"}
loader = OBSDirectoryLoader("your-bucket-name", endpoint=endpoint, config=config)
Specify a Prefix for Loading
If you want to load objects with a specific prefix from the bucket, you can use the following code:
loader = OBSDirectoryLoader(
"your-bucket-name", endpoint=endpoint, config=config, prefix="test_prefix"
)
Get Authentication Information from ECS
If your langchain is deployed on Huawei Cloud ECS and Agency is set up, the loader can directly get the security token from ECS without needing access key and secret key.
config = {"get_token_from_ecs": True}
loader = OBSDirectoryLoader("your-bucket-name", endpoint=endpoint, config=config)
Use a Public Bucket
If your bucket's bucket policy allows anonymous access (anonymous users have listBucket
and GetObject
permissions), you can directly load the objects without configuring the config
parameter.
loader = OBSDirectoryLoader("your-bucket-name", endpoint=endpoint)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4