AS AgentScopeAPI 手册 / API Reference
类class agentscope.embedding

EmbeddingCacheBase

class EmbeddingCacheBase
源码Source agentscope/embedding/_cache_base.py:12–63

向量化缓存基类,与模型服务通信并返回生成或向量化结果。位于 agentscope.embedding 包。核心成员包括 store、retrieve、remove、clear。

Base class for embedding caches, which is responsible for storing and retrieving embeddings. Declared in agentscope.embedding.

方法摘要Method Summary

方法Method说明Description
async def store(embeddings: List[Embedding], identifier: JSONSerializableObject, overwrite: bool = False, **kwargs: Any…asyncabstractabstractmethod
执行存储相关操作。
Store the embeddings with the given identifier.
async def retrieve(identifier: JSONSerializableObject) -> List[Embedding] | Noneasyncabstractabstractmethod
按查询检索相关文档。
Retrieve the embeddings with the given identifier. If not found, return `None`.
async def remove(identifier: JSONSerializableObject) -> Noneasyncabstractabstractmethod
设置移除。
Remove the embeddings with the given identifier.
async def clear() -> Noneasyncabstractabstractmethod
清空或重置内部状态。
Clear all cached embeddings.

方法详情Method Detail

store

async def store(embeddings: List[Embedding], identifier: JSONSerializableObject, overwrite: bool = False, **kwargs: Any) -> None
asyncabstractabstractmethod

执行存储相关操作。

Store the embeddings with the given identifier.

参数Parameters
名称Name类型Type说明Description
embeddingsList[Embedding]向量到存储。The embeddings to store.
identifierJSONSerializableObjectidentifier(类型 `JSONSerializableObject`)。The identifier to distinguish the embeddings.
overwrite默认default Falsebooloverwrite(类型 `bool`)。Whether to overwrite existing embeddings with the same identifier. If `True`, existing embeddings will be replaced.
kwargsAny关键字参数(类型 `Any`)。The kwargs.
返回Returns None
无返回值。No value is returned.
源码Source agentscope/embedding/_cache_base.py:17–34

retrieve

async def retrieve(identifier: JSONSerializableObject) -> List[Embedding] | None
asyncabstractabstractmethod

按查询检索相关文档。

Retrieve the embeddings with the given identifier.

参数Parameters
名称Name类型Type说明Description
identifierJSONSerializableObjectidentifier(类型 `JSONSerializableObject`)。The identifier to retrieve the embeddings.
返回Returns List[Embedding] | None
返回向量化列表。Returns a list of embedding.
源码Source agentscope/embedding/_cache_base.py:37–47

remove

async def remove(identifier: JSONSerializableObject) -> None
asyncabstractabstractmethod

设置移除。

Remove the embeddings with the given identifier.

参数Parameters
名称Name类型Type说明Description
identifierJSONSerializableObjectidentifier(类型 `JSONSerializableObject`)。The identifier to remove the embeddings.
返回Returns None
无返回值。No value is returned.
源码Source agentscope/embedding/_cache_base.py:50–59

clear

async def clear() -> None
asyncabstractabstractmethod

清空或重置内部状态。

Clear all cached embeddings.

返回Returns None
无返回值。No value is returned.
源码Source agentscope/embedding/_cache_base.py:62–63
基于官方固定版本源码静态生成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.