Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
486a2c1d
Commit
486a2c1d
authored
May 08, 2024
by
Michael Yang
Browse files
types/model: fix tag case
parent
2a5302a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
types/model/name.go
types/model/name.go
+7
-5
types/model/name_test.go
types/model/name_test.go
+12
-2
No files found.
types/model/name.go
View file @
486a2c1d
...
@@ -290,12 +290,14 @@ func (n Name) Filepath() string {
...
@@ -290,12 +290,14 @@ func (n Name) Filepath() string {
if
!
n
.
IsFullyQualified
()
{
if
!
n
.
IsFullyQualified
()
{
panic
(
"illegal attempt to get filepath of invalid name"
)
panic
(
"illegal attempt to get filepath of invalid name"
)
}
}
return
strings
.
ToLower
(
filepath
.
Join
(
return
filepath
.
Join
(
n
.
Host
,
strings
.
ToLower
(
filepath
.
Join
(
n
.
Namespace
,
n
.
Host
,
n
.
Model
,
n
.
Namespace
,
n
.
Model
,
)),
n
.
Tag
,
n
.
Tag
,
)
)
)
}
}
// LogValue returns a slog.Value that represents the name as a string.
// LogValue returns a slog.Value that represents the name as a string.
...
...
types/model/name_test.go
View file @
486a2c1d
...
@@ -19,6 +19,16 @@ func TestParseNameParts(t *testing.T) {
...
@@ -19,6 +19,16 @@ func TestParseNameParts(t *testing.T) {
wantFilepath
string
wantFilepath
string
wantValidDigest
bool
wantValidDigest
bool
}{
}{
{
in
:
"registry.ollama.ai/library/dolphin-mistral:7b-v2.6-dpo-laser-q6_K"
,
want
:
Name
{
Host
:
"registry.ollama.ai"
,
Namespace
:
"library"
,
Model
:
"dolphin-mistral"
,
Tag
:
"7b-v2.6-dpo-laser-q6_K"
,
},
wantFilepath
:
filepath
.
Join
(
"registry.ollama.ai"
,
"library"
,
"dolphin-mistral"
,
"7b-v2.6-dpo-laser-q6_K"
),
},
{
{
in
:
"scheme://host:port/namespace/model:tag"
,
in
:
"scheme://host:port/namespace/model:tag"
,
want
:
Name
{
want
:
Name
{
...
@@ -266,9 +276,9 @@ func TestFilepathAllocs(t *testing.T) {
...
@@ -266,9 +276,9 @@ func TestFilepathAllocs(t *testing.T) {
allocs
:=
testing
.
AllocsPerRun
(
1000
,
func
()
{
allocs
:=
testing
.
AllocsPerRun
(
1000
,
func
()
{
n
.
Filepath
()
n
.
Filepath
()
})
})
allowedAllocs
:=
2.0
var
allowedAllocs
float64
=
3
if
runtime
.
GOOS
==
"windows"
{
if
runtime
.
GOOS
==
"windows"
{
allowedAllocs
=
4
allowedAllocs
=
5
}
}
if
allocs
>
allowedAllocs
{
if
allocs
>
allowedAllocs
{
t
.
Errorf
(
"allocs = %v; allowed %v"
,
allocs
,
allowedAllocs
)
t
.
Errorf
(
"allocs = %v; allowed %v"
,
allocs
,
allowedAllocs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment