Skip to content

The agent engineering platform.

community[patch]: Add "model" attribute to the payload sent to Ollama in `ChatOllama` (#20354)

P. Taylor Goetz9317df7f16e0
diff --git a/libs/community/langchain_community/chat_models/ollama.py b/libs/community/langchain_community/chat_models/ollama.py
index 1562a69845..5e5a98f8ae 100644
--- a/libs/community/langchain_community/chat_models/ollama.py
+++ b/libs/community/langchain_community/chat_models/ollama.py
@@ -156,6 +156,7 @@ class ChatOllama(BaseChatModel, _OllamaCommon):
**kwargs: Any,
) -> Iterator[str]:
payload = {
+ "model": self.model,
"messages": self._convert_messages_to_ollama_messages(messages),
}
yield from self._create_stream(
@@ -169,6 +170,7 @@ class ChatOllama(BaseChatModel, _OllamaCommon):
**kwargs: Any,
) -> AsyncIterator[str]:
payload = {
+ "model": self.model,
"messages": self._convert_messages_to_ollama_messages(messages),
}
async for stream_resp in self._acreate_stream(