[GH-ISSUE #4372] When can I make the api support functions parameters like openai, using langchain implementation will make the request slow, which is not what I want #2729

Closed
opened 2026-04-12 13:02:42 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @zhangweiwei0326 on GitHub (May 12, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/4372

What is the issue?

from langchain_experimental.llms.ollama_functions import OllamaFunctions

model=OllamaFunctions(base_url="http://192.168.1.117:11434", model="qwen:4b", temperature=0.0, format="json")

绑定这个函数

model_with_tools = model.bind_tools(
tools = [
{
"name": "getCurrentWeather",
"description": "获取本地的天气情况",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "城市名称,如:添加",
},
},
"required": ["location"],
},
}
],
function_call={"name": "getCurrentWeather"},
)
output = model_with_tools.invoke("北京的天气怎么样?")
print(output)

上面代码会输出
content='' additional_kwargs={'function_call': {'name': 'getCurrentWeather', 'arguments': '{"location": "\u5317\u4eac"}'}} id='run-4867ae50-51c7-4d3a-b093-a082dbd1b25a-0'

OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @zhangweiwei0326 on GitHub (May 12, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/4372 ### What is the issue? from langchain_experimental.llms.ollama_functions import OllamaFunctions model=OllamaFunctions(base_url="http://192.168.1.117:11434", model="qwen:4b", temperature=0.0, format="json") # 绑定这个函数 model_with_tools = model.bind_tools( tools = [ { "name": "getCurrentWeather", "description": "获取本地的天气情况", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "城市名称,如:添加", }, }, "required": ["location"], }, } ], function_call={"name": "getCurrentWeather"}, ) output = model_with_tools.invoke("北京的天气怎么样?") print(output) 上面代码会输出 content='' additional_kwargs={'function_call': {'name': 'getCurrentWeather', 'arguments': '{"location": "\\u5317\\u4eac"}'}} id='run-4867ae50-51c7-4d3a-b093-a082dbd1b25a-0' ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-04-12 13:02:42 -05:00
Author
Owner

@zhangweiwei0326 commented on GitHub (May 13, 2024):

https://github.com/ollama/ollama/issues/4386

<!-- gh-comment-id:2106725614 --> @zhangweiwei0326 commented on GitHub (May 13, 2024): https://github.com/ollama/ollama/issues/4386
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#2729