类class
agentscope.embeddingOllamaEmbeddingModel
class OllamaEmbeddingModel(EmbeddingModelBase[str | TextBlock])
源码Source
agentscope/embedding/_ollama/_model.py:15–146Ollama 向量化模型,与模型服务通信并返回生成或向量化结果。位于 agentscope.embedding 包,继承自 EmbeddingModelBase[str | TextBlock]。
Wraps locally-hosted embedding models served by Ollama (e.g.
nomic-embed-text, mxbai-embed-large). Inherits batching
and retry logic from :class:EmbeddingModelBase. TextBlock
items in the input list are unpacked to their .text field by
the base class before _call_api runs, so this subclass only
has to handle plain str.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(credential: CredentialBase, model: str, dimensions: int | None, parameters: 'OllamaEmbeddingModel.Paramete… | 初始化 `OllamaEmbeddingModel` 实例。 Initialize the Ollama embedding model. |
构造器详情Constructor Detail
OllamaEmbeddingModel
def __init__(credential: CredentialBase, model: str, dimensions: int | None, parameters: 'OllamaEmbeddingModel.Parameters | None' = None, embedding_cache: EmbeddingCacheBase | None = None, context_size: int = 8192, max_retries: int = 3, retry_delay: float = 1.0) -> None
初始化 OllamaEmbeddingModel 实例。
Initialize the Ollama embedding model.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
credential | CredentialBase | 凭证对象(类型 `CredentialBase`)。An :class:`~agentscope.credential.OllamaCredential` instance providing the host URL. |
model | str | 模型实例(类型 `str`)。The embedding model name (e.g. `"nomic-embed-text"`). |
dimensions | int | None | 向量维度(类型 `int | None`)。The output embedding vector dimensions. Required at the contract level — see :class:`EmbeddingModelBase` for the rationale. `None` is accepted only for backward compatibility with legacy configs that persisted `dimensions` inside `parameters`. |
parameters默认default None | 'OllamaEmbeddingModel.Parameters | None' | 参数(类型 `'OllamaEmbeddingModel.Parameters | None'`)。Provider-specific non-dimensional parameters. Currently empty for Ollama. |
embedding_cache默认default None | EmbeddingCacheBase | None | 向量化缓存(类型 `EmbeddingCacheBase | None`)。Optional embedding cache. |
context_size默认default 8192 | int | 上下文大小(类型 `int`)。Maximum input tokens per text. |
max_retries默认default 3 | int | 最大重试次数(类型 `int`)。Number of retries on transient failures. |
retry_delay默认default 1.0 | float | 重试延迟(类型 `float`)。Seconds between retry attempts. |
源码Source
agentscope/embedding/_ollama/_model.py:28–87