Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

Huawei OBS File

The following code demonstrates how to load an object from the Huawei OBS (Object Storage Service) as document.

# Install the required package
# pip install esdk-obs-python
from langchain_community.document_loaders.obs_fileimport OBSFileLoader
API Reference:OBSFileLoader
endpoint="your-endpoint"
from obsimport ObsClient

obs_client= ObsClient(
access_key_id="your-access-key",
secret_access_key="your-secret-key",
server=endpoint,
)
loader= OBSFileLoader("your-bucket-name","your-object-key", client=obs_client)
loader.load()

Each Loader with Separate Authentication Information

If you don't need to reuse OBS connections between different loaders, you can directly configure theconfig. The loader will use the config information to initialize its own OBS client.

# Configure your access credentials\n
config={"ak":"your-access-key","sk":"your-secret-key"}
loader= OBSFileLoader(
"your-bucket-name","your-object-key", endpoint=endpoint, config=config
)
loader.load()

Get Authentication Information from ECS

If your langchain is deployed on Huawei Cloud ECS andAgency 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= OBSFileLoader(
"your-bucket-name","your-object-key", endpoint=endpoint, config=config
)
loader.load()

Access a Publicly Accessible Object

If the object you want to access allows anonymous user access (anonymous users haveGetObject permission), you can directly load the object without configuring theconfig parameter.

loader= OBSFileLoader("your-bucket-name","your-object-key", endpoint=endpoint)
loader.load()

Related


[8]ページ先頭

©2009-2025 Movatter.jp