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
15af5584
"tests/test_arraymisc.py" did not exist on "7ccd8b0b74f3f862dc4e27895bdc454060a9ccb5"
Commit
15af5584
authored
Jun 19, 2024
by
Michael Yang
Browse files
include modelfile messages
parent
f5e39392
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
20 deletions
+19
-20
cmd/cmd.go
cmd/cmd.go
+0
-1
server/images.go
server/images.go
+1
-6
server/routes.go
server/routes.go
+18
-13
No files found.
cmd/cmd.go
View file @
15af5584
...
...
@@ -362,7 +362,6 @@ func RunHandler(cmd *cobra.Command, args []string) error {
opts
.
MultiModal
=
slices
.
Contains
(
info
.
Details
.
Families
,
"clip"
)
opts
.
ParentModel
=
info
.
Details
.
ParentModel
opts
.
Messages
=
append
(
opts
.
Messages
,
info
.
Messages
...
)
if
interactive
{
return
generateInteractive
(
cmd
,
opts
)
...
...
server/images.go
View file @
15af5584
...
...
@@ -70,7 +70,7 @@ type Model struct {
License
[]
string
Digest
string
Options
map
[
string
]
interface
{}
Messages
[]
Message
Messages
[]
api
.
Message
Template
*
template
.
Template
}
...
...
@@ -191,11 +191,6 @@ func (m *Model) String() string {
return
modelfile
.
String
()
}
type
Message
struct
{
Role
string
`json:"role"`
Content
string
`json:"content"`
}
type
ConfigV2
struct
{
ModelFormat
string
`json:"model_format"`
ModelFamily
string
`json:"model_family"`
...
...
server/routes.go
View file @
15af5584
...
...
@@ -164,17 +164,6 @@ func (s *Server) GenerateHandler(c *gin.Context) {
}
}
var
b
bytes
.
Buffer
if
req
.
Context
!=
nil
{
s
,
err
:=
r
.
Detokenize
(
c
.
Request
.
Context
(),
req
.
Context
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
b
.
WriteString
(
s
)
}
var
values
template
.
Values
if
req
.
Suffix
!=
""
{
values
.
Prompt
=
prompt
...
...
@@ -187,6 +176,10 @@ func (s *Server) GenerateHandler(c *gin.Context) {
msgs
=
append
(
msgs
,
api
.
Message
{
Role
:
"system"
,
Content
:
m
.
System
})
}
if
req
.
Context
==
nil
{
msgs
=
append
(
msgs
,
m
.
Messages
...
)
}
for
_
,
i
:=
range
images
{
msgs
=
append
(
msgs
,
api
.
Message
{
Role
:
"user"
,
Content
:
fmt
.
Sprintf
(
"[img-%d]"
,
i
.
ID
)})
}
...
...
@@ -194,11 +187,22 @@ func (s *Server) GenerateHandler(c *gin.Context) {
values
.
Messages
=
append
(
msgs
,
api
.
Message
{
Role
:
"user"
,
Content
:
req
.
Prompt
})
}
var
b
bytes
.
Buffer
if
err
:=
tmpl
.
Execute
(
&
b
,
values
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
if
req
.
Context
!=
nil
{
s
,
err
:=
r
.
Detokenize
(
c
.
Request
.
Context
(),
req
.
Context
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
b
.
WriteString
(
s
)
}
prompt
=
b
.
String
()
}
...
...
@@ -1323,11 +1327,12 @@ func (s *Server) ChatHandler(c *gin.Context) {
return
}
msgs
:=
append
(
m
.
Messages
,
req
.
Messages
...
)
if
req
.
Messages
[
0
]
.
Role
!=
"system"
&&
m
.
System
!=
""
{
req
.
Message
s
=
append
([]
api
.
Message
{{
Role
:
"system"
,
Content
:
m
.
System
}},
req
.
Message
s
...
)
msg
s
=
append
([]
api
.
Message
{{
Role
:
"system"
,
Content
:
m
.
System
}},
msg
s
...
)
}
prompt
,
images
,
err
:=
chatPrompt
(
c
.
Request
.
Context
(),
m
,
r
.
Tokenize
,
opts
,
req
.
Message
s
,
req
.
Tools
)
prompt
,
images
,
err
:=
chatPrompt
(
c
.
Request
.
Context
(),
m
,
r
.
Tokenize
,
opts
,
msg
s
,
req
.
Tools
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
...
...
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