Is it possible to set the response_format as json when using the assistant api instead of the classic chat api?
Doesn’t seem to be a way to do it in the docs, but seems silly since you can set files, tools, system messages, and more at the assistant, thread, and message level when using assistant api.
Afraid not, as of November 2023, JSON mode is not supported in the Assistants API
I have noticed that the instruction following capability of the Assistant is poor. I have requested it to return the answer in JSON format, but it still outputs some other information.
Ability to support Assistants API with JSON mode would be helpful.
Noticed that assistant quite often stops returning response as JSON.
Are the any plans in near future to enable this functionality?
This really limits the usefulness of the assistant API in situations where I need to be able to inject structured data. Are there any plans to add this?
It surprises me that it is not already supported. I hope that it will be added in the near future.
@robmartin You can take the response from the Assistant and then run it through the chat api to have it format it in JSON for you. Should work for the time being at least until they add it into the Assistant API.
I agree, not being able to get the data the same way every time is nearly impossible to code reliably to.
I don’t think this is exactly what you’re looking for, but I thought I’d share the function I’m using to print the responses from Assistant API calls:
json_string = json.dumps(messages_list, default=obj_dict, indent=4)
This example is for
messages_list, a list of messages from a thread, but should work for any response.