We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
nunomaduro
gehrisandro
Learn more about funding links in repositories.
Report abuse
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to run an assistant, >threads()->messages()->list and $allMessages->data is returning the following response only:
>threads()->messages()->list
$allMessages->data
Run status: completed Array ( [0] => OpenAI\Responses\Threads\Messages\ThreadMessageResponse Object ( [id] => msg_Mc6EQ9OjSZ0zUPf5h28a4Bqs [object] => thread.message [createdAt] => 1705610963 [threadId] => thread_cSCy95o2DWDTR2UaY0HjlFOS [role] => user [content] => Array ( [0] => OpenAI\Responses\Threads\Messages\ThreadMessageResponseContentTextObject Object ( [type] => text [text] => OpenAI\Responses\Threads\Messages\ThreadMessageResponseContentText Object ( [value] => Write me description for Icecream Machine [annotations] => Array ( ) ) ) ) [assistantId] => [runId] => [fileIds] => Array ( ) [metadata] => Array ( ) [meta:OpenAI\Responses\Threads\Messages\ThreadMessageResponse:private] => OpenAI\Responses\Meta\MetaInformation Object ( [requestId] => fe3cce0834ec01c0585230b7c048a8e9 [openai] => OpenAI\Responses\Meta\MetaInformationOpenAI Object ( [model] => [organization] => user-mcgdqt1tm3gqg7bictrvyogv [version] => 2020-10-01 [processingMs] => 83 ) [requestLimit] => [tokenLimit] => ) ) )
It is not returning the response by the Assistant.
The code:
$openAI = OpenAI::client(KEY); // $response = $openAI->assistants()->retrieve(ASSISTANT_ID_PRODUCT_OFFER_WRITER); $result = createRunThread(ASSISTANT_ID_PRODUCT_OFFER_WRITER,"Write me description for Icecream Machine",$openAI);
Function Definition
function createRunThread($assistantId, $userPrompt, $openAIClient) { $threadID = $runID = 0; // Thread Creation $thread = $openAIClient->threads()->create([]); $threadID = $thread->id; //Message Creation $message = $openAIClient ->threads() ->messages() ->create($threadID, [ 'role' => 'user', 'content' => $userPrompt, ]); //Run Creation $run = $openAIClient->threads()->runs()->create( threadId: $threadID, parameters: [ 'assistant_id' => $assistantId, ], ); $runID = $run->id; //Periodically retrieve the Run to check status and see if it has completed //Should print "in_progress" several times before completing while ($run->status != "completed") { $response = $openAIClient->threads() ->runs() ->retrieve( threadId: $threadID, runId: $runID, ); print("Run status: {$response->status}\n"); if($response->status == "completed") { break; } sleep(1); } //Retrieve messages added by the Assistant to the thread $allMessages = $openAIClient->threads() ->messages() ->list($threadID); print_r($allMessages->data); return null; }
0.8.1
8.1
No response
The text was updated successfully, but these errors were encountered:
Hi @kadnan
Not sure what the issue is here, but looks like your code is a bit messed up. You are not updating the $run.
$run
Maybe my example here does help you: https://gehri.dev/blog/how-to-use-the-openai-assistants-api-in-php-and-laravel
Otherwise please provide a sample repository to which reproduces the issue.
Sorry, something went wrong.
No branches or pull requests
Description
I am trying to run an assistant,
>threads()->messages()->list
and$allMessages->data
is returning the following response only:It is not returning the response by the Assistant.
Steps To Reproduce
The code:
Function Definition
OpenAI PHP Client Version
0.8.1
PHP Version
8.1
Notes
No response
The text was updated successfully, but these errors were encountered: