Is there a limit on the usage of the Assistant that is currently in beta release?

Hi, I am creating an Assistant and retrieving its id to conduct tests.
Initially, I could see an object with the role property as ‘assistant’ included in a list of messages for a given thread for about the first four times.
But at some point, the assistant object stopped being included. The code has not been changed.

  const assistant = await openai.beta.assistants.retrieve('#assistant_id');

  const thread = await openai.beta.threads.create();

  await openai.beta.threads.messages.create(thread.id, {
    role: 'user',
    content: question
  });

  await openai.beta.threads.runs.create(thread.id, {
    assistant_id: assistant.id
  });

  const messages = await openai.beta.threads.messages.list(thread.id);
console.log(messages);

ThreadMessagesPage {
  options: {
    method: 'get',
    path: '/threads/#thread_id/messages',
    query: {},
    headers: { 'OpenAI-Beta': 'assistants=v1' }
  },
  response: Response {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [Gunzip], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'https://api.openai.com/v1/threads/#thread_id/messages',
      status: 200,
      statusText: 'OK',
      headers: [Headers],
      counter: 0
    }
  },
  body: {
    object: 'list',
    data: [ [Object] ],
    first_id: '#msg_id',
    last_id: '#msg_id',
    has_more: false
  },
  data: [
    {
      id: ''#msg_id',
      object: 'thread.message',
      created_at: 1701051827,
      thread_id: 'thread_id',
      role: 'user',
      content: [Array],
      file_ids: [],
      assistant_id: null,
      run_id: null,
      metadata: {}
    }
  ]
}

console.log(messages.data[0].content.length);

1

Let me see if I have this correct, you created an assistant then added a thread to it and then added a message to it and then performed a run, to which the AI generated some content and added it as an assistant reply?

2 Likes

Yes, that’s right. I referred to the link at https://platform.openai.com/docs/assistants/overview. The Assistant’s response should have been added to the message list. However, from what I saw, it seems like there’s no API request being made.

Can you show some output logs of what you mean, because I’m not sure what might be happening.

What I think might be happening given the numbers you mentioned is that you are on the free Tier which only allows 3 calls per minute, so on the 4th call you are getting a rate limit error and that is then not creating an assistant message entry, however once you have done some investigation the minute rate limit time has passed and you try again only to get the same thing.

You could try adding a payment method and loading $5 of credit and this issue may go away, but either way you should put some error handling in your code to detect when issues like API failures or rate limits have been encountered.

1 Like

The messages object created according to the above code contains the assistant’s response in its data. However, as I mentioned before, after successfully receiving about four times like this, the messages no longer include the assistant response, as shown in the above output log."

I believe I’m sufficiently covering the costs as I’m using an organization account. Thank you for your help.
I attach the output image when I receive a response, i.e., when it’s successful. The important part is marked with a red square.

It’s okay if it’s not resolved. I just want to verify if it can be used. :grinning:

1 Like

Do you loop around the run to check its status before you retrieve the messages?

2 Likes

No, I do not loop around to check the run status. I didn’t do it because I thought it was unnecessary.
In fact, there was no difference whether I did it or not. Did I miss something?

1 Like

By the way, It should lead to a discussion, but right now, it feels like I’m using it as if it were Stack Overflow. :sweat_smile: :sweat_smile:

If it’s not appropriate, you don’t have to solve the problem.

1 Like

It’s okay. But you need to loop around the run and check its status and retrieve the messages when it is completed. Do you have retrieval/function calling in your assistant? If you have those, you definitely need to check the status.

3 Likes

Another great spot by @supershaneski there! That’ll do it!

2 Likes

Got it. I understand that I need to check the status. I’ve checked. My assistant does have retrieval calling. When I checked the log by looking at the run status, I noticed that the status is continuously in_progress.

I’ve gained insight for the next step. Thank you so much! @supershaneski @Foxalabs

2 Likes