try to fix arguments return from GPT

This commit is contained in:
fiatrete
2023-06-16 15:58:57 +08:00
parent 034cb1f5e4
commit 73140529c7
+2 -3
View File
@@ -55,10 +55,10 @@ class GptAgent(BaseAgent):
"speak": assistant_reply, "speak": assistant_reply,
} }
elif reply_type == "function_call": elif reply_type == "function_call":
# TODO: Check arguments arguments = fix_json_using_multiple_techniques(assistant_reply["arguments"])
return { return {
"function": assistant_reply["name"], "function": assistant_reply["name"],
"arguments": json.loads(assistant_reply["arguments"]) "arguments": arguments
} }
async def feed_prompt(self, prompt): async def feed_prompt(self, prompt):
@@ -86,7 +86,6 @@ class GptAgent(BaseAgent):
function_name: str = reply.get("function") function_name: str = reply.get("function")
if function_name is None: if function_name is None:
await self._caller_context.reply_text(reply["speak"]) await self._caller_context.reply_text(reply["speak"])
pass
else: else:
arguments: Dict = reply["arguments"] arguments: Dict = reply["arguments"]