openai-php / client

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

[Bug]: Expected type 'OpenAI\Contracts\TransporterContract'. Found 'OpenAI\Testing\ClientFake' #284

Closed jimmy-vee closed 6 months ago

jimmy-vee commented 7 months ago

Description

Hi, I am trying to use the newly added assistants and threads resources for the ClientFake, but I get this error on both.

Expected type 'OpenAI\Contracts\TransporterContract'. Found 'OpenAI\Testing\ClientFake'.intelephense(P1006)

image

Steps To Reproduce

$fakeResponses = [
        AssistantResponse::fake([
            'id' => 'asst_gxzBkD1wkKEloYqZ410pT5pad',
            'object' => 'assistant',
            'createdAt' => 1623936000,
            'name' => 'Math Tutor',
            'instructions' => 'Test Instructions',
            'model' => 'gpt-4',
            'description' => null,
            'tools' => [
                ['type' => 'code_interpreter']
            ],
            'fileIds' => [],
            'metadata' => []
        ])
    ];

    $client = new ClientFake($fakeResponses);

    $client->assistants()->create([
            "name" => 'Math Tutor',
            "instructions" =>  'Test Instructions',
            "tools" => [
                [
                    'type' => 'code_interpreter',
                ]
            ],
            "model" => 'gpt-4'
    ]);

OpenAI PHP Client Version

0.8.0

PHP Version

8.1.2

Notes

No response

gehrisandro commented 7 months ago

Bug is fixed, going to make a new release today.