Skip to content

Conversation

@ericcurtin
Copy link
Contributor

@ericcurtin ericcurtin commented Oct 15, 2025

Add normalization to configure, list, and unload commands

Summary by Sourcery

Introduce consistent model name normalization and display stripping across the CLI and manager, ensuring default organization and tag are applied or removed appropriately.

New Features:

  • Add normalizeModelName to prepend "ai/" and append ":latest" to model names when missing.
  • Add stripDefaultsFromModelName to remove default "ai/" prefix and ":latest" tag for user-facing display.

Enhancements:

  • Integrate normalization into configure, list, pull, push, inspect, remove, unload, run, tag, and ps CLI commands.
  • Replace normalizeHuggingFaceModelName with normalizeModelName in the desktop client and HTTP handlers.
  • Normalize model names in the manager’s create, get, delete, and OpenAI endpoints.
  • Strip default prefixes and tags in CLI list and ps outputs for cleaner display.

Tests:

  • Add unit tests covering normalizeModelName and stripDefaultsFromModelName for various naming scenarios.

Copilot AI review requested due to automatic review settings October 15, 2025 13:36
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 15, 2025

Reviewer's Guide

This PR implements a uniform model name normalization strategy by introducing normalizeModelName (and stripDefaultsFromModelName) to prepend the default "ai/" org and ":latest" tag when missing, refactors existing client and server code to use these helpers, updates all CLI commands to normalize user inputs and strip defaults for display, and adds comprehensive unit tests for both functions.

Sequence diagram for model name normalization in CLI commands

sequenceDiagram
actor User
participant CLI
participant "normalizeModelName()"
participant Backend
User->>CLI: Enter model name (e.g., "gemma3")
CLI->>"normalizeModelName()": Normalize model name
"normalizeModelName()"-->>CLI: Returns normalized name (e.g., "ai/gemma3:latest")
CLI->>Backend: Send normalized model name
Loading

Class diagram for model name normalization utilities

classDiagram
class Utils {
  +normalizeModelName(model string) string
  +stripDefaultsFromModelName(model string) string
}
Utils <.. CLI : uses
Utils <.. Backend : uses
Loading

File-Level Changes

Change Details Files
Introduce normalization and stripping utilities
  • Add defaultOrg and defaultTag constants
  • Implement normalizeModelName in CLI utils, desktop and manager packages
  • Implement stripDefaultsFromModelName for display
  • Ensure stripDefaults logic handles ai/ prefix and :latest tag cases
cmd/cli/commands/utils.go
cmd/cli/desktop/desktop.go
pkg/inference/models/manager.go
Refactor desktop client to use new normalization
  • Replace normalizeHuggingFaceModelName calls with normalizeModelName across Pull, Push, Inspect, ChatWithContext, Remove, Tag
  • Import and reference new default constants
cmd/cli/desktop/desktop.go
Normalize inputs and strip defaults in CLI commands
  • Normalize model arguments in configure, pull, push, run, tag, unload, rm, inspect commands
  • Normalize filter in list and adjust tag matching logic
  • Strip default org/tag in list display and ps table
cmd/cli/commands/configure.go
cmd/cli/commands/list.go
cmd/cli/commands/ps.go
cmd/cli/commands/pull.go
cmd/cli/commands/push.go
cmd/cli/commands/run.go
cmd/cli/commands/tag.go
cmd/cli/commands/unload.go
cmd/cli/commands/rm.go
cmd/cli/commands/inspect.go
Add unit tests for normalization logic
  • Create tests covering various model name forms for normalizeModelName
  • Create tests covering stripping behavior in stripDefaultsFromModelName
cmd/cli/commands/utils_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ericcurtin, 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 enhances the CLI's model management by introducing robust model name normalization and display stripping. The changes ensure that model names are consistently interpreted internally by automatically applying default prefixes and tags, while simultaneously improving the user experience by presenting cleaner, less verbose model names in command outputs. This standardization simplifies user input and maintains clarity in the system's model handling.

Highlights

  • Model Name Normalization: Introduced a normalizeModelName function that automatically adds a default organization prefix (e.g., ai/) and a default tag (e.g., :latest) to model names if they are not explicitly provided by the user. This ensures consistent internal representation of model identifiers across various commands.
  • Display Stripping for User Experience: Added a stripDefaultsFromModelName function to remove the default ai/ prefix and :latest tag when displaying model names in CLI output, such as in the list and ps commands. This provides a cleaner and more user-friendly presentation.
  • Widespread Application Across Commands: The new normalization logic has been integrated into key CLI commands including configure, inspect, list (for filtering), pull, push, rm, run, tag, and unload, ensuring that all model-related operations benefit from consistent name handling.
  • New Utility Functions and Constants: Defined defaultOrg and defaultTag constants and implemented the normalizeModelName and stripDefaultsFromModelName utility functions to encapsulate the logic for standardizing and simplifying model names.
  • Comprehensive Unit Testing: A new test file, utils_test.go, was added to provide thorough unit tests for both the normalizeModelName and stripDefaultsFromModelName functions, covering various input scenarios to ensure correctness.
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.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive model name normalization functionality to standardize how model names are handled across the CLI and API. The changes ensure that model names are consistently formatted with default organization prefix ("ai/") and tag (":latest") when missing, while preserving special cases like HuggingFace models and external registries.

