OkGoDoIt / OpenAI-API-dotnet

An unofficial C#/.NET SDK for accessing the OpenAI GPT-3 API
https://www.nuget.org/packages/OpenAI/
Other
1.86k stars 433 forks source link

StreamResponseEnumerableFromChatbotAsync (and StreamResponseFromChatbotAsync) call endpoint twice #184

Closed crazybmanp closed 11 months ago

crazybmanp commented 11 months ago

Following the example code on the readme leads to two calls of the completion endpoint when you run the async stream methods. It only seems to get one token back before starting a new generation and sending the chat request again.

This is unfortunately breaking a third party endpoint i use, however i have verified the problem against the official API using the usage screen on OpenAI.

OkGoDoIt commented 11 months ago

Hmm, are you referring to the chat endpoint or the completion endpoint? I modified some of the logic in the chat endpoint to support auto-retry when the context length is too long (which maybe has a bug?), but I haven't touched the logic for the completion endpoint in a very long time. What code specifically are you running?

crazybmanp commented 11 months ago

Sorry for not specifying; this is for the chat endpoint.

OkGoDoIt commented 11 months ago

Good catch. My retry logic for streaming chats had a bug. I've fixed it in in v1.9.