类class
agentscope.embeddingEmbeddingCacheBase
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 |
|---|---|---|
embeddings | List[Embedding] | 向量到存储。The embeddings to store. |
identifier | JSONSerializableObject | identifier(类型 `JSONSerializableObject`)。The identifier to distinguish the embeddings. |
overwrite默认default False | bool | overwrite(类型 `bool`)。Whether to overwrite existing embeddings with the same identifier. If `True`, existing embeddings will be replaced. |
kwargs | Any | 关键字参数(类型 `Any`)。The kwargs. |
None
无返回值。No value is returned.
源码Source
agentscope/embedding/_cache_base.py:17–34retrieve
async def retrieve(identifier: JSONSerializableObject) -> List[Embedding] | None
asyncabstractabstractmethod
按查询检索相关文档。
Retrieve the embeddings with the given identifier.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
identifier | JSONSerializableObject | identifier(类型 `JSONSerializableObject`)。The identifier to retrieve the embeddings. |
List[Embedding] | None
返回向量化列表。Returns a list of embedding.
源码Source
agentscope/embedding/_cache_base.py:37–47remove
async def remove(identifier: JSONSerializableObject) -> None
asyncabstractabstractmethod
设置移除。
Remove the embeddings with the given identifier.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
identifier | JSONSerializableObject | identifier(类型 `JSONSerializableObject`)。The identifier to remove the embeddings. |
None
无返回值。No value is returned.
源码Source
agentscope/embedding/_cache_base.py:50–59clear
async def clear() -> None
asyncabstractabstractmethod
清空或重置内部状态。
Clear all cached embeddings.
None
无返回值。No value is returned.
源码Source
agentscope/embedding/_cache_base.py:62–63