-
Notifications
You must be signed in to change notification settings - Fork 923
Support field labels
for GeminiModel
and GoogleModel
on Vertex AI
#1056
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
Support field labels
for GeminiModel
and GoogleModel
on Vertex AI
#1056
Conversation
Do other providers support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT: Not sure if this is ok, but I've created a new file for this test because:
- This test doesn't go in
tests/models/test_gemini.py
, as import ofgoogle.auth
might be unsuccessful, which would cause skipping the whole file.
@Kludex I don't think so, but I'm not 100% sure. From my experience, usually api-key-based providers use different api keys to track usage and spending. For example, with OpenAI you can create different projects and each project has its own key and that's how you track usage and spending across projects. |
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
I'll check this tomorrow. Sorry. |
no worries, take your time! |
…d-in-gemini-models
…d-in-gemini-models
labels
for Gemini modelslabels
for Gemini models on Vertex AI
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
@Kludex sorry to bother, do you think someone has time to check this soon? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I forgot to press "comment".
tests/models/test_gemini_vertexai.py
Outdated
# pyright: reportDeprecated=false | ||
# pyright: reportPrivateUsage=false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those shouldn't be necessary in the top of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed # pyright: reportDeprecated=false
I also removed # pyright: reportPrivateUsage=false
but then I manually built the mock response content. Just FYI, because in other testing modules it's not like that.
request_data['safety_settings'] = gemini_safety_settings | ||
|
||
if gemini_labels := model_settings.get('gemini_labels'): | ||
provider_name = self._provider.name if isinstance(self._provider, Provider) else self._provider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an error on Gemini if send this parameter? It would be cool to be provider-agnostic.
This is just a comment. I'm thinking...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we get a 400. Tested with Gemini-1.5-flash
(GLA) raises:
pydantic_ai.exceptions.ModelHTTPError: status_code: 400, model_name: gemini-1.5-flash
with body:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"labels\": Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"labels\": Cannot find field."
}
]
}
]
}
}
Could also just let the user deal with this and then no need to check the provider.
…d-in-gemini-models
…d-in-gemini-models
…d-in-gemini-models
We're redoing the Google provider at #1373, so related PRs are on hold until that lands. |
…d-in-gemini-models
…d-in-gemini-models
I'll check this in a bit. Ping me when pipeline is passing please. 👍 |
@DouweM or @Kludex If possible, I'd need some guidance here, please: I've implemented the labels for both However, with GLA they behave differently. If a user provides labels in the settings dict:
I'm thinking it'd be best if they both behaved the same way, so which would be the best approach in your opinion?
EDIT: managed to fix the tests |
@Kludex tests are passing now:) I've got a question #1056 (comment) |
labels
for Gemini models on Vertex AIlabels
for GeminiModel
and GoogleModel
on Vertex AI
…d-in-gemini-models
…d-in-gemini-models
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks amazing. Sorry for the long wait.
I think the difference in behavior is fine.
Gemini requests on Vertex AI support custom metadata labels. For example, one might use the labels to know which calls are coming from which projects and thus accurately keep track of billing.
See the Gemini API docs for more info.