Conversation
Summary of ChangesHello, 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 registration and refresh capabilities of the system. It transitions from a static, startup-only model catalog to a dynamic, periodically refreshed one. The core improvement lies in the introduction of a callback mechanism that allows the service to react to changes in model definitions by automatically re-registering clients. This ensures that the system's understanding of available models and client-specific states, like quota cooldowns, is always current and responsive to external updates. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a periodic model refresh mechanism and enhances model registration. The changes are well-structured, introducing a callback system for model updates and refactoring existing code to be more robust and maintainable. I've found a couple of areas with opportunities for minor refactoring to reduce code duplication and improve efficiency. Overall, this is a solid enhancement to the model registry functionality.
| seen := make(map[string]struct{}, len(existing)+len(incoming)) | ||
| merged := make([]string, 0, len(existing)+len(incoming)) | ||
| for _, provider := range existing { | ||
| name := strings.ToLower(strings.TrimSpace(provider)) | ||
| if name == "" { | ||
| continue | ||
| } | ||
| if _, ok := seen[name]; ok { | ||
| continue | ||
| } | ||
| seen[name] = struct{}{} | ||
| merged = append(merged, name) | ||
| } | ||
| for _, provider := range incoming { | ||
| name := strings.ToLower(strings.TrimSpace(provider)) | ||
| if name == "" { | ||
| continue | ||
| } | ||
| if _, ok := seen[name]; ok { | ||
| continue | ||
| } | ||
| seen[name] = struct{}{} | ||
| merged = append(merged, name) | ||
| } |
There was a problem hiding this comment.
The two for loops for processing existing and incoming provider lists are identical. This code can be simplified to reduce duplication and improve maintainability by combining the slices and iterating once.
seen := make(map[string]struct{}, len(existing)+len(incoming))
merged := make([]string, 0, len(existing)+len(incoming))
for _, provider := range append(existing, incoming...) {
name := strings.ToLower(strings.TrimSpace(provider))
if name == "" {
continue
}
if _, ok := seen[name]; !ok {
seen[name] = struct{}{}
merged = append(merged, name)
}
}| for _, item := range auths { | ||
| if item == nil || item.ID == "" { | ||
| continue | ||
| } | ||
| auth, ok := s.coreManager.GetByID(item.ID) | ||
| if !ok || auth == nil || auth.Disabled { | ||
| continue | ||
| } | ||
| provider := strings.ToLower(strings.TrimSpace(auth.Provider)) | ||
| if !providerSet[provider] { | ||
| continue | ||
| } | ||
| if s.refreshModelRegistrationForAuth(auth) { | ||
| refreshed++ | ||
| } | ||
| } |
There was a problem hiding this comment.
The call to s.coreManager.GetByID(item.ID) inside the loop is redundant. s.coreManager.List() already returns a slice of *coreauth.Auth objects (clones), so you can use the item from the loop directly instead of fetching it again by ID. This will improve performance by avoiding an unnecessary map lookup and lock acquisition.
for _, auth := range auths {
if auth == nil || auth.ID == "" || auth.Disabled {
continue
}
provider := strings.ToLower(strings.TrimSpace(auth.Provider))
if !providerSet[provider] {
continue
}
if s.refreshModelRegistrationForAuth(auth) {
refreshed++
}
}
No description provided.