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
998f1785
Commit
998f1785
authored
Nov 29, 2023
by
Michael Yang
Browse files
add modelfamilies
parent
2cb0fa7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
13 deletions
+46
-13
server/images.go
server/images.go
+46
-13
No files found.
server/images.go
View file @
998f1785
...
@@ -19,6 +19,8 @@ import (
...
@@ -19,6 +19,8 @@ import (
"strings"
"strings"
"text/template"
"text/template"
"golang.org/x/exp/slices"
"github.com/jmorganca/ollama/api"
"github.com/jmorganca/ollama/api"
"github.com/jmorganca/ollama/llm"
"github.com/jmorganca/ollama/llm"
"github.com/jmorganca/ollama/parser"
"github.com/jmorganca/ollama/parser"
...
@@ -131,17 +133,48 @@ type ManifestV2 struct {
...
@@ -131,17 +133,48 @@ type ManifestV2 struct {
}
}
type
ConfigV2
struct
{
type
ConfigV2
struct
{
ModelFormat
string
`json:"model_format"`
ModelFormat
string
`json:"model_format"`
ModelFamily
string
`json:"model_family"`
ModelFamily
string
`json:"model_family"`
ModelType
string
`json:"model_type"`
ModelFamilies
[]
string
`json:"model_families"`
FileType
string
`json:"file_type"`
ModelType
string
`json:"model_type"`
RootFS
RootFS
`json:"rootfs"`
FileType
string
`json:"file_type"`
RootFS
RootFS
`json:"rootfs"`
// required by spec
// required by spec
Architecture
string
`json:"architecture"`
Architecture
string
`json:"architecture"`
OS
string
`json:"os"`
OS
string
`json:"os"`
}
}
func
(
c
*
ConfigV2
)
SetModelFormat
(
format
string
)
{
if
c
.
ModelFormat
==
""
{
c
.
ModelFormat
=
format
}
}
func
(
c
*
ConfigV2
)
SetModelFamily
(
families
...
string
)
{
for
_
,
family
:=
range
families
{
if
c
.
ModelFamily
==
""
{
c
.
ModelFamily
=
family
}
if
!
slices
.
Contains
(
c
.
ModelFamilies
,
family
)
{
c
.
ModelFamilies
=
append
(
c
.
ModelFamilies
,
family
)
}
}
}
func
(
c
*
ConfigV2
)
SetModelType
(
modelType
string
)
{
if
c
.
ModelType
==
""
{
c
.
ModelType
=
modelType
}
}
func
(
c
*
ConfigV2
)
SetFileType
(
fileType
string
)
{
if
c
.
FileType
==
""
{
c
.
FileType
=
fileType
}
}
type
RootFS
struct
{
type
RootFS
struct
{
Type
string
`json:"type"`
Type
string
`json:"type"`
DiffIDs
[]
string
`json:"diff_ids"`
DiffIDs
[]
string
`json:"diff_ids"`
...
@@ -351,10 +384,10 @@ func CreateModel(ctx context.Context, name, modelFileDir string, commands []pars
...
@@ -351,10 +384,10 @@ func CreateModel(ctx context.Context, name, modelFileDir string, commands []pars
return
err
return
err
}
}
config
.
ModelFormat
=
fromConfig
.
ModelFormat
config
.
Set
ModelFormat
(
fromConfig
.
ModelFormat
)
config
.
ModelFamily
=
fromConfig
.
ModelFamily
config
.
Set
ModelFamily
(
append
(
fromConfig
.
ModelFamilies
,
fromConfig
.
ModelFamily
)
...
)
config
.
ModelType
=
fromConfig
.
ModelType
config
.
Set
ModelType
(
fromConfig
.
ModelType
)
config
.
FileType
=
fromConfig
.
FileType
config
.
Set
FileType
(
fromConfig
.
FileType
)
for
_
,
layer
:=
range
manifest
.
Layers
{
for
_
,
layer
:=
range
manifest
.
Layers
{
deleteMap
[
layer
.
Digest
]
=
struct
{}{}
deleteMap
[
layer
.
Digest
]
=
struct
{}{}
...
@@ -400,10 +433,10 @@ func CreateModel(ctx context.Context, name, modelFileDir string, commands []pars
...
@@ -400,10 +433,10 @@ func CreateModel(ctx context.Context, name, modelFileDir string, commands []pars
return
err
return
err
}
}
config
.
ModelFormat
=
ggml
.
Name
()
config
.
Set
ModelFormat
(
ggml
.
Name
()
)
config
.
ModelFamily
=
ggml
.
ModelFamily
()
config
.
Set
ModelFamily
(
ggml
.
ModelFamily
()
)
config
.
ModelType
=
ggml
.
ModelType
()
config
.
Set
ModelType
(
ggml
.
ModelType
()
)
config
.
FileType
=
ggml
.
FileType
()
config
.
Set
FileType
(
ggml
.
FileType
()
)
mediatype
:=
mediatype
mediatype
:=
mediatype
if
ggml
.
ModelFamily
()
==
"clip"
{
if
ggml
.
ModelFamily
()
==
"clip"
{
...
...
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