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

Seems long response will be cut out #9

Closed devzhuchuanbo closed 1 year ago

devzhuchuanbo commented 1 year ago

Hi, thanks for your SDK, but I got a problem. For instance, I ask "I'm late for class, help me write a 200-word review", and the response was not analyzed correctly. It seems to be cut out, and only shows a small part in front. The "finish reason" for the response.Choices[0] is "length".

Snipaste_2023-02-02_10-29-41 Snipaste_2023-02-02_10-31-35
devzhuchuanbo commented 1 year ago

I find the reason. When creating the request, there is a "MaxToken" inside it, by default, it's value is 16. We just need to change it to what we want. like this: var request = new CreateCompletionRequest { Model = "text-davinci-003", Prompt = inputField.text, MaxTokens = 1000 //this is the max length }; image