mirror of https://github.com/ollama/ollama.git
model: tweak renderer for qwen3coder
This commit is contained in:
parent
c47154c08d
commit
abc6a300de
|
@ -291,7 +291,7 @@ func mapToTypeScriptType(jsonType string) string {
|
||||||
case "boolean":
|
case "boolean":
|
||||||
return "boolean"
|
return "boolean"
|
||||||
case "array":
|
case "array":
|
||||||
return "any[]"
|
return "array"
|
||||||
case "object":
|
case "object":
|
||||||
return "Record<string, any>"
|
return "Record<string, any>"
|
||||||
case "null":
|
case "null":
|
||||||
|
|
|
@ -90,7 +90,7 @@ func Qwen3CoderRenderer(messages []api.Message, tools []api.Tool, _ *api.ThinkVa
|
||||||
sb.WriteString("<function>\n")
|
sb.WriteString("<function>\n")
|
||||||
sb.WriteString("<name>" + tool.Function.Name + "</name>")
|
sb.WriteString("<name>" + tool.Function.Name + "</name>")
|
||||||
if tool.Function.Description != "" {
|
if tool.Function.Description != "" {
|
||||||
sb.WriteString("\n<description>" + tool.Function.Description + "</description>")
|
sb.WriteString("\n<description>" + strings.TrimSpace(tool.Function.Description) + "</description>")
|
||||||
}
|
}
|
||||||
sb.WriteString("\n<parameters>")
|
sb.WriteString("\n<parameters>")
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ func Qwen3CoderRenderer(messages []api.Message, tools []api.Tool, _ *api.ThinkVa
|
||||||
}
|
}
|
||||||
|
|
||||||
if prop.Description != "" {
|
if prop.Description != "" {
|
||||||
sb.WriteString("\n<description>" + prop.Description + "</description>")
|
sb.WriteString("\n<description>" + strings.TrimSpace(prop.Description) + "</description>")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render any additional keys not already handled
|
// Render any additional keys not already handled
|
||||||
|
@ -137,7 +137,7 @@ func Qwen3CoderRenderer(messages []api.Message, tools []api.Tool, _ *api.ThinkVa
|
||||||
|
|
||||||
for i, message := range filteredMessages {
|
for i, message := range filteredMessages {
|
||||||
lastMessage := i == len(filteredMessages)-1
|
lastMessage := i == len(filteredMessages)-1
|
||||||
prefill := lastMessage && message.Role == "assistant"
|
// prefill := lastMessage && message.Role == "assistant"
|
||||||
switch message.Role {
|
switch message.Role {
|
||||||
case "assistant":
|
case "assistant":
|
||||||
if len(message.ToolCalls) > 0 {
|
if len(message.ToolCalls) > 0 {
|
||||||
|
@ -146,7 +146,7 @@ func Qwen3CoderRenderer(messages []api.Message, tools []api.Tool, _ *api.ThinkVa
|
||||||
sb.WriteString(message.Content + "\n")
|
sb.WriteString(message.Content + "\n")
|
||||||
}
|
}
|
||||||
for _, toolCall := range message.ToolCalls {
|
for _, toolCall := range message.ToolCalls {
|
||||||
sb.WriteString("\n<tool_call>\n<function=" + toolCall.Function.Name + ">")
|
sb.WriteString("<tool_call>\n<function=" + toolCall.Function.Name + ">")
|
||||||
for name, value := range toolCall.Function.Arguments {
|
for name, value := range toolCall.Function.Arguments {
|
||||||
valueStr := formatToolCallArgument(value)
|
valueStr := formatToolCallArgument(value)
|
||||||
sb.WriteString("\n<parameter=" + name + ">\n" + valueStr + "\n</parameter>")
|
sb.WriteString("\n<parameter=" + name + ">\n" + valueStr + "\n</parameter>")
|
||||||
|
@ -157,9 +157,9 @@ func Qwen3CoderRenderer(messages []api.Message, tools []api.Tool, _ *api.ThinkVa
|
||||||
} else {
|
} else {
|
||||||
sb.WriteString(imStartTag + "assistant\n")
|
sb.WriteString(imStartTag + "assistant\n")
|
||||||
sb.WriteString(message.Content)
|
sb.WriteString(message.Content)
|
||||||
if !prefill {
|
// if !prefill {
|
||||||
sb.WriteString(imEndTag + "\n")
|
sb.WriteString(imEndTag + "\n")
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
case "tool":
|
case "tool":
|
||||||
// consecutive tool responses should share a single `<im_start>user`, but
|
// consecutive tool responses should share a single `<im_start>user`, but
|
||||||
|
@ -184,7 +184,7 @@ func Qwen3CoderRenderer(messages []api.Message, tools []api.Tool, _ *api.ThinkVa
|
||||||
sb.WriteString(imEndTag + "\n")
|
sb.WriteString(imEndTag + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
if lastMessage && !prefill {
|
if lastMessage {
|
||||||
sb.WriteString(imStartTag + "assistant\n")
|
sb.WriteString(imStartTag + "assistant\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue