ollama_embedding_driver
Adapted from the Griptape AI Framework documentation.
Bases:
BaseEmbeddingDriver
Attributes
Name | Type | Description |
---|---|---|
model | str | Ollama embedding model name. |
host | Optional[str] | Optional Ollama host. |
client | Client | Ollama Client . |
Source Code in griptape/drivers/embedding/ollama_embedding_driver.py
@define class OllamaEmbeddingDriver(BaseEmbeddingDriver): """Ollama Embedding Driver. Attributes: model: Ollama embedding model name. host: Optional Ollama host. client: Ollama `Client`. """ model: str = field(kw_only=True, metadata={"serializable": True}) host: Optional[str] = field(default=None, kw_only=True, metadata={"serializable": True}) _client: Optional[Client] = field(default=None, kw_only=True, alias="client", metadata={"serializable": False}) @lazy_property() def client(self) -> Client: return import_optional_dependency("ollama").Client(host=self.host) def try_embed_chunk(self, chunk: str, **kwargs) -> list[float]: return list(self.client.embeddings(model=self.model, prompt=chunk)["embedding"])
_client = field(default=None, kw_only=True, alias='client', metadata={'serializable': False})
class-attribute instance-attributehost = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute instance-attributemodel = field(kw_only=True, metadata={'serializable': True})
class-attribute instance-attribute
client()
Source Code in griptape/drivers/embedding/ollama_embedding_driver.py
@lazy_property() def client(self) -> Client: return import_optional_dependency("ollama").Client(host=self.host)
try_embed_chunk(chunk, **kwargs)
Source Code in griptape/drivers/embedding/ollama_embedding_driver.py
def try_embed_chunk(self, chunk: str, **kwargs) -> list[float]: return list(self.client.embeddings(model=self.model, prompt=chunk)["embedding"])
Could this page be better? Report a problem or suggest an addition!