Key changes:

  • Added normalizeModelName function that adds "ai/" prefix and ":latest" tag when missing
  • Added stripDefaultsFromModelName function to clean up display names by removing defaults
  • Applied normalization to all CLI commands (pull, push, run, configure, inspect, etc.) and API handlers

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/inference/models/manager.go Added normalization to API handlers for model operations
cmd/cli/desktop/desktop.go Updated client methods to use new normalization instead of HuggingFace-only normalization
cmd/cli/commands/utils.go Added core normalization and display stripping functions
cmd/cli/commands/utils_test.go Added comprehensive test coverage for normalization functions
cmd/cli/commands/*.go Applied normalization to all CLI commands that handle model names
cmd/cli/commands/list.go Updated filtering logic and added display name stripping
cmd/cli/commands/ps.go Added display name stripping for running models
Comments suppressed due to low confidence (1)

cmd/cli/commands/list.go:1

  • The slices import is removed but the package may still be needed elsewhere in the file. Ensure all uses of the slices package have been replaced with alternative implementations.
package commands

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ericcurtin
Copy link
Contributor Author

Backend and frontend changes to make "ai/" and ":latest" optional and defaults, we need both. Now it's just:

docker model run gemma

Copy link
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 model name normalization and display stripping, which is a valuable enhancement for user experience and consistency across the CLI. The changes are applied to numerous commands, which is great. However, I've identified a critical bug in the stripDefaultsFromModelName function that leads to incorrect model name displays. Additionally, the normalizeModelName function is duplicated across three packages with slight inconsistencies, which poses a maintainability risk. I've provided detailed feedback and suggestions to address these issues.

@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from 460a84a to fc07567 Compare October 15, 2025 20:49
Copilot AI review requested due to automatic review settings October 15, 2025 21:19
@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from fc07567 to c9c4844 Compare October 15, 2025 21:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from c9c4844 to 0bc6f3b Compare October 15, 2025 22:12
Copilot AI review requested due to automatic review settings October 15, 2025 22:17
@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from 0bc6f3b to 3fef10f Compare October 15, 2025 22:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from 3fef10f to 882db0e Compare October 15, 2025 22:18
Copilot AI review requested due to automatic review settings October 15, 2025 22:20
@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from 882db0e to 92acddb Compare October 15, 2025 22:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

cmd/cli/commands/list.go:3

  • The unused import "slices" should be removed since it's no longer needed after the filtering logic refactoring.
import (

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from 92acddb to e79a94b Compare October 15, 2025 22:22
Copilot AI review requested due to automatic review settings October 15, 2025 22:25
@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from e79a94b to 1e1f37d Compare October 15, 2025 22:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from 1e1f37d to 7c3e7c9 Compare October 15, 2025 22:27
Copilot AI review requested due to automatic review settings October 15, 2025 22:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Add normalization to configure, list, and unload commands

Signed-off-by: Eric Curtin <[email protected]>
@ericcurtin ericcurtin force-pushed the make-model-optional-in-tooling branch from dfff6ac to 9d0898e Compare October 15, 2025 22:29
// - "myorg/gemma3:latest" -> "myorg/gemma3"
// - "gemma3:latest" -> "gemma3"
// - "hf.co/bartowski/model:latest" -> "hf.co/bartowski/model"
func stripDefaultsFromModelName(model string) string {
Copy link

Choose a reason for hiding this comment

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

nit: Maybe this should be implemented in the model manager along with NormalizeModelName? Could be called ExtractModelBaseName().

Copy link
Contributor Author

@ericcurtin ericcurtin Oct 16, 2025

Choose a reason for hiding this comment

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

Good consideration, I thought of that at one point, might do it in a follow on PR. The reason it's not is one has wider use than the other. But I get your point they are similar, one does the opposite of the other.

I actually think it's a pity we didn't go lowercase for our dmr quantization sometimes, the :tag . We actually have code here that converts everything to lowercase for huggingface and it's generally what ollama does also.

Copy link

@p1-0tr p1-0tr left a comment

Choose a reason for hiding this comment

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

One small nit, but otherwise LGTM.

@ericcurtin ericcurtin merged commit 5435e65 into main Oct 16, 2025
9 checks passed
@ericcurtin ericcurtin deleted the make-model-optional-in-tooling branch October 16, 2025 10:07
doringeman added a commit that referenced this pull request Oct 17, 2025
…oling"

This reverts commit 5435e65, reversing
changes made to d528460.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants