@@ -21,14 +21,16 @@ import (
21
21
)
22
22
23
23
const (
24
- HuggingFacePrefix = "huggingface://"
25
- OCIPrefix = "oci://"
26
- OllamaPrefix = "ollama://"
27
- HTTPPrefix = "http://"
28
- HTTPSPrefix = "https://"
29
- GithubURI = "github:"
30
- GithubURI2 = "github://"
31
- LocalPrefix = "file://"
24
+ HuggingFacePrefix = "huggingface://"
25
+ HuggingFacePrefix1 = "hf://"
26
+ HuggingFacePrefix2 = "hf.co/"
27
+ OCIPrefix = "oci://"
28
+ OllamaPrefix = "ollama://"
29
+ HTTPPrefix = "http://"
30
+ HTTPSPrefix = "https://"
31
+ GithubURI = "github:"
32
+ GithubURI2 = "github://"
33
+ LocalPrefix = "file://"
32
34
)
33
35
34
36
type URI string
@@ -127,6 +129,8 @@ func (u URI) LooksLikeURL() bool {
127
129
return strings .HasPrefix (string (u ), HTTPPrefix ) ||
128
130
strings .HasPrefix (string (u ), HTTPSPrefix ) ||
129
131
strings .HasPrefix (string (u ), HuggingFacePrefix ) ||
132
+ strings .HasPrefix (string (u ), HuggingFacePrefix1 ) ||
133
+ strings .HasPrefix (string (u ), HuggingFacePrefix2 ) ||
130
134
strings .HasPrefix (string (u ), GithubURI ) ||
131
135
strings .HasPrefix (string (u ), OllamaPrefix ) ||
132
136
strings .HasPrefix (string (u ), OCIPrefix ) ||
@@ -170,8 +174,10 @@ func (s URI) ResolveURL() string {
170
174
projectPath := strings .Join (repoPath [2 :], "/" )
171
175
172
176
return fmt .Sprintf ("https://raw.githubusercontent.com/%s/%s/%s/%s" , org , project , branch , projectPath )
173
- case strings .HasPrefix (string (s ), HuggingFacePrefix ):
177
+ case strings .HasPrefix (string (s ), HuggingFacePrefix ) || strings . HasPrefix ( string ( s ), HuggingFacePrefix1 ) || strings . HasPrefix ( string ( s ), HuggingFacePrefix2 ) :
174
178
repository := strings .Replace (string (s ), HuggingFacePrefix , "" , 1 )
179
+ repository = strings .Replace (repository , HuggingFacePrefix1 , "" , 1 )
180
+ repository = strings .Replace (repository , HuggingFacePrefix2 , "" , 1 )
175
181
// convert repository to a full URL.
176
182
// e.g. TheBloke/Mixtral-8x7B-v0.1-GGUF/mixtral-8x7b-v0.1.Q2_K.gguf@main -> https://huggingface.co/TheBloke/Mixtral-8x7B-v0.1-GGUF/resolve/main/mixtral-8x7b-v0.1.Q2_K.gguf
177
183
owner := strings .Split (repository , "/" )[0 ]
0 commit comments