Skip to content

[API][Misc] Add new model capabilities and update its determination logic#294

Merged
slin1237 merged 1 commit into
mainfrom
update-model-capabilities-determine-logic
Oct 17, 2025
Merged

[API][Misc] Add new model capabilities and update its determination logic#294
slin1237 merged 1 commit into
mainfrom
update-model-capabilities-determine-logic

Conversation

@beiguo218
Copy link
Copy Markdown
Collaborator

What type of PR is this?

/kind feature

What this PR does / why we need it:

  1. Added official capability names that align with industry standards (particularly HuggingFace):
  • EMBEDDING - For text embedding models
  • RERANK - For reranking models
  • TEXT_TO_TEXT - For general text generation/chat models
  • IMAGE_TEXT_TO_TEXT - For vision-language models

The legacy capabilities (TEXT_GENERATION, TEXT_SUMMARIZATION, TEXT_EMBEDDINGS, TEXT_RERANK, CHAT, VISION) are preserved for backward compatibility but marked for future deprecation.

  1. Refactored Capability Determination Logic
  • Removed unreachable code: The old logic had an if-else chain where the TEXT_GENERATION capability could never be reached due to the preceding conditions always matching first;
  • Migrated to use new capability names.
  1. Updated unit tests

Does this PR introduce a user-facing change?

Yes

Model capabilities are now reported using standardized names aligned with HuggingFace conventions. Models will now return capabilities such as TEXT_TO_TEXT (instead of CHAT), EMBEDDING (instead of TEXT_EMBEDDINGS), and IMAGE_TEXT_TO_TEXT (instead of VISION). The old capability names remain supported for backward compatibility but are considered legacy, and users can still pass old capability names in the model spec.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @beiguo218, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the model capability system by introducing a set of standardized, industry-aligned names for various model functionalities. It also overhauls the internal logic responsible for identifying these capabilities, ensuring that models are correctly categorized under the new scheme. While maintaining backward compatibility for existing deployments, this change aims to streamline future development and improve the clarity of model descriptions.

Highlights

  • New Model Capabilities: Introduced new, standardized model capability names: EMBEDDING, RERANK, TEXT_TO_TEXT, and IMAGE_TEXT_TO_TEXT, aligning with industry standards like HuggingFace.
  • Legacy Capability Management: Existing capabilities (TEXT_GENERATION, TEXT_SUMMARIZATION, TEXT_EMBEDDINGS, TEXT_RERANK, CHAT, VISION) are preserved for backward compatibility but are marked for future deprecation.
  • Refactored Capability Determination Logic: The logic for determining model capabilities from HuggingFace metadata has been refactored to use the new capability names and remove previously unreachable code paths, improving clarity and maintainability.
  • Updated Unit Tests: Unit tests have been updated to reflect the new model capability names and the revised determination logic, ensuring correctness of the changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@slin1237 slin1237 merged commit 63dd9a3 into main Oct 17, 2025
16 checks passed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new standardized model capabilities, aligning with industry standards. The capability determination logic has been refactored for correctness and clarity, removing unreachable code. The unit tests have been updated to reflect these changes. The changes are a good improvement. I have one suggestion to further improve the readability and efficiency of the capability determination logic.

Comment on lines 394 to +413
architecture := hfModel.GetArchitecture()
modelType := hfModel.GetModelType()

// Add vision capability if the model supports it
// For vision, only support image text capability right now
if hfModel.HasVision() {
capabilities = append(capabilities, string(v1beta1.ModelCapabilityVision))
} else if strings.Contains(strings.ToLower(architecture), "embedding") ||
return append(capabilities, string(v1beta1.ModelCapabilityImageTextToText))
}

// Check for text embedding capability
if strings.Contains(strings.ToLower(architecture), "embedding") ||
strings.Contains(strings.ToLower(architecture), "sentence") ||
strings.Contains(strings.ToLower(modelType), "bert") ||
// Special case for known embedding models
(strings.Contains(strings.ToLower(modelType), "mistral") &&
strings.Contains(strings.ToLower(architecture), "mistralmodel")) {
capabilities = append(capabilities, string(v1beta1.ModelCapabilityTextEmbeddings))
return capabilities
} else if !slices.Contains(capabilities, string(v1beta1.ModelCapabilityChat)) {
capabilities = append(capabilities, string(v1beta1.ModelCapabilityChat))
} else {
capabilities = append(capabilities, string(v1beta1.ModelCapabilityTextGeneration))
return append(capabilities, string(v1beta1.ModelCapabilityEmbedding))
}

return capabilities
// Default to text-to-text capability
return append(capabilities, string(v1beta1.ModelCapabilityTextToText))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve readability and avoid repeated calls to strings.ToLower, you can convert architecture and modelType to lowercase once at the beginning of the function.

Suggested change
architecture := hfModel.GetArchitecture()
modelType := hfModel.GetModelType()
// Add vision capability if the model supports it
// For vision, only support image text capability right now
if hfModel.HasVision() {
capabilities = append(capabilities, string(v1beta1.ModelCapabilityVision))
} else if strings.Contains(strings.ToLower(architecture), "embedding") ||
return append(capabilities, string(v1beta1.ModelCapabilityImageTextToText))
}
// Check for text embedding capability
if strings.Contains(strings.ToLower(architecture), "embedding") ||
strings.Contains(strings.ToLower(architecture), "sentence") ||
strings.Contains(strings.ToLower(modelType), "bert") ||
// Special case for known embedding models
(strings.Contains(strings.ToLower(modelType), "mistral") &&
strings.Contains(strings.ToLower(architecture), "mistralmodel")) {
capabilities = append(capabilities, string(v1beta1.ModelCapabilityTextEmbeddings))
return capabilities
} else if !slices.Contains(capabilities, string(v1beta1.ModelCapabilityChat)) {
capabilities = append(capabilities, string(v1beta1.ModelCapabilityChat))
} else {
capabilities = append(capabilities, string(v1beta1.ModelCapabilityTextGeneration))
return append(capabilities, string(v1beta1.ModelCapabilityEmbedding))
}
return capabilities
// Default to text-to-text capability
return append(capabilities, string(v1beta1.ModelCapabilityTextToText))
architecture := strings.ToLower(hfModel.GetArchitecture())
modelType := strings.ToLower(hfModel.GetModelType())
// For vision, only support image text capability right now
if hfModel.HasVision() {
return append(capabilities, string(v1beta1.ModelCapabilityImageTextToText))
}
// Check for text embedding capability
if strings.Contains(architecture, "embedding") ||
strings.Contains(architecture, "sentence") ||
strings.Contains(modelType, "bert") ||
// Special case for known embedding models
(strings.Contains(modelType, "mistral") &&
strings.Contains(architecture, "mistralmodel")) {
return append(capabilities, string(v1beta1.ModelCapabilityEmbedding))
}
// Default to text-to-text capability
return append(capabilities, string(v1beta1.ModelCapabilityTextToText))

@zhyncs zhyncs deleted the update-model-capabilities-determine-logic branch November 3, 2025 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants