I’m getting the error in the title, I’m beginning to think it’s a bug in the library… I got openai version 1.59.7.
This is my code:
def handle_function_call(call, run, sender_id, thread_id):
tool_output = ''
if call.function.name == 'fetch_user_profile':
logger.info(f'Calling fetch_user_profile with arguments: {sender_id}, {call.function.arguments}')
tool_output = fetch_user_profile(sender_id, json.loads(call.function.arguments)['fields'])
logger.info(f'fetch_user_profile response: {tool_output}')
if tool_output:
output_submission = ToolOutput()
output_submission.output = tool_output
output_submission.tool_call_id = call.id
openai_api.beta.threads.runs.submit_tool_outputs(run_id=run.id, thread_id=thread_id,
tool_outputs=[output_submission])
else:
logger.error(f'Tool call {call} failed! Cancelling run for {sender_id}')
openai_api.beta.threads.runs.cancel(run_id=run.id, thread_id=thread_id)
fetch_user_profile() returns an str like this one:
{'name': 'Piotr Kobus', 'picture': {'data': {'height': 50, 'is_silhouette': False, 'url': 'https://platform-lookaside.fbsbx.com/platform/profilepic/?eai=AXGq11wEYroQukqJwmT-S_Pl-bjs8b-e6ff-Awst51bFerXwH-k40y2rqq6nb0jbsRuoUNyK-5Tp&psid=9015655468510817&height=50&width=50&ext=1739871341&hash=AbagUiEtnY1zlE4h9fR1o6DR', 'width': 50}}, 'id': '9015655468510817'}