Some models produce almost correct json during function calling, but with additional data before of after it. This solves it.

This commit is contained in:
smonux 2024-09-26 22:02:56 +02:00
parent 1715446b13
commit d8f71e1d7f

View File

@ -440,6 +440,7 @@ async def chat_completion_tools_handler(
if not content: if not content:
return body, {} return body, {}
content = content[content.find("{") : content.rfind("}") + 1]
result = json.loads(content) result = json.loads(content)
tool_function_name = result.get("name", None) tool_function_name = result.get("name", None)