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

OllamaEmbeddingModel

class OllamaEmbeddingModel(EmbeddingModelBase[str | TextBlock])
源码Source agentscope/embedding/_ollama/_model.py:15–146

Ollama 向量化模型,与模型服务通信并返回生成或向量化结果。位于 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
credentialCredentialBase凭证对象(类型 `CredentialBase`)。An :class:`~agentscope.credential.OllamaCredential` instance providing the host URL.
modelstr模型实例(类型 `str`)。The embedding model name (e.g. `"nomic-embed-text"`).
dimensionsint | 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 NoneEmbeddingCacheBase | None向量化缓存(类型 `EmbeddingCacheBase | None`)。Optional embedding cache.
context_size默认default 8192int上下文大小(类型 `int`)。Maximum input tokens per text.
max_retries默认default 3int最大重试次数(类型 `int`)。Number of retries on transient failures.
retry_delay默认default 1.0float重试延迟(类型 `float`)。Seconds between retry attempts.
源码Source agentscope/embedding/_ollama/_model.py:28–87

继承成员Inherited Members

基于官方固定版本源码静态生成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.