Hey all - In the JS lib there is a helper function chat.completions.runTools that automatically calls a js function and passes the output back to the ai to craft the response message or call another function. This has been very handy.
You have to listen for the tool that requires action event.event === "thread.run.requires_action" and then call the function and pass the output to run.submitToolOutputs .
I’m pretty lazy and I’m hoping someone knows of the runTools equivalent for assistants so I don’t have to implement this for a migration to the assistants api.
JS functional ( classes) wrapper that automatically calls functions/tools passed into an assistant api call.
Don’t be scared of all the setup code. The adapted (improved) part is lines 207-223 that finds and calls the function and passes back to the LLM. The rest sets up the test run.