Skip to content

The agent engineering platform.

[partner]: ollama llm fix (#24790)

Isaac Francisco78d97b49d9c7
diff --git a/libs/partners/ollama/langchain_ollama/llms.py b/libs/partners/ollama/langchain_ollama/llms.py
index e2bf73cfab..fd7b49dcd9 100644
--- a/libs/partners/ollama/langchain_ollama/llms.py
+++ b/libs/partners/ollama/langchain_ollama/llms.py
@@ -304,11 +304,7 @@ class OllamaLLM(BaseLLM):
for stream_resp in self._create_generate_stream(prompt, stop, **kwargs):
if not isinstance(stream_resp, str):
chunk = GenerationChunk(
- text=(
- stream_resp["message"]["content"]
- if "message" in stream_resp
- else ""
- ),
+ text=(stream_resp.get("response", "")),
generation_info=(
dict(stream_resp) if stream_resp.get("done") is True else None
),
@@ -330,11 +326,7 @@ class OllamaLLM(BaseLLM):
async for stream_resp in self._acreate_generate_stream(prompt, stop, **kwargs):
if not isinstance(stream_resp, str):
chunk = GenerationChunk(
- text=(
- stream_resp["message"]["content"]
- if "message" in stream_resp
- else ""
- ),
+ text=(stream_resp.get("response", "")),
generation_info=(
dict(stream_resp) if stream_resp.get("done") is True else None
),