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

fix: 4162 - Graceful Openrouter error handling #4200

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

louis-jan
Copy link
Contributor

Describe Your Changes

This PR aims to handle error messages returned by OpenRouter gracefully. Unlike others, it doesn’t return JSON but a stream message.

CleanShot 2024-12-03 at 15 59 57
CleanShot 2024-12-03 at 15 59 50

Fixes Issues

Changes made

The code changes remove certain debug logging statements and add error handling logic:

  1. OAIEngine.ts:

    • Removed debug statements that logged the inference URL, headers, and the inference error as a JSON string.
  2. sse.ts:

    • Added logic to handle errors received in the SSE data. If the parsed data contains an error, it triggers the error handling in the subscriber, marks the stream as complete, and exits early to prevent further processing.

These changes improve error handling and reduce unnecessary logging output.

@louis-jan louis-jan requested a review from a team December 3, 2024 09:02
@github-actions github-actions bot added the type: bug Something isn't working label Dec 3, 2024
Copy link
Contributor

github-actions bot commented Dec 3, 2024

Barecheck - Code coverage report

Total: 69.27%

Your code coverage diff: -0.05% ▾

Uncovered files and lines
FileLines
core/src/browser/extensions/engines/OAIEngine.ts59, 71, 108, 136-138, 166
core/src/browser/extensions/engines/helpers/sse.ts37-38, 74-75, 81-83, 87, 93, 100

@louis-jan louis-jan merged commit 57d31bc into dev Dec 3, 2024
11 checks passed
@louis-jan louis-jan deleted the fix/4162-graceful-openrouter-error-handling branch December 3, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants