mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
fix: ollama tool call
This commit is contained in:
parent
2470da8336
commit
260137fc12
1 changed files with 5 additions and 6 deletions
|
|
@ -6,18 +6,17 @@ from open_webui.utils.misc import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def convert_ollama_tool_call_to_openai(tool_calls: dict) -> dict:
|
def convert_ollama_tool_call_to_openai(tool_calls: list) -> list:
|
||||||
openai_tool_calls = []
|
openai_tool_calls = []
|
||||||
for tool_call in tool_calls:
|
for tool_call in tool_calls:
|
||||||
|
function = tool_call.get("function", {})
|
||||||
openai_tool_call = {
|
openai_tool_call = {
|
||||||
"index": tool_call.get("index", 0),
|
"index": tool_call.get("index", function.get("index", 0)),
|
||||||
"id": tool_call.get("id", f"call_{str(uuid4())}"),
|
"id": tool_call.get("id", f"call_{str(uuid4())}"),
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"function": {
|
"function": {
|
||||||
"name": tool_call.get("function", {}).get("name", ""),
|
"name": function.get("name", ""),
|
||||||
"arguments": json.dumps(
|
"arguments": json.dumps(function.get("arguments", {})),
|
||||||
tool_call.get("function", {}).get("arguments", {})
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
openai_tool_calls.append(openai_tool_call)
|
openai_tool_calls.append(openai_tool_call)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue