Skip to content

Commit

Permalink
Add hf:// as an alias to huggingface://
Browse files Browse the repository at this point in the history
Also check start of string contains :// , by checking if start of
the string simply starts with things like "hf", "ollama", etc. we
are kinda polluting the namespace and not allowing models to start
with these terms.

Signed-off-by: Eric Curtin <[email protected]>
  • Loading branch information
ericcurtin committed Oct 17, 2024
1 parent 88884d8 commit 75364ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def login_parser(subparsers):
def login_cli(args):
transport = args.TRANSPORT
if transport != "":
transport = os.getenv("RAMALAMA_TRANSPORT")
transport = os.getenv("RAMALAMA_TRANSPORT") + "://"
model = New(str(transport))
return model.login(args)

Expand All @@ -211,7 +211,7 @@ def logout_parser(subparsers):
def logout_cli(args):
transport = args.TRANSPORT
if transport != "":
transport = os.getenv("RAMALAMA_TRANSPORT")
transport = os.getenv("RAMALAMA_TRANSPORT") + "://"
model = New(str(transport))
return model.logout(args)

Expand Down Expand Up @@ -679,11 +679,11 @@ def dry_run(args):


def New(model):
if model.startswith("huggingface"):
if model.startswith("huggingface://") or model.startswith("hf://"):
return Huggingface(model)
if model.startswith("ollama"):
if model.startswith("ollama://"):
return Ollama(model)
if model.startswith("oci") | model.startswith("docker"):
if model.startswith("oci://") or model.startswith("docker://"):
return OCI(model)

transport = os.getenv("RAMALAMA_TRANSPORT")
Expand Down
5 changes: 5 additions & 0 deletions test/system/050-pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ load helpers

# bats test_tags=distro-integration
@test "ramalama pull huggingface" {
run_ramalama pull hf://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf
run_ramalama list
is "$output" ".*afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k" "image was actually pulled locally"
run_ramalama rm hf://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf

run_ramalama pull huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf
run_ramalama list
is "$output" ".*afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k" "image was actually pulled locally"
Expand Down

0 comments on commit 75364ee

Please sign in to comment.