Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/llm/ollama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct OllamaEmbeddingRequest<'a> {

#[derive(Debug, Deserialize)]
struct OllamaEmbeddingResponse {
pub embedding: Vec<f32>,
pub embeddings: Vec<Vec<f32>>,
}

const OLLAMA_DEFAULT_ADDRESS: &str = "http://localhost:11434";
Expand Down Expand Up @@ -153,10 +153,17 @@ impl LlmEmbeddingClient for Client {
)
.await
.context("Ollama API error")?;

let embedding_resp: OllamaEmbeddingResponse = resp.json().await.context("Invalid JSON")?;
Ok(super::LlmEmbeddingResponse {
embedding: embedding_resp.embedding,
})

// Extract the first embedding (index 0)
let embedding = embedding_resp
.embeddings
.into_iter()
.next()
.context("Ollama API returned no embeddings")?;

Ok(super::LlmEmbeddingResponse { embedding })
}

fn get_default_embedding_dimension(&self, model: &str) -> Option<u32> {
Expand Down
Loading