Assistant Response JSON issue (Streaming)

I have created an assistant with a file search feature. I want to get the response in JSON format. In the instructions, I have mentioned to output the response in valid JSON and even provided the JSON format, but I’m unable to get the response in proper JSON. As a workaround, I tried to clean and parse using the JavaScript string replace method to replace \n and asterisks. However, I’m concerned about how to handle this when implementing streaming. I have read somewhere about creating a function call just to get the response in JSON format. It will use tokens, but I’m also not sure if this workaround will work for streaming.

you want to stream JSONs? :thinking:

how are you gonna parse them? :face_with_monocle:

One quick fix that comes to mind is to just automatically append

Remember, only emit valid JSON, otherwise the system will break.
Start your response with {

to the last message.

My question is if im getting stick to cleaning and parsing the response into json , then how would i handle it when implementing streaming ?

I’m not sure I understand. It’s quite easy to get proper json output…

Can you tell me how ? Im newbie