{"record":{"id":"b240b4e2cc51fe25","repo":"Mintplex-Labs/anything-llm","slug":"ollama-getchatcompletion-failed-to-communicate-wi","errorCode":null,"errorMessage":"Ollama::getChatCompletion failed to communicate with Ollama. ${this.#errorHandler(e).message}","messagePattern":"Ollama::getChatCompletion failed to communicate with Ollama\\. (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/ollama/index.js","lineNumber":298,"sourceCode":"            num_ctx: this.promptWindowLimit(),\n          },\n        })\n        .then((res) => {\n          let content = res.message.content;\n          if (res.message.thinking)\n            content = `<think>${res.message.thinking}</think>${content}`;\n          return {\n            content,\n            usage: {\n              prompt_tokens: res.prompt_eval_count,\n              completion_tokens: res.eval_count,\n              total_tokens: res.prompt_eval_count + res.eval_count,\n              duration: res.eval_duration / 1e9,\n            },\n          };\n        })\n        .catch((e) => {\n          throw new Error(\n            `Ollama::getChatCompletion failed to communicate with Ollama. ${this.#errorHandler(e).message}`\n          );\n        })\n    );\n\n    if (!result.output.content || !result.output.content.length)\n      throw new Error(`Ollama::getChatCompletion text response was empty.`);\n\n    return {\n      textResponse: result.output.content,\n      metrics: {\n        prompt_tokens: result.output.usage.prompt_tokens,\n        completion_tokens: result.output.usage.completion_tokens,\n        total_tokens: result.output.usage.total_tokens,\n        outputTps:\n          result.output.usage.completion_tokens / result.output.usage.duration,\n        duration: result.output.usage.duration,\n        model: this.model,","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/ollama/index.js#L280-L316","documentation":"Catch wrapper in OllamaAILLM.getChatCompletion: the Ollama SDK chat request failed (instance unreachable, connection refused, or API error) and the #errorHandler-normalized message is rethrown so the failure names both the method and the underlying cause.","triggerScenarios":"Thrown when a chat completion request to Ollama fails.","commonSituations":"Ollama down, model missing, or request error.","solutions":["Ensure Ollama is running and reachable.","Verify the model is pulled (ollama pull <model>).","Review the handled error message for details."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}