autorag.embed

Ollama-backed embedder for document and chunk text.

Wraps langchain_ollama.OllamaEmbeddings and resolves its base URL and model from the environment so the same defaults apply across the CLI, SDK, and server:

  • AUTORAG_OLLAMA_BASE_URL — defaults to http://localhost:11434.

  • AUTORAG_EMBED_MODEL — defaults to nomic-embed-text.

class autorag.embed.Embedder(base_url=None, model=None)[source]

Bases: object

Thin wrapper around OllamaEmbeddings.

Exposes embed_texts() for raw strings and embed_chunks() for in-place enrichment of Chunk objects.

Parameters:
  • base_url (str | None) – Override the Ollama server URL. Falls back to the AUTORAG_OLLAMA_BASE_URL env var, then http://localhost:11434.

  • model (str | None) – Override the embedding model name. Falls back to AUTORAG_EMBED_MODEL, then nomic-embed-text.

embed_texts(texts)[source]

Embed a list of strings, returning one vector per input.

Raises RuntimeError with the configured Ollama URL on connection or model errors. Empty input returns [] without touching the network.

Parameters:

texts (list[str])

Return type:

list[list[float]]

embed_chunks(chunks)[source]

Set chunk.embedding on every chunk in place; return the same list.

Parameters:

chunks (list[Chunk])

Return type:

list[Chunk]