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
Uri parameter cannot be overridden when sending via rest transport #319
Comments
Okay, it's python so there's always a workaround. Let's see what we can do. First off, everything in
The interceptor class doesn't help because it doesn't even get access to the URI. The URI is in http_options, which is not passes in. Metadata is extra headers for the request, and We either need to edit the protos generate a version of the library, or find some other way to patch in. Regenerating from protosOne nice effect of this approach is that you can generate the clients for other languages too. The lines in the protos that set the rest uri are these ones: From that directory the command to generate the library is:
That generates a .tar.gz file that you can pip install. You may want to adjust it's version number. PatchingI'm not sure what the best approach is here. I normally work above the I'd start by forking Where does It's not clear that the one in init does anything. So once you have the replacement version of
|
But I'm not sure I caught the question about API keys. |
Hello Marc, Other than the suffix, i.e. the inference method in the uri: "generateContent" |
Description of the bug:
We want to override the standard google uri part of the model endpoint.
Although some parameters e.g., api endpoint (host) can be overridden the uri parameter is hard coded.
Context:
we have our own AI hub where we count tokens for a set of models before forwarding the request to the model hosted by Google/ Azure-OpenAI, etc.
E.g., in case of OpenAI we can override the parameters like endpoint and api_key.
But this is not the case for the Google generative SDK.
Steps to reproduce
Created subclass for GenerativeModel
Instantiated a GenerativeServiceClient for sending requests to Gemini 1.0 model
Call generate_content with the intent to replace api endpoint, model uri, and api key
Code Example
Actual vs expected behavior:
However, in
venv/lib/python3.9/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/transports/rest.py:810
uri seems to be hard coded, whereas host can be overridden.
We want to override with this uri: "models/gemini-1.0-pro:generateContent" (i.e. remove "/v1beta/" prefix)
Also a interceptor did not help as request is immutable:
Plz provide an option to override the uri or let us know if there is another way.
Thanks!
Any other information you'd like to share?
Environment details
OS type and version: Mac OS latest
Python version: 3.9
pip version: 24.0
google-cloud-aiplatform version: Version: 1.47.0
The text was updated successfully, but these errors were encountered: