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 432 forks source link

Add a way to stop waiting for response and stop receiving response by StreamCompletionAsync (add CancelationToken parameter) #137

Open jeffdapaz opened 1 year ago

jeffdapaz commented 1 year ago

Hello,

First I would like to congratulate you for your work! This library encouraged me to create the Visual chatGPT Studio extension that uses this library to communicate with OpenAI.

About the issue, one of the users of my extension requested to add a way to stop waiting for the response and also to stop continuing to receive the response when the request is made via StreamCompletionAsync.

I tried to do this on my own but was unsuccessful. I also looked to see if somehow the library allowed this but I didn't find anything.

Is there already a way to do this through the library? If not, would it be possible to add this possibility?

I believe that this possibility from the library would be a great addition.

zeecorleone commented 1 year ago

@jeffdapaz , are you looking for something like CancellationToken, that you can use to stop streaming?

jeffdapaz commented 1 year ago

Hi @zeecorleone,

yes. If there be a way to call the requests and pass as parameter the CancellationToken, problably this will resolve my problem.

But it's seen that is not possible to use CancellationToken as I saw in this issue.

Will be great if there are this possibility.