How to get the function output?

Hi there,

Currently in playground and when interacting with the API I seem to not understand how to actually get the data out from the function. I made a function that defines the JSON layout that I want the data to be returned in, nothing more. However on playground it asks for me to submit additional message such as {success: true} then when I do submit that it ends up returning the data not in json format.

While on the API side I am able to extract the data from the incomplete function when doing it like so steps.data[0].step_details.tool_calls[-1].function.arguments however, I understand this is not the best way, or the right way. So I am wondering what is the right way? This currently works for me for 3.5 but not for 4.

When I switch over to 4 it says that there is no .tool_calls (at least there).

I want to do it the right way so it’s not a hack and so I can change between 3.5 and 4 when needed, could someone help me out here?

Thanks in advance.

This worked for me with gpt4

        tool_id=run_steps.data[0].step_details.tool_calls[0].id

        tools_call_response = client.beta.threads.runs.submit_tool_outputs(
                thread_id=thread.id,
                run_id=run.id,
                tool_outputs=[
                    {
                        "tool_call_id":tool_id,
                        "output":'{"success:true"}'
                        }
                    ]
                )
1 Like