Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.
TypeScript
fix(RAG): pass num_ctx and truncate to Ollama embed call (#763)
chriscrosstalk7bebedcefa16
diff --git a/admin/app/services/ollama_service.ts b/admin/app/services/ollama_service.tsindex 27f5cac7..fe0cb1c8 100644--- a/admin/app/services/ollama_service.ts+++ b/admin/app/services/ollama_service.ts@@ -480,10 +480,21 @@ export class OllamaService {}try {- // Prefer Ollama native endpoint (supports batch input natively)+ // Prefer Ollama native endpoint (supports batch input natively).+ // Pass num_ctx explicitly so we don't depend on the embedding model's+ // modelfile defaults. Some installs ship nomic-embed-text:v1.5 with+ // num_ctx=2048, which our chunker (sized for ~1500 tokens) can exceed+ // on dense content, causing "input length exceeds context length" errors.+ // truncate:true is a runtime safety net for any chunk that still overshoots.+ // 8192 matches nomic-embed-text:v1.5's RoPE-extrapolated max.const response = await axios.post(`${this.baseUrl}/api/embed`,- { model, input },+ {+ model,+ input,+ truncate: true,+ options: { num_ctx: 8192 },+ },{ timeout: 60000 })// Some backends (e.g. LM Studio) return HTTP 200 for unknown endpoints with an incompatible