openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.57k stars 466 forks source link

get reply of run #317

Closed ahsan154 closed 5 months ago

ahsan154 commented 5 months ago

Hi,

I am new to chatgpt and trying to digest this whole thing, My client has already trained assistants created by him in his account, he provided me an assistant_id e.g: asst_XXXXXXXXXX, now i want to send message to that assistant and want to get his reply, after reading your documentation i came to know that i need to create a thread to assistant, then run that thread, once the the thread run is completed, now i am unable to get reply from the assistnat against the thread_id and run_id, which query will give me reply

  1. $client->threads()->createAndRun(assistant_id and message sleep()
  2. $response2 = $client->threads()->runs()->create(thread_id, assistant_id sleep()
  3. $response = $client->threads()->runs()->retrieve(thread_id, run_id

I am calling the above three methods and need help/guidance which method to called and get my reply from the assistant

Regards,

aconital commented 5 months ago

Same question on my end

gehrisandro commented 5 months ago

You can read the messages from the messages list endpoint: https://github.com/openai-php/client?tab=readme-ov-file#list-5

You can find an example in my blog post: https://gehri.dev/blog/how-to-use-the-openai-assistants-api-in-php-and-laravel