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
orangecat
ollama
Commits
20090f31
"examples/cpp/llama/start_ids.csv" did not exist on "720fc533da804ac3f46ee938864403e51fcd9fa7"
Unverified
Commit
20090f31
authored
Jul 19, 2024
by
Jeffrey Morgan
Committed by
GitHub
Jul 19, 2024
Browse files
preserve last assistant message (#5802)
parent
69a2d4cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
template/template.go
template/template.go
+2
-1
template/template_test.go
template/template_test.go
+20
-0
No files found.
template/template.go
View file @
20090f31
...
...
@@ -264,6 +264,7 @@ func (t *Template) Execute(w io.Writer, v Values) error {
nodes
:=
deleteNode
(
t
.
Template
.
Root
.
Copy
(),
func
(
n
parse
.
Node
)
bool
{
if
field
,
ok
:=
n
.
(
*
parse
.
FieldNode
);
ok
&&
slices
.
Contains
(
field
.
Ident
,
"Response"
)
{
cut
=
true
return
false
}
return
cut
...
...
@@ -273,7 +274,7 @@ func (t *Template) Execute(w io.Writer, v Values) error {
if
err
:=
template
.
Must
(
template
.
New
(
""
)
.
AddParseTree
(
""
,
&
tree
))
.
Execute
(
&
b
,
map
[
string
]
any
{
"System"
:
system
,
"Prompt"
:
prompt
,
"Response"
:
""
,
"Response"
:
response
,
});
err
!=
nil
{
return
err
}
...
...
template/template_test.go
View file @
20090f31
...
...
@@ -260,6 +260,26 @@ func TestExecuteWithMessages(t *testing.T) {
Hello friend![/INST] Hello human![INST] What is your name?[/INST] `
,
},
{
"mistral assistant"
,
[]
template
{
{
"no response"
,
`[INST] {{ .Prompt }}[/INST] `
},
{
"response"
,
`[INST] {{ .Prompt }}[/INST] {{ .Response }}`
},
{
"messages"
,
`
{{- range $i, $m := .Messages }}
{{- if eq .Role "user" }}[INST] {{ .Content }}[/INST] {{ else if eq .Role "assistant" }}{{ .Content }}{{ end }}
{{- end }}`
},
},
Values
{
Messages
:
[]
api
.
Message
{
{
Role
:
"user"
,
Content
:
"Hello friend!"
},
{
Role
:
"assistant"
,
Content
:
"Hello human!"
},
{
Role
:
"user"
,
Content
:
"What is your name?"
},
{
Role
:
"assistant"
,
Content
:
"My name is Ollama and I"
},
},
},
`[INST] Hello friend![/INST] Hello human![INST] What is your name?[/INST] My name is Ollama and I`
,
},
{
"chatml"
,
[]
template
{
...
...
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