Skip to content

feat: Support Custom Metadata Labels on Vertex AI #8207

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

yu-iskw
Copy link

@yu-iskw yu-iskw commented May 20, 2025

Fixes # (issue) #8205

This is already supported in langchain-google. So, it would be great to support it in langchainjs as well.

https://github.com/langchain-ai/langchain-google/blob/24ce2fd6aecf7e06c4f524a60e0bb1671e6516c2/libs/vertexai/langchain_google_vertexai/chat_models.py#L1184-L1186

Copy link

vercel bot commented May 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview May 27, 2025 4:19am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) May 27, 2025 4:19am

@yu-iskw yu-iskw marked this pull request as ready for review May 21, 2025 00:27
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features labels May 21, 2025
@benjamincburns
Copy link
Collaborator

@afirstenberg any thoughts on this?

yu-iskw added 2 commits May 22, 2025 16:25
Signed-off-by: Yu Ishikawa <[email protected]>
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 22, 2025
@@ -1594,6 +1594,7 @@ export function getGeminiAPI(config?: GeminiAPIConfig): GoogleAIAPI {
const ret: GeminiRequest = {
contents,
generationConfig,
labels: parameters.labels,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is ok, but would like to see a test to confirm it doesn't show up if not specified.

@afirstenberg
Copy link
Contributor

afirstenberg commented May 22, 2025

Thanks for the PR! I hadn't seen this in the Vertex docs before, but it does look useful.

Overall, this looks good to me. One comment about making sure the labels aren't included if not set.

We should run a test to see if it works on AI Studio, tho it doesn't look it from the discovery doc. I don't think we need to explicitly handle that case, however.

I'd rather see the tests integrated into the current test suite (particularly in google-common:chat_models.test.ts using one of the mocked responses and google-vertex/chat_models.int.test.ts)

Signed-off-by: Yu Ishikawa <[email protected]>
@yu-iskw
Copy link
Author

yu-iskw commented May 27, 2025

@afirstenberg Thank you for the feedback. I have updated the code. Can you review it again please?

According to my research, the feature of custom metadata labels is currently supported only in Vertex AI. Gemini API doesn't have the feature at the moment. We can also implement the feature only in langchain-google-vertexai and langchain-google-vertexai-web. In that case, we need to implement the property in each. So, I implemented the property in langchain-google-common.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features google size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants