Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat stream controller #324

Open
PsiKai opened this issue Sep 1, 2023 · 2 comments
Open

Chat stream controller #324

PsiKai opened this issue Sep 1, 2023 · 2 comments

Comments

@PsiKai
Copy link

PsiKai commented Sep 1, 2023

Is your feature request related to a problem? Please describe.

I am not seeing a way to signal to the stream that I want to abort, for the cases of when a response is getting too long, or is wrong and I want to start over.

In the node package for the OpenAI API, they expose a controller object which allows you to abort the stream midway through.

Describe the solution you'd like

I would like that calling the chat method on a client instance would return a stream controller so that I can abort the stream if need be. Perhaps this is already possible with how you built it, but I did not have success attempting to use it. If this is already possible, would you please update the readme with instructions?

Example usage:

@chat_stream = client.chat(parameters:)

...

@chat_stream.controller.abort

Additional context

Node.js implementation:

Screenshot 2023-09-01 at 2 39 20 PM

Thank you for providing and maintaining this Gem 🙏

@alexrudall
Copy link
Owner

This would be cool and a well used feature I think, definitely open to a PR on it

@coezbek
Copy link
Contributor

coezbek commented Dec 12, 2023

As per discussion in the past (#265), one way to abort is to raise an exception from the proc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants