mirror of
https://github.com/ollama/ollama.git
synced 2025-12-05 18:46:22 -06:00
multiturn tests
This commit is contained in:
@@ -71,20 +71,17 @@ func (r *DeepSeekRenderer) Render(messages []api.Message, tools []api.Tool, thin
|
||||
sb.WriteString("<|tool▁calls▁end|><|end▁of▁sentence|>")
|
||||
} else {
|
||||
if isLastUser {
|
||||
sb.WriteString("<|Assistant|>")
|
||||
if enableThinking {
|
||||
sb.WriteString("<think>")
|
||||
} else {
|
||||
sb.WriteString("</think>")
|
||||
}
|
||||
sb.WriteString("<|Assistant|></think>")
|
||||
}
|
||||
isLastUser = false
|
||||
|
||||
content := message.Content
|
||||
|
||||
if isToolContext {
|
||||
sb.WriteString(content + "<|end▁of▁sentence|>")
|
||||
isToolContext = false
|
||||
} else {
|
||||
// Remove any existing </think> tags from content (matching Jinja behavior)
|
||||
if strings.Contains(content, "</think>") {
|
||||
parts := strings.SplitN(content, "</think>", 2)
|
||||
if len(parts) > 1 {
|
||||
|
||||
@@ -16,6 +16,45 @@ func TestDeepSeekRenderer(t *testing.T) {
|
||||
thinkValue *api.ThinkValue
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "debug multi-turn conversation",
|
||||
messages: []api.Message{
|
||||
{Role: "user", Content: "hey!"},
|
||||
{Role: "assistant", Content: "Hey there! 👋 How's it going?"},
|
||||
{Role: "user", Content: "how are you?"},
|
||||
},
|
||||
thinkValue: &api.ThinkValue{Value: true},
|
||||
expected: `<|begin▁of▁sentence|><|User|>hey!<|Assistant|></think>Hey there! 👋 How's it going?<|end▁of▁sentence|><|User|>how are you?<|Assistant|><think>`,
|
||||
},
|
||||
{
|
||||
name: "historical message with thinking field",
|
||||
messages: []api.Message{
|
||||
{Role: "user", Content: "hello"},
|
||||
{
|
||||
Role: "assistant",
|
||||
Thinking: "The user is greeting me, I should respond politely.",
|
||||
Content: "Hello! How can I help you today?",
|
||||
},
|
||||
{Role: "user", Content: "thanks"},
|
||||
},
|
||||
thinkValue: &api.ThinkValue{Value: false},
|
||||
expected: `<|begin▁of▁sentence|><|User|>hello<|Assistant|></think>Hello! How can I help you today?<|end▁of▁sentence|><|User|>thanks<|Assistant|></think>`,
|
||||
},
|
||||
{
|
||||
name: "conversation with thinking enabled",
|
||||
messages: []api.Message{
|
||||
{Role: "user", Content: "hey!"},
|
||||
{
|
||||
Role: "assistant",
|
||||
Content: `Hey there! 😊 How's your day going? What can I help you with today - whether it's answering
|
||||
questions, brainstorming ideas, or just having a chat?!`,
|
||||
},
|
||||
{Role: "user", Content: "chat"},
|
||||
},
|
||||
thinkValue: &api.ThinkValue{Value: true},
|
||||
expected: `<|begin▁of▁sentence|><|User|>hey!<|Assistant|></think>Hey there! 😊 How's your day going? What can I help you with today - whether it's answering
|
||||
questions, brainstorming ideas, or just having a chat?!<|end▁of▁sentence|><|User|>chat<|Assistant|><think>`,
|
||||
},
|
||||
{
|
||||
name: "basic user message",
|
||||
messages: []api.Message{
|
||||
@@ -280,6 +319,9 @@ Second instruction<|User|>Hello<|Assistant|></think>`,
|
||||
if err != nil {
|
||||
t.Fatalf("Render() error = %v", err)
|
||||
}
|
||||
if tt.name == "debug multi-turn conversation" {
|
||||
t.Logf("Actual rendered output: %q", rendered)
|
||||
}
|
||||
if diff := cmp.Diff(tt.expected, rendered); diff != "" {
|
||||
t.Errorf("Render() mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user