Commit eca2212
fix: bypass LiteLLM for Ollama embeddings to resolve 400 Bad Request
LiteLLM's Ollama embedding handler sends a malformed request to Ollama's
/api/embed endpoint, causing a 400 Bad Request error on Ollama 0.18.x.
- Add `_ollama_embed()` to `LiteLLMEmbeddingWrapper` that calls Ollama's
`/api/embed` directly via httpx, stripping the "ollama/" prefix from
the model name (the root cause of the malformed request)
- Route `embed_query` and `embed_documents` through this helper when
provider == "ollama", bypassing LiteLLM entirely
- Wrap `search_similarity_threshold` in try/except so an embedding
failure returns [] instead of crashing the agent
Fixes #1425
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 69e1774 commit eca2212
2 files changed
Lines changed: 26 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| 596 | + | |
596 | 597 | | |
597 | 598 | | |
598 | 599 | | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
599 | 608 | | |
600 | 609 | | |
601 | 610 | | |
602 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
603 | 615 | | |
604 | 616 | | |
605 | 617 | | |
| |||
610 | 622 | | |
611 | 623 | | |
612 | 624 | | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
613 | 628 | | |
614 | 629 | | |
615 | 630 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
347 | 351 | | |
348 | 352 | | |
349 | 353 | | |
| |||
0 commit comments