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

[OPIK-853] handle gemini client errors #1138

Merged
merged 3 commits into from
Feb 18, 2025

Conversation

idoberko2
Copy link
Contributor

@idoberko2 idoberko2 commented Jan 26, 2025

Details

Gemini client errors were not handled correctly. The purpose of this PR is fix the Gemini error handling method to respond with a human readable error.
Gemini API throws RuntimeExceptions with the error details as a JSON inside the message. This PR adds parsing to the error message in order to extract the meaningful part out of it.

Issues

OPIK-853

Testing

Tested locally:

❯ curl -v -X "POST" -H "Content-Type: application/json" --data '{"model":"gemini-1.5-flash","messages":[{"role":"user","content":"why are the sky blue?"}],"stream":true,"stream_options":{"include_usage":true},"temperature":0,"max_completion_tokens":1024,"top_p":1}' http://localhost:8080/v1/private/chat/completions

* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> POST /v1/private/chat/completions HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.7.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 200
>
* upload completely sent off: 200 bytes
< HTTP/1.1 200 OK
< Date: Sun, 26 Jan 2025 11:23:34 GMT
< Content-Type: text/event-stream
< Transfer-Encoding: chunked
<
{"code":429,"message":"Resource has been exhausted (e.g. check quota).","details":"RESOURCE_EXHAUSTED"}
* Connection #0 to host localhost left intact

@idoberko2 idoberko2 self-assigned this Jan 26, 2025
@idoberko2 idoberko2 requested a review from a team as a code owner January 26, 2025 11:32
thiagohora
thiagohora previously approved these changes Jan 26, 2025
Copy link
Contributor

@thiagohora thiagohora left a comment

Choose a reason for hiding this comment

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

Minor suggestion: It looks good!

Copy link
Contributor

@BorisTkachenko BorisTkachenko left a comment

Choose a reason for hiding this comment

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

Left a few comments

Copy link
Collaborator

@andrescrz andrescrz left a comment

Choose a reason for hiding this comment

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

Please address the important open comments.

@idoberko2 idoberko2 force-pushed the ido/opik-853-handle-gemini-client-errors branch from 99f55e0 to 60c8f15 Compare February 17, 2025 11:04
@idoberko2 idoberko2 merged commit fdc149b into main Feb 18, 2025
8 checks passed
@idoberko2 idoberko2 deleted the ido/opik-853-handle-gemini-client-errors branch February 18, 2025 09:36
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.

4 participants