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

[Bug]: Azure Asynchronous Filter #407

Closed
beliven-daniele-sarnari opened this issue May 26, 2024 · 4 comments
Closed

[Bug]: Azure Asynchronous Filter #407

beliven-daniele-sarnari opened this issue May 26, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@beliven-daniele-sarnari
Copy link
Contributor

Description

Enabling Asynchronous Filter will cause a Undefined array key "delta" error

ErrorException

  Undefined array key "delta"

  at vendor/openai-php/client/src/Responses/Chat/CreateStreamedResponseChoice.php:23
     19▕     public static function from(array $attributes): self
     20▕     {
     21▕         return new self(
     22▕             $attributes['index'],
  ➜  23▕             CreateStreamedResponseDelta::from($attributes['delta']),
     24▕             $attributes['finish_reason'] ?? null,
     25▕         );
     26▕     }
     27▕

      +2 vendor frames

  3   [internal]:0
      OpenAI\Responses\Chat\CreateStreamedResponse::OpenAI\Responses\Chat\{closure}()
      +2 vendor frames

Steps To Reproduce

  1. Enable Asynchronous Filter on Azure OpenAI Studio
    image

  2. Create a OpenAI client that works with Azure

$this->clientGPT4 = OpenAI::factory()
            ->withBaseUri("{$endpoint}/openai/deployments/{$deploymentIdGPT4}")
            ->withHttpHeader('api-key', $apiKey)
            ->withQueryParam('api-version', $apiVersion)
            ->make();
  1. Use the chat()->createStreamed() function
return $this->clientGPT4->chat()->createStreamed([
            'messages' => $messages,
        ]);

OpenAI PHP Client Version

v0.9.1

PHP Version

8.3.6

Notes

No response

@beliven-daniele-sarnari beliven-daniele-sarnari added the bug Something isn't working label May 26, 2024
@gehrisandro
Copy link
Collaborator

Hi @beliven-daniele-sarnari

Thank you for the issue and PR.

The Azure API and the default OpenAI API are becoming increasingly divergent. Not sure if it is the right way to modify this package more and more, because this will make the response objects harder to use in context of the original OpenAI and still not fully support OpenAI on Azure.

We will have to discuss how to proceed here.

@gehrisandro gehrisandro added enhancement New feature or request and removed bug Something isn't working labels May 27, 2024
@beliven-daniele-sarnari
Copy link
Contributor Author

beliven-daniele-sarnari commented May 28, 2024

Hi @beliven-daniele-sarnari

Thank you for the issue and PR.

The Azure API and the default OpenAI API are becoming increasingly divergent. Not sure if it is the right way to modify this package more and more, because this will make the response objects harder to use in context of the original OpenAI and still not fully support OpenAI on Azure.

We will have to discuss how to proceed here.

Hello @gehrisandro, i fully agree with you.
Imho a dedicated repository would be the right choice, but that would mean that two repositories needs to be updated and this generates further work on your side.
What do you think is the best solution? Maybe a dedicated namespace inside this repository?

Meanwhile, can we merge the pull request so we can continue working? I would like to avoid forking two repositories (we use Laravel) just for one line of code :/

@gehrisandro
Copy link
Collaborator

I have merged your PR, as it affects the direct OpenAI users, not really. I will make a new release the next days.

But still, I think having a dedicated package would be the best choice. Having two different packages is of course a maintenance burden, but I can't think of a good way to have both in a single package.

Atm, I don't have time to create (and test) a full Azure implementation, but I will keep this in mind, for later.
If you are interested in helping me out, I would love to hear from you 🙏🏼

@berott
Copy link

berott commented Jun 2, 2024

Thank you for this PR and the merge!

@gehrisandro I'm looking forward to the release :-) Is there a possibility to help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants