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

feat(openai): handle error messages in chat completion streams #86

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

sd2k
Copy link
Contributor

@sd2k sd2k commented Sep 27, 2023

Once grafana/grafana-llm-app#75 is merged we'll need to be able to handle error messages in the streams returned by streamChatCompletions. This commit updates the types on the response stream and adds a new handleError operator which users can provide with a callback to handle an error if one occurs.

sd2k added a commit to grafana/grafana-llmexamples-app that referenced this pull request Sep 27, 2023
Demonstrates how to use grafana/grafana-experimental#86
to handle errors occurring in a stream.
@sd2k sd2k marked this pull request as ready for review September 27, 2023 14:05
src/llms/openai.ts Outdated Show resolved Hide resolved
@sd2k sd2k marked this pull request as draft September 27, 2023 15:21
sd2k added a commit to grafana/grafana-llmexamples-app that referenced this pull request Sep 27, 2023
Demonstrates how to use grafana/grafana-experimental#86
to handle errors occurring in a stream.
Once grafana/grafana-llm-app#75 is merged we'll
need to be able to handle error messages in the streams returned by
`streamChatCompletions`. This commit intercepts those errors and
re-throws them inside the Observable, so they can be handled using the
`error` property of `stream.subscribe`.
@sd2k sd2k marked this pull request as ready for review September 27, 2023 16:22
sd2k added a commit to grafana/grafana-llmexamples-app that referenced this pull request Sep 27, 2023
Demonstrates how to use grafana/grafana-experimental#86
to handle errors occurring in a stream.
sd2k added a commit to grafana/grafana-llmexamples-app that referenced this pull request Sep 27, 2023
Demonstrates how to use grafana/grafana-experimental#86
to handle errors occurring in a stream.
Copy link
Contributor

@SandersAaronD SandersAaronD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this for current dashgpt features and it works. Of sort of interest to note, when run directly in Grafana the linter doesn't like the use of "any" in this.

@sd2k
Copy link
Contributor Author

sd2k commented Sep 27, 2023

I don't really like the use of any either really, I'm not sure what type to use though 🤔

@sd2k sd2k merged commit ae226f7 into main Sep 27, 2023
1 check passed
@sd2k sd2k deleted the handle-errors-in-streams branch September 27, 2023 20:10
SandersAaronD pushed a commit to grafana/grafana-llm-app that referenced this pull request Oct 27, 2023
SandersAaronD pushed a commit to grafana/grafana-llm-app that referenced this pull request Oct 30, 2023
SandersAaronD pushed a commit to grafana/grafana-llm-app that referenced this pull request Oct 31, 2023
SandersAaronD pushed a commit that referenced this pull request Jan 10, 2024
feat(openai): handle error messages in chat completion streams
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

Successfully merging this pull request may close these issues.

3 participants