Using Assistants with Chat API

Im using chat/completions as I dont need a chat facility, I need to send a block of text, and have chatgpt run queries over it.
But I would like to use the Assistants file_search facility, as I have some pre defined Identifiers id id like to get back.

I don’t think assistants are supported in chat?

I have it working in the Assistants playground.
I have to use /v1/threads

I’m trying to work through this, but it seems I have to

  1. Create a Thread
    2)Add Messages to the Thread
  2. Run the thread specifying assistant_id
  3. Get a response from the Run
  4. The retrieve the Messages from the thread

After Step 5, I get messages back, but none contain any AI response, I get the feeling I need to be polling some API waiting, but API documentation isn’t clear, I’m just assuming that from what i have seen in python

I’m using .NET rather than Python, so its hard to find examples online.

I got completions working pretty easily, Assistants I’m struggling with.

Essentially, how do I get the AI generated response back?

Are you waiting for the Run to Complete? Check if the Response you’re getting from run has status completed. If not wait and then check again, retrieve the thread messages only when Run is complete.

I too used different language than Python, in my case it was Apex. This doesn’t support streaming but you can check if you can add the Streaming to stream the results.

If not, add polling.

Thanks for responding, I added polling every 100ms, and got the response back.

Just didnt seem right to me for some reason to be doing that.

1 Like

Yeah, run do take little bit time to run.

If you issue is fixed, you can mark this topic closed by selecting correct solution.