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

Request: Add abort method on chat completion stream #35

Open
Deepakanandrao opened this issue Oct 9, 2024 · 0 comments
Open

Request: Add abort method on chat completion stream #35

Deepakanandrao opened this issue Oct 9, 2024 · 0 comments

Comments

@Deepakanandrao
Copy link

It would be nice to have a stream.abort() method for the chat completion API.

e.g.

start(){
  this.stream = await this.mistralClient.chat.stream({
    model: 'mistral-small-latest',
    messages: [
      {
        content: this.prompt,
        role: 'user',
      },
    ],
  });

  for await (const chunk of this.stream) {
    const streamText = chunk.data.choices[0].delta.content;
    this.response += streamText; 
  }
}


// Stops the stream manually when called
stop() {
  
  if (this.stream) {
    this.stream.abort();
  }
}
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

1 participant