hadadrjt's picture
SearchGPT: Enhance. #2
ceb70c7
raw
history blame contribute delete
812 Bytes
#
# SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org>
# SPDX-License-Identifier: Apache-2.0
#
def assistant_response(response_message):
extracted_tool_calls = []
if getattr(response_message, "tool_calls", None):
for tool_call in response_message.tool_calls:
extracted_tool_calls.append(
{
"id": tool_call.id,
"type": "function",
"function": {
"name": tool_call.function.name,
"arguments": tool_call.function.arguments
}
}
)
return {
"role": "assistant",
"content": response_message.content or "",
"tool_calls": extracted_tool_calls if extracted_tool_calls else None
}