AS AgentScopeAPI 手册 / API Reference
类class agentscope.app.rag

LocalBlobStore

class LocalBlobStore(BlobStoreBase)
源码Source 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.

参数Parameters
名称Name类型Type说明Description
root_dirstr | os.PathLike根目录(类型 `str | os.PathLike`)。Directory that holds all blobs for this app. Created on :meth:`__aenter__` if it does not exist.
源码Source agentscope/app/rag/blob_store/_local.py:37–45

方法详情Method Detail

__aenter__

async def __aenter__() -> 'LocalBlobStore'
async

进入异步上下文并返回自身。

Ensure the root directory exists.

返回Returns 'LocalBlobStore'
返回'LocalBlobStore'。Returns local blob store.
源码Source agentscope/app/rag/blob_store/_local.py:47–50

write_stream

async def write_stream(key: str, stream: IO[bytes]) -> str
async

执行写入流相关操作。

Creates intermediate directories as needed.

参数Parameters
名称Name类型Type说明Description
keystr键(类型 `str`)。Backend-relative key.
streamIO[bytes]流(类型 `IO[bytes]`)。Synchronous binary source.
返回Returns str
返回字符串结果。`str`:
源码Source agentscope/app/rag/blob_store/_local.py:81–107

open

async def open(uri: str) -> AsyncIterator[AsyncReadable]
asyncasynccontextmanager

设置打开。

Open the blob at uri for streaming reads.

参数Parameters
名称Name类型Type说明Description
uristrURI(类型 `str`)。The uri.
返回Returns AsyncIterator[AsyncReadable]
以异步流的形式返回AsyncReadable。Returns a stream of async readable.
源码Source agentscope/app/rag/blob_store/_local.py:110–117

size

async def size(uri: str) -> int | None
async

设置大小。

Return the file's size on disk, or None if it is gone.

参数Parameters
名称Name类型Type说明Description
uristrURI(类型 `str`)。The uri.
返回Returns int | None
返回int|None。Returns int none.
源码Source agentscope/app/rag/blob_store/_local.py:119–125

delete

async def delete(uri: str) -> None
async

删除数据。

Remove the blob at uri if present (idempotent).

参数Parameters
名称Name类型Type说明Description
uristrURI(类型 `str`)。The uri.
返回Returns None
无返回值。No value is returned.
源码Source agentscope/app/rag/blob_store/_local.py:127–141

exists

async def exists(uri: str) -> bool
async

判断数据是否存在。

Return whether the blob at uri is present.

参数Parameters
名称Name类型Type说明Description
uristrURI(类型 `str`)。The uri.
返回Returns bool
返回布尔值,表示判断结果。Returns a boolean result.
源码Source agentscope/app/rag/blob_store/_local.py:143–146

继承成员Inherited Members

继承自Inherited from BlobStoreBase
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.