Skip to content

Conversation

@CAPsMANyo
Copy link
Contributor

Description

  • Updates the OllamaEmbeddingResponse struct in src/llm/ollama.rs to match the Ollama API. It now expects embeddings: Vec<Vec> instead of embedding: Vec.
  • Updates embed_text to take the first (index 0) embedding from the nested list.
  • This api endpoint supports multiple inputs and returns a list of embeddings. This change assumes a single input (as required by the LlmEmbeddingClient trait) and parses the first embedding from the response.

Motivation and context

  • The Ollama embedding client was broken because it couldn't parse the correct API response, causing "Invalid JSON" errors.
  • This fix aligns the client with official Ollama documentation - https://docs.ollama.com/api#generate-embeddings

Is this a breaking change?

  • No

Related GitHub issues

Updates the 'OllamaEmbeddingResponse' struct to match the official
Ollama API, which returns a nested 'embeddings: Vec<Vec<f32>>' array
instead of a flat 'embedding: Vec<f32>'.
@CAPsMANyo CAPsMANyo changed the title fix: correctly parse nested embeddings array from ollama endpoint /api/embed fix(ollama): correctly parse nested embeddings array from ollama endpoint /api/embed Oct 27, 2025
@georgeh0 georgeh0 merged commit 5d779e7 into cocoindex-io:main Oct 27, 2025
8 checks passed
@CAPsMANyo CAPsMANyo deleted the ollama-embed-response-fix branch October 27, 2025 20:41
@badmonster0
Copy link
Member

@CAPsMANyo thanks for the PR!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants