Skip to content
New issue

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

Undefined array key "file_ids"[Bug]: #389

Closed
nedikexpando opened this issue May 15, 2024 · 4 comments
Closed

Undefined array key "file_ids"[Bug]: #389

nedikexpando opened this issue May 15, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@nedikexpando
Copy link

Description

By calling threads->createAndRun() it throws an exception 'Undefined array key "file_ids"'
The same is when calling threads()->messages()->list()

Steps To Reproduce

try {
                $response = $this->client->threads()->createAndRun(
                    [
                        'assistant_id' => $this->getOpenAiAssistantId(),
                        'thread' => [
                            'messages' => [['role' => 'user', 'content' => $userText,],],
                        ],
                    ],
                );
             
                return $response->threadId;
            } catch (Exception $e) {
               dump($e);
            }

OpenAI PHP Client Version

v0.8.5

PHP Version

8.3

Notes

No response

@nedikexpando nedikexpando added the bug Something isn't working label May 15, 2024
@LMCom
Copy link

LMCom commented May 15, 2024

I assume you are using GPT-4o which also requires an assistant v2. That's a very recent change to which this repository is not yet adjusted.
Try an earlier GPT version with an assistant v1. It should work.

@prashantadevkota-bg
Copy link

prashantadevkota-bg commented May 17, 2024

If you want to see how the V2 API behaves, then you can use the below quick hack to support creating assistants, threads & messages. It will also allow you to read back the responses from the AI. It will even support using the latest Model, which is 'gpt-4o'.

All you need to do is apply the change in three files like shown in the image below. The error happens because the V2 response doesn't have a 'file_ids' array key in the attributes array (I haven't checked whether this is true for all use-cases, but the fix is generic enough that it can easily handle cases where the file_ids key is present), and we just assign an empty array if that is the case.

Please note that this is a hacky solution for people who are too impatient for this library to be fixed.

bug-fix-for-v2

@udgithub
Copy link

can you estimate when you will have adapted this cool PHP library to Open AI assistants API v2?

@gehrisandro
Copy link
Collaborator

I am currently working on the v2 implementation, but it is a lot to do.

Feel free to give it an extra boost github.com/sponsors/gehrisandro 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants