openai-php / client

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

[Bug]: MistralAI- Undefined array key "type" #397

Closed doc- closed 5 months ago

doc- commented 5 months ago

Description

Hi,

I'm using this API implementation with both OpenAI models and MistralAI ones.

My implementation works perfectly with both, except for the tool_calls function which is the only thing that goes wrong with MistralAI models.

When calling a function with a compliant model (example: open-mixtral-8x22b), I get this error message:

Message: Undefined array key "type"

Filename: Chat/CreateResponseToolCall.php

Line Number: 23

It only happens when the model intends to use the tool. It's able to recognise its tools though, but as soon as it tries to use them, there is this error occuring.

Steps To Reproduce

Create a MistralAI account and get an API key.

Use this base URI: api.mistral.ai/v1

Make a chat resource with a tool and use it with a MistralAI compliant model (example: open-mixtral-8x22b).

OpenAI PHP Client Version

v0.8.5

PHP Version

8.3

Notes

No response

gehrisandro commented 5 months ago

@doc- Could you make a PR for that?

doc- commented 5 months ago

Sadly I did not find the way to fix it.

gehrisandro commented 5 months ago

Going to close this, as supporting the Mistral API is not a goal of this package.

If someone opens a PR to add support, I am happy to review.