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
f7ee0123
Commit
f7ee0123
authored
Jul 13, 2024
by
jmorganca
Browse files
server: prepend system message in chat handler
parent
1ed0aa8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
server/routes.go
server/routes.go
+4
-0
No files found.
server/routes.go
View file @
f7ee0123
...
@@ -1181,6 +1181,10 @@ func (s *Server) ChatHandler(c *gin.Context) {
...
@@ -1181,6 +1181,10 @@ func (s *Server) ChatHandler(c *gin.Context) {
return
return
}
}
if
req
.
Messages
[
0
]
.
Role
!=
"system"
{
req
.
Messages
=
append
([]
api
.
Message
{{
Role
:
"system"
,
Content
:
m
.
System
}},
req
.
Messages
...
)
}
prompt
,
images
,
err
:=
chatPrompt
(
c
.
Request
.
Context
(),
m
,
r
.
Tokenize
,
opts
,
req
.
Messages
)
prompt
,
images
,
err
:=
chatPrompt
(
c
.
Request
.
Context
(),
m
,
r
.
Tokenize
,
opts
,
req
.
Messages
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
...
...
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