Skip to content

Comments

Implement "ai/" as the default namespace for model references#2

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-54849741-7494-44c2-87d8-9e64b35586fb
Draft

Implement "ai/" as the default namespace for model references#2
Copilot wants to merge 3 commits intomainfrom
copilot/fix-54849741-7494-44c2-87d8-9e64b35586fb

Conversation

Copy link

Copilot AI commented Sep 4, 2025

This PR implements the feature requested in docker#126 to make "ai/" the default namespace for model references, allowing users to run commands like docker model run gpt-oss without explicitly specifying the "ai/" prefix.

Changes Made

Added a smart namespace defaulting system that automatically prepends "ai/" to simple model names while preserving existing behavior for qualified references:

Core Implementation

  • Added addDefaultNamespace() function with intelligent logic to determine when to apply the default namespace
  • Updated 4 client methods to use the default namespace:
    • PullModel() - for pulling models from registry
    • GetModel() - for retrieving stored models
    • IsModelInStore() - for checking model existence
    • DeleteModel() - for removing models

Smart Logic

The namespace defaulting only applies to simple model names, preserving existing behavior for:

  • Models with existing namespaces: my-namespace/model → unchanged
  • Repository:tag references: some-repo:v1.0 → unchanged
  • Registry references: registry.com/namespace/model:tag → unchanged
  • SHA256 digests: sha256:abcd1234... → unchanged

Examples

# Simple model names get ai/ prefix automatically
docker model pull gpt-oss          # → ai/gpt-oss
docker model get llama2             # → ai/llama2

# Qualified references remain unchanged  
docker model pull ai/gpt-oss        # → ai/gpt-oss
docker model pull custom/model:v1   # → custom/model:v1
docker model pull repo.com/ns/model # → repo.com/ns/model

Testing

Added comprehensive test coverage including:

  • Unit tests for the namespace function logic with all edge cases
  • Integration tests demonstrating end-to-end functionality
  • Verification that existing behavior is preserved for all qualified reference types

This implementation follows the minimal-change principle and maintains backward compatibility while providing the convenience feature similar to how Ollama handles the "library/" namespace.

Closes docker#126


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 4, 2025 19:35
Co-authored-by: ericcurtin <1694275+ericcurtin@users.noreply.github.com>
Co-authored-by: ericcurtin <1694275+ericcurtin@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement as ekcasey described here: @docker/model-distribution/pull/126 Implement "ai/" as the default namespace for model references Sep 4, 2025
Copilot AI requested a review from ericcurtin September 4, 2025 19:38
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.

2 participants