openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.56k stars 465 forks source link

[file_search]: Do we have to wait for the v2 API to get file_search? #388

Closed Damien514 closed 1 month ago

Damien514 commented 1 month ago

Description

When I test my assistant in the Playground, it gets my data from my files Vector Stores and can answer all of my questions related to people in my organization. When I ask the same question using my PHP script, it always says it has no info on this person. Does it means that "file_search" is not possible for the moment with the v1 API ?

I know, that's not a bug, more a question, sorry for that!

Steps To Reproduce

In my PHP:

  1. Create a thread $response = $client->threads()->create([]);
  2. Create a message
    $response = $client->threads()->messages()->create($threadId,
    [
        'role' => 'user',
        'content' => $obj
    ]
    );
  3. Run
    $response = $client->threads()->runs()->create(
    threadId: $threadId,
    parameters: [
        'assistant_id' => 'asst_xxxxxxxxxx',
    ],
    );
  4. Retrieve my run
    $response = $client->threads()->runs()->retrieve(
        threadId: $threadId,
        runId: $runId,
    );
  5. get the answer $response = $client->threads()->messages()->list($threadId, ['limit' => 1,]);

OpenAI PHP Client Version

v.0.8.5

PHP Version

8.1

Notes

Thanks!

GrayHoax commented 1 month ago

Did you try to create assistant with tools with 'type' => 'file_search'? I think vector store id defining in this method - https://platform.openai.com/docs/api-reference/assistants/createAssistant only fyi - https://platform.openai.com/docs/api-reference/vector-stores/object

knash94 commented 1 month ago

Hey @Damien514 ,

Since this SDK is only using V1 of the assistants API at the moment then you may need to attach the file to the assistant using the API rather than the OpenAI interface. Have you tried something along these lines?

$client->assistants()->modify('asst_xxxxxxxxxx', [
    'file_ids' => ['file-xxx']
]);
stephenr85 commented 1 month ago

Also interested. I am attaching files to the assistant for the time being, which works for the code interpreter, but the SDK throws an error trying to use "file_search" as a tool value in all contexts I've tried.

rkuhl commented 1 month ago

It seems to me that this is just a naming issue; file_search was previously named retrieval. Try retrieval when using v1 API

gehrisandro commented 1 month ago

Release for assistants v2 has arrived (beta). 🚀

https://github.com/openai-php/client/releases/tag/v0.10.0-beta.1