openai-php / client

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

If I input 0.2+0.3 and the result is .5 instead of 0.5, the leading 0 is lost #104

Closed xiaojian520 closed 1 year ago

nunomaduro commented 1 year ago

That's is an API issue. Not an API Client issue.

xiaojian520 commented 1 year ago

That's is an API issue. Not an API Client issue. But when I directly request the OpenAI API, it returns 0.Did you do any processing on it?

nunomaduro commented 1 year ago

cc @gehrisandro

gehrisandro commented 1 year ago

@xiaojian520 I don't understand what's the issue here.

Could you provide steps to reproduce the issue?

xiaojian520 commented 1 year ago

@xiaojian520 I don't understand what's the issue here.

Could you provide steps to reproduce the issue?

When I enter 0.1+0.2 using your client to request a response, the leading 0 disappears and the result is returned as .3. image

However, when I directly request the openid interface by entering 0.1+0.2, the result obtained is 0.3.

gehrisandro commented 1 year ago

I was able to reproduce. This only happens when you are using the toArray() on the reponse:

$response->toArray()['choices'][0]['delta']

using the object works fine:

$response->choices[0]->delta

Going to release a fix for this as soon as possible.