Closed coreation closed 1 year ago
Hi @coreation
According to the official OpenAI docs this should always be an array: https://github.com/openai/openai-openapi/blob/master/openapi.yaml#L3281
Can you give as an example how to reproduce the issue?
Hi @gehrisandro , unfortunately I can't. This is only occurring in the proverbial 1-2% of bulk embed API calls. That's why I didn't include a code example, but the stack trace itself. I can provide the API call that I'm making, but it's just a straightforward bulk embed API call:
$this
->getApiClient()
->embeddings()
->create([
'model' => 'text-embedding-ada-002',
'input' => $texts, // $texts being an array of strings
]);
Most of the times, this works out without a hitch, sometimes though, I get the error mentioned in the original post.
I tried to reproduce the issue by hitting the API in an endless loop. But even after thousands of requests, I never ran into this issue.
Currently I think it would be bad practice to adjust the library based on an undocumented and probably unintended behaviour. What do you think?
Hm, could try sneaking in a null as a value in the array or an empty string? My code trims all of the texts, so a null value is highly unlikely to be the cause, but an empty string might be it.
If that's still ending up with nothing, you can close the issue and I'll just use my work-around, which is just embedding texts one by one.
I've already tried empty strings and null values, but both instantly return an API error:
"error": {
"message": "'$.input' is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference.",
"type": "invalid_request_error",
"param": null,
"code": null
}
Ok, then this can be closed as far as I'm concerned. :)
Hi there,
When I'm using the embeddings endpoint I sometimes get the following ErrorException - which cannot be caught:
It seems to me that OpenAI can provide a null response for one or more embeddings, but the DTOs that are made do no take this into account, making the entire request fail, without the possibility to catch the failure.
If I make a change to make the embedding nullable in the
CreateResponseEmbedding
constructor, would that be accepted or do you see a different / better approach?