Closed arturspon closed 1 month ago
This bug started happening after #406.
When sending a message with a file and using streaming, it raises an exception with the following message: "Undefined array key "input".
Modifying the line 48 of the file src/Responses/Threads/Runs/Steps/Delta/ThreadRunStepDeltaObject.php to $attributes['input'] ?? '' made it work.
src/Responses/Threads/Runs/Steps/Delta/ThreadRunStepDeltaObject.php
$attributes['input'] ?? ''
Stacktrace:
ErrorException: Undefined array key "input" #15 /vendor/openai-php/client/src/Responses/Threads/Runs/Steps/ThreadRunStepResponseCodeInterpreter.php(48): Illuminate\Foundation\Bootstrap\HandleExceptions::handleError #14 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure} #13 /vendor/openai-php/client/src/Responses/Threads/Runs/Steps/ThreadRunStepResponseCodeInterpreter.php(48): OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseCodeInterpreter::from #12 /vendor/openai-php/client/src/Responses/Threads/Runs/Steps/ThreadRunStepResponseCodeToolCall.php(43): OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseCodeToolCall::from #11 /vendor/openai-php/client/src/Responses/Threads/Runs/Steps/ThreadRunStepResponseToolCallsStepDetails.php(42): OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseToolCallsStepDetails::OpenAI\Responses\Threads\Runs\Steps\{closure} #10 [internal](0): array_map #9 /vendor/openai-php/client/src/Responses/Threads/Runs/Steps/ThreadRunStepResponseToolCallsStepDetails.php(40): OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseToolCallsStepDetails::from #8 /vendor/openai-php/client/src/Responses/Threads/Runs/Steps/Delta/ThreadRunStepDeltaObject.php(39): OpenAI\Responses\Threads\Runs\Steps\Delta\ThreadRunStepDeltaObject::from #7 /vendor/openai-php/client/src/Responses/Threads/Runs/Steps/Delta/ThreadRunStepDeltaResponse.php(40): OpenAI\Responses\Threads\Runs\Steps\Delta\ThreadRunStepDeltaResponse::from #6 /vendor/openai-php/client/src/Responses/Threads/Runs/ThreadRunStreamResponse.php(63): OpenAI\Responses\Threads\Runs\ThreadRunStreamResponse::from #5 /vendor/openai-php/client/src/Responses/StreamResponse.php(68): OpenAI\Responses\StreamResponse::getIterator #4 /app/Http/Controllers/ChatController.php(54): App\Http\Controllers\ChatController::App\Http\Controllers\{closure} #3 /vendor/symfony/http-foundation/StreamedResponse.php(106): Symfony\Component\HttpFoundation\StreamedResponse::sendContent #2 /vendor/symfony/http-foundation/Response.php(398): Symfony\Component\HttpFoundation\Response::send #1 /vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1172): Illuminate\Foundation\Application::handleRequest #0 /public/index.php(17): null
1) Create an assistant; 2) Create a thread; 3) Create a message in the thread and stream the response, like below:
OpenAI::threads()->messages()->create($chat->thread_id, [ 'role' => 'user', 'content' => 'analyze this file and provide an overview for me', 'file_ids' => {your_file_ids}, ]); $stream = OpenAI::threads()->runs()->createStreamed( threadId: {your_thread_id}, parameters: [ 'assistant_id' => {your_assistant_id}, ], ) foreach ($stream as $chunk) { // code }
v0.9.0
8.3.6
No response
Going to fix this with the next release from this PR https://github.com/openai-php/client/pull/405
Description
This bug started happening after #406.
When sending a message with a file and using streaming, it raises an exception with the following message: "Undefined array key "input".
Modifying the line 48 of the file
src/Responses/Threads/Runs/Steps/Delta/ThreadRunStepDeltaObject.php
to$attributes['input'] ?? ''
made it work.Stacktrace:
Steps To Reproduce
1) Create an assistant; 2) Create a thread; 3) Create a message in the thread and stream the response, like below:
OpenAI PHP Client Version
v0.9.0
PHP Version
8.3.6
Notes
No response