I am trying to utilize the function calling feature of assistants API to call an external REST API. I am running this code from my local environment that has internet access. This code used to work before.
But now it is throwing an error at the step where run status is “requires_action”
I get this error:
AttributeError: ‘NoneType’ object has no attribute ‘submit_tool_outputs’
before the function call.
This is the piece of code that throws this error:
run = submit_tool_outputs(st.session_state.thread.id, run.id, run.required_action.submit_tool_outputs.tool_calls, run)
Any help would be great. Thanks!
I suspect the code reads run.submit_tool_outputs(… ) not run = …
And the error means that run. is None and you trying to .submit_tool_outputs() so check your code (debug step by step maybe?) to to see why run is not what you expect it to be (a run object)
Function Calling is optional and was decided by the model. If the assistant change the mind and think this question run did not require any function calling, the required_action will be null.
You may need to check this attribute not null before call functions(and equired_action.submit_tool_outputs.tool_calls is array and need to take care of that, sometime it asked more than one call to the same function with different parameters, and if you submit only first one call_id it will produce exception).
And why this used to work before and have error now? Maybe related to recent topic regards GPT became LAZY , but that’s another issue. We need to protect our code’s robustness.
Thanks all ! it looks like a mistake from my end.
I had earlier used this statement in my code :
run_status = st.session_state.client.beta.threads.runs.retrieve(
before call the submit_tools_outputs function.
After passing run_status.required_action.submit_tool_outputs.tool_calls as the parameter, the issue got resolved.
Thanks for your replies !
Can you post the complete solution. I have the same issue. Not sure what you meant by passing run_status.required_action.submit_tool_outputs.tool_calls as the parameter.