srcnalt / OpenAI-Unity

An unofficial OpenAI Unity Package that aims to help you use OpenAI API directly in Unity Game engine.
MIT License
672 stars 150 forks source link

CreateCompletionAsync sometime return an empty array #50

Open Morgan-6Freedom opened 1 year ago

Morgan-6Freedom commented 1 year ago

Hello.

I use CreateCompletionAsync to use the streaming mode while completing texts. However sometime the returned List is empty. Even if I try to resend the prompt.

image

Do you have an idea why ? Maybe I reached Rate Limit ? But there is no error.

srcnalt commented 1 year ago

Hi @Morgan-6Freedom, yes if you reached the rate limit then OpenAI would let you know with an error message. Could you drop a debug log into this line here to see if it is what OpenAI produces (in that case i cannot really do much) or a bug in the functionality?

Debug.Log(request.downloadHandler.text) into this line https://github.com/srcnalt/OpenAI-Unity/blob/fb8af0a6f6869081d8c4c2a6143d7152a2694d61/Runtime/OpenAIApi.cs#L116

srcnalt commented 1 year ago

Seems like Chat Completion receives results from OpenAI however Text Completion endpoint does not, I will have a look at it later in the evening.

Morgan-6Freedom commented 1 year ago

On what I have tested. Text Completion works for ~1min and then constantly sends me empty arrays. But work again later.

Morgan-6Freedom commented 1 year ago

This is what the debug log looks like :

Debug.LogError($"DispatchRequest {request.downloadHandler.text}");

image

This is what it should look like :

image