Replies: 1 comment
-
I found this was the way ti make it work: // Get the original filename and extension
$originalName = $file->getClientOriginalName();
// Create a unique temporary file with the original filename to preserve the extension
$tempPath = tempnam(sys_get_temp_dir(), 'openai_upload_');
$tempPathWithExt = $tempPath . '_' . $originalName;
// Copy the file content to the temporary file
copy($file->getRealPath(), $tempPathWithExt);
// Upload the file with the correct extension
$response = $this->client->files()->upload([
'purpose' => 'assistants',
'file' => fopen($tempPathWithExt, 'rb'),
]);
// Clean up the temporary files
if (file_exists($tempPath)) {
unlink($tempPath);
}
if (file_exists($tempPathWithExt)) {
unlink($tempPathWithExt);
} I don't know if there's a simpler way, but for me this is the only thing that worked. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I created a script using this https://github.com/hiddenhatpress/openai-assistants SDK but learned that it did not work with gpt-4o. So I switched to this SDK. I was able to get create an assistant just fine with openai-php/client however I'm struggling to figure out how to associate my text files to the specific assistant. Can anyone provide me with some sample code or explain how this should work?
Beta Was this translation helpful? Give feedback.
All reactions