mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-14 09:21:22 +00:00
Merge 805cce8122 into f7b3029a69
This commit is contained in:
commit
465a95e97e
1 changed files with 8 additions and 1 deletions
|
|
@ -328,12 +328,19 @@ def convert_chat_completions_messages_to_ollama(messages: list[dict]) -> list[di
|
|||
# If tool calls are present, add them to the message
|
||||
ollama_tool_calls = []
|
||||
for tool_call in tool_calls:
|
||||
arguments = tool_call.get('function', {}).get('arguments')
|
||||
if isinstance(arguments, str):
|
||||
try:
|
||||
arguments = JSONCodec.loads(arguments)
|
||||
except JSONCodec.JSONDecodeError:
|
||||
arguments = {}
|
||||
|
||||
ollama_tool_call = {
|
||||
'index': tool_call.get('index', 0),
|
||||
'id': tool_call.get('id', None),
|
||||
'function': {
|
||||
'name': tool_call.get('function', {}).get('name', ''),
|
||||
'arguments': JSONCodec.loads(tool_call.get('function', {}).get('arguments', {})),
|
||||
'arguments': arguments if isinstance(arguments, dict) else {},
|
||||
},
|
||||
}
|
||||
ollama_tool_calls.append(ollama_tool_call)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue