Giter Club home page Giter Club logo

Comments (2)

alek-s-andr avatar alek-s-andr commented on June 12, 2024

I created a PR with a fix for this issue: #363

from client.

BrainPackIO avatar BrainPackIO commented on June 12, 2024

Here is how you can create a completely new install that recreates this error. I have also included the fix

php -v

PHP 8.2.12 (cli) (built: Oct 24 2023 21:15:15) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies

composer require openai-php/client

composer dump-autoload    

nano index.php

Paste this:

<?php
require __DIR__ . '/vendor/autoload.php';

$client = OpenAI::client('insert-your-key-here');

$response = $client->fineTuning()->listJobs();
?>

php index.php

Error Response:

PHP Warning: Undefined array key "code" in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 35

Warning: Undefined array key "code" in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 35
PHP Warning: Undefined array key "param" in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 36

Warning: Undefined array key "param" in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 36
PHP Warning: Undefined array key "message" in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 37

Warning: Undefined array key "message" in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 37
PHP Fatal error: Uncaught TypeError: OpenAI\Responses\FineTuning\RetrieveJobResponseError::__construct(): Argument #1 ($code) must be of type string, null given, called in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 34 and defined in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php:20
Stack trace:
#0 vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php(34): OpenAI\Responses\FineTuning\RetrieveJobResponseError->__construct(NULL, NULL, NULL)
#1 vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponse.php(70): OpenAI\Responses\FineTuning\RetrieveJobResponseError::from(Array)
#2 vendor\openai-php\client\src\Responses\FineTuning\ListJobsResponse.php(45): OpenAI\Responses\FineTuning\RetrieveJobResponse::from(Array, Object(OpenAI\Responses\Meta\MetaInformation))
#3 [internal function]: OpenAI\Responses\FineTuning\ListJobsResponse::OpenAI\Responses\FineTuning{closure}(Array)
#4 vendor\openai-php\client\src\Responses\FineTuning\ListJobsResponse.php(45): array_map(Object(Closure), Array)
#5 vendor\openai-php\client\src\Resources\FineTuning.php(51): OpenAI\Responses\FineTuning\ListJobsResponse::from(Array, Object(OpenAI\Responses\Meta\MetaInformation))
#6 index.php(6): OpenAI\Resources\FineTuning->listJobs()
#7 {main}
thrown in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 20

Fatal error: Uncaught TypeError: OpenAI\Responses\FineTuning\RetrieveJobResponseError::__construct(): Argument #1 ($code) must be of type string, null given, called in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 34 and defined in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php:20
Stack trace:
#0 vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php(34): OpenAI\Responses\FineTuning\RetrieveJobResponseError->__construct(NULL, NULL, NULL)
#1 vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponse.php(70): OpenAI\Responses\FineTuning\RetrieveJobResponseError::from(Array)
#2 vendor\openai-php\client\src\Responses\FineTuning\ListJobsResponse.php(45): OpenAI\Responses\FineTuning\RetrieveJobResponse::from(Array, Object(OpenAI\Responses\Meta\MetaInformation))
#3 [internal function]: OpenAI\Responses\FineTuning\ListJobsResponse::OpenAI\Responses\FineTuning{closure}(Array)
#4 vendor\openai-php\client\src\Responses\FineTuning\ListJobsResponse.php(45): array_map(Object(Closure), Array)
#5 vendor\openai-php\client\src\Resources\FineTuning.php(51): OpenAI\Responses\FineTuning\ListJobsResponse::from(Array, Object(OpenAI\Responses\Meta\MetaInformation))
#6 index.php(6): OpenAI\Resources\FineTuning->listJobs()
#7 {main}
thrown in vendor\openai-php\client\src\Responses\FineTuning\RetrieveJobResponseError.php on line 20

Fix:

Inside file src\Responses\FineTuning\RetrieveJobResponseError.php

Change:

private function __construct(
    public readonly string $code,
    public readonly ?string $param,
    public readonly string $message,
) {
}

To:

private function __construct(
    public readonly ?string $code,
    public readonly ?string $param,
    public readonly ?string $message,
) {
}

Change:

return new self(
    $attributes['code'],
    $attributes['param'],
    $attributes['message'],
);

To:

return new self(
    $attributes['code'] ?? null,
    $attributes['param'] ?? null,
    $attributes['message'] ?? null,
);

from client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.