mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-19 13:23:35 +00:00
community[patch]: Add "model" attribute to the payload sent to Ollama in ChatOllama
(#20354)
Example Ollama API calls: Request without "model": ``` curl --location 'http://localhost:11434/api/chat' \ --header 'Content-Type: application/json' \ --data '{ "messages": [ { "role": "user", "content": "What is the capitol of PA?" } ], "stream": false }' ``` Response: ``` {"error":"model is required"} ``` Request with "model": ``` curl --location 'http://localhost:11434/api/chat' \ --header 'Content-Type: application/json' \ --data '{ "model": "openchat", "messages": [ { "role": "user", "content": "What is the capitol of PA?" } ], "stream": false }' ``` Response: ``` { "eval_duration" : 733248000, "created_at" : "2024-04-11T23:04:08.735766843Z", "model" : "openchat", "message" : { "content" : " The capital city of Pennsylvania is Harrisburg.", "role" : "assistant" }, "total_duration" : 3138731168, "prompt_eval_count" : 25, "load_duration" : 466562959, "done" : true, "prompt_eval_duration" : 1938495000, "eval_count" : 10 } ```
This commit is contained in:
parent
57bb940c17
commit
9317df7f16
@ -156,6 +156,7 @@ class ChatOllama(BaseChatModel, _OllamaCommon):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> Iterator[str]:
|
) -> Iterator[str]:
|
||||||
payload = {
|
payload = {
|
||||||
|
"model": self.model,
|
||||||
"messages": self._convert_messages_to_ollama_messages(messages),
|
"messages": self._convert_messages_to_ollama_messages(messages),
|
||||||
}
|
}
|
||||||
yield from self._create_stream(
|
yield from self._create_stream(
|
||||||
@ -169,6 +170,7 @@ class ChatOllama(BaseChatModel, _OllamaCommon):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> AsyncIterator[str]:
|
) -> AsyncIterator[str]:
|
||||||
payload = {
|
payload = {
|
||||||
|
"model": self.model,
|
||||||
"messages": self._convert_messages_to_ollama_messages(messages),
|
"messages": self._convert_messages_to_ollama_messages(messages),
|
||||||
}
|
}
|
||||||
async for stream_resp in self._acreate_stream(
|
async for stream_resp in self._acreate_stream(
|
||||||
|
Loading…
Reference in New Issue
Block a user