Skip to content

[BUG] Ollama.rs expects incorrect response from /api/embed #1226

@CAPsMANyo

Description

@CAPsMANyo

Describe the bug
Ollama.rs is hard coded to use the /api/embed endpoint and expects a return formatted like

{
  "embedding": [
    0.5896830558776855,
    0.2319980412721634,
    -0.20815671980381012
    // ... many more floating-point numbers
  ]
}

This is the expected response of the /api/embeddings endpoint, which Ollama has said is deprecated

The actual response from /api/embed is

{
  "model": "nomic-embed-text",
  "embeddings": [
    [
      0.034329344,
      0.059441593,
      -0.16081077,
      "..."
    ]
  ],
  "total_duration": 66893984,
  "load_duration": 17070078,
  "prompt_eval_count": 10
}

Official ollama docs https://docs.ollama.com/api#generate-embeddings

To Reproduce
Attempt to embed with api_type=cocoindex.LlmApiType.OLLAMA,

Expected behavior
Working embedding with native Ollama endpoint

Screenshots

[2025-10-27T16:05:30Z ERROR cocoindex_engine::execution::source_indexer] Error in processing row from flow `repo_embeddings` source `repo` with key: {"requirements.txt"}
    
    Caused by:
        0: Evaluating ForEach op `.for_each.0`
        1: Evaluating in scope with key {"requirements.txt"}
        2: Evaluating ForEach op `.for_each.1`
        3: Evaluating in scope with key {[0, 345)}
        4: Evaluating Transform op `embedding`
        5: Invalid JSON
        6: error decoding response body
        7: missing field `embedding` at line 1 column 9601

CocoIndex Version
0.22.2

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions