-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add support for Gemini Vertex #248
Comments
Gemini API has two implementations:
See differences here The PoC is related to Vertex. |
@sashirestela I discovered in my experiments with Gemini that sometimes it returns an invalid chatCompletion response where the content field is an array of strings instead of being just a string or null as specified here: https://platform.openai.com/docs/api-reference/chat/create. This is a bug of Gemini and I'll see if I can reach out to them and get it fixed, but on the simple-openai/cleverclient side I think we can handle this by adding a response interceptor (similar to the request interceptor). Then, if a response needs to be massaged a little bit to comply with the OpenAI API then it can be done there and the core of simple-openai doesn't need to change to handle incompatible providers. I noticed it only for tool calls so far (other chat competions return a single string correctly). In this case the array can be merged into a single string. |
I reported the bug here: |
@the-gigi I can't see your bug report, I just can see the documentation and a warning saying that the support to OpenAI is still in beta. |
@sashirestela I used the "send feedback" form on the page. It is not visible there. I may add it to the developer forum too. Yes, the API is in beta, but I think it's useful to support it in simple-openai even if some aspects are not implemented yet or broken as in this case. My suggestion for adding a response interceptor will allow fixing these category of problems for any provider. |
@sashirestela I reported it in the developer forum too with a simple curl reproducer |
@sashirestela what are your thoughts on adding response interceptor? also, should it be a separate issue? the need emerges from the Gemini Vertex OpenAI compatibility later, but it's a general-purpose feature that can be useful for other providers (or even OpenAI itself if you want to have a hook perform some global check or modification to all responses) |
I think you could add a feature request in cleverclient for that. NEW ADDITION: |
Have you checked if some request parameters can avoid that non-standard content? If it happens with tools, it means that support for functions is invalid and we cannot deliver it in that state. |
Just in case, have you checked if the other implementation, Gemini Google AI, has the same issue? |
@sashirestela Function calling works for some requests. It doesn't work for the particular request that I reported on (which happens to be part of our integration tests). The open AI compatibility layer of Gemini API seems to be very buggy at the moment. I see multiple new bugs reported constantly in the developer forum. I didn't play with request parameters as this is a straight forward bug that violates the documented format of the response's message content. If you don't want to add it to simple-openai in such state then let's wait. We're not going to use it anyway until it's more stable. Anyway, with the new approach for providers we can add it ourselves from the outside (this is how I'm running out integration tests against Gemini). re: Gemini Vertex AI vs Gemini Google AI. I didn't try it. |
@the-gigi I think it's not a question of wanting to, it would be a bit irresponsible to deliver it in its current state with errors. Let's put it on hold while it matures |
@sashirestela sure. that makes sense. I'll keep my fork around and monitor the progress on Gemini API compatibility layer. I assume there is no point in opening a PR at this point. |
Yeah, no PR for now, please. |
@the-gigi Are you working on this feature or do you need more time for researching? |
Gemini vis simple-openai works in our codebase. I need to find time to get back to the POC and update it to the latest changes in simple-openai including the response interceptor. |
@sashirestela I updated my POC to the latest 3.18.0 version and added the response interceptor to address their bug. I opened a PR here: #291 |
@sashirestela I addressed your review comments on #291. I have one open question about the google-auth-library-oauth2-http that you mentioned not everyone needs. |
See full discussion here:
#221
Here is the POC of Gemini in a simple-openai fork:
the-gigi@40fe114
The text was updated successfully, but these errors were encountered: