agentscope.app.ragLocalBlobStore
class LocalBlobStore(BlobStoreBase)
agentscope/app/rag/blob_store/_local.py:27–153本地二进制对象存储,负责持久化与读取数据。位于 agentscope.app.rag 包,继承自 BlobStoreBase。核心成员包括 write_stream、open、size、delete、exists。
Intended for single-node deployments and development. The lifecycle
of a blob is bound to the document that owns it, not to the request
that uploaded it — this is what distinguishes the store from
FastAPI's per-request SpooledTemporaryFile and is the reason
the abstraction exists at all.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(root_dir: str | os.PathLike) -> None | 初始化 `LocalBlobStore` 实例。 Initialize the local backend. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def __aenter__() -> 'LocalBlobStore'async | 进入异步上下文并返回自身。 Ensure the root directory exists. |
async def write_stream(key: str, stream: IO[bytes]) -> strasync | 执行写入流相关操作。 Copy ``stream`` into the blob at ``key`` in 1 MiB chunks. |
async def open(uri: str) -> AsyncIterator[AsyncReadable]asyncasynccontextmanager | 设置打开。 Open the blob at ``uri`` for streaming reads. |
async def size(uri: str) -> int | Noneasync | 设置大小。 Return the file's size on disk, or ``None`` if it is gone. |
async def delete(uri: str) -> Noneasync | 删除数据。 Remove the blob at ``uri`` if present (idempotent). |
async def exists(uri: str) -> boolasync | 判断数据是否存在。 Return whether the blob at ``uri`` is present. |
构造器详情Constructor Detail
LocalBlobStore
def __init__(root_dir: str | os.PathLike) -> None
初始化 LocalBlobStore 实例。
Initialize the local backend.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
root_dir | str | os.PathLike | 根目录(类型 `str | os.PathLike`)。Directory that holds all blobs for this app. Created on :meth:`__aenter__` if it does not exist. |
agentscope/app/rag/blob_store/_local.py:37–45方法详情Method Detail
__aenter__
async def __aenter__() -> 'LocalBlobStore'
进入异步上下文并返回自身。
Ensure the root directory exists.
agentscope/app/rag/blob_store/_local.py:47–50write_stream
async def write_stream(key: str, stream: IO[bytes]) -> str
执行写入流相关操作。
Creates intermediate directories as needed.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | str | 键(类型 `str`)。Backend-relative key. |
stream | IO[bytes] | 流(类型 `IO[bytes]`)。Synchronous binary source. |
agentscope/app/rag/blob_store/_local.py:81–107open
async def open(uri: str) -> AsyncIterator[AsyncReadable]
设置打开。
Open the blob at uri for streaming reads.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
uri | str | URI(类型 `str`)。The uri. |
agentscope/app/rag/blob_store/_local.py:110–117size
async def size(uri: str) -> int | None
设置大小。
Return the file's size on disk, or None if it is gone.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
uri | str | URI(类型 `str`)。The uri. |
agentscope/app/rag/blob_store/_local.py:119–125delete
async def delete(uri: str) -> None
删除数据。
Remove the blob at uri if present (idempotent).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
uri | str | URI(类型 `str`)。The uri. |
agentscope/app/rag/blob_store/_local.py:127–141exists
async def exists(uri: str) -> bool
判断数据是否存在。
Return whether the blob at uri is present.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
uri | str | URI(类型 `str`)。The uri. |
agentscope/app/rag/blob_store/_local.py:143–146