You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get an error:
Fatal error: Uncaught TypeError: OpenAI\Responses\Files\RetrieveResponse::__construct(): Argument #3 ($bytes) must be of type int, null given, called in /my-project-path/vendor/openai-php/client/src/Responses/Files/RetrieveResponse.php on line 51 and defined in /my-project-path/vendor/openai-php/client/src/Responses/Files/RetrieveResponse.php on line 30
That is the loop to process the messages:
foreach ($messages->data as $message) {
if (!empty($message->content)) {
foreach ($message->content as $contentPart) {
if ($contentPart->type == "text") {
# skipping this to keep code small
} elseif ($contentPart->type == "image_file") {
$imageFileId = $contentPart->imageFile->fileId;
$imageFile = $client->files()->retrieve($imageFileId);
$imageData = $client->files()->download($imageFile);
print_r($imageData);
file_put_contents("image_$imageCounter.png", $imageData);
$imageCounter++;
}
}
}
}
It would be great if you could give me an hint what I'm doing wrong or fix the bug if it is one.
Thanks a lot in advance for your help.
Steps To Reproduce
create an assistant of type code_interpreter and send a request like
plot these numbers in a graph: 1,2,3,4,15,73,12
then try to read the messages and download the imageFile
OpenAI PHP Client Version
0.8.1
PHP Version
8.1.2
Notes
No response
The text was updated successfully, but these errors were encountered:
OK, I found the solution:
Your documenation said: `$client->files()->download($file);
So I retrieved the file info.
But now it works, when I use the fileId:
Description
Hello guys,
first of all: thanks for your great development.
So I as an PHP developer can use OpenAI API almost as convenient as with Python.
Now the problem:
If I go through all messages I can find a $contentPart->type of "image_file" .
If I try to get the image data like this:
I get an error:
Fatal error: Uncaught TypeError: OpenAI\Responses\Files\RetrieveResponse::__construct(): Argument #3 ($bytes) must be of type int, null given, called in /my-project-path/vendor/openai-php/client/src/Responses/Files/RetrieveResponse.php on line 51 and defined in /my-project-path/vendor/openai-php/client/src/Responses/Files/RetrieveResponse.php on line 30
That is the loop to process the messages:
It would be great if you could give me an hint what I'm doing wrong or fix the bug if it is one.
Thanks a lot in advance for your help.
Steps To Reproduce
create an assistant of type code_interpreter and send a request like
plot these numbers in a graph: 1,2,3,4,15,73,12
then try to read the messages and download the imageFile
OpenAI PHP Client Version
0.8.1
PHP Version
8.1.2
Notes
No response
The text was updated successfully, but these errors were encountered: