Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

use strings.Builder

Michael Yang8acb233668dd
diff --git a/types/model/file.go b/types/model/file.go
index b4b7578f0..c614fd32c 100644
--- a/types/model/file.go
+++ b/types/model/file.go
@@ -29,24 +29,20 @@ type Command struct {
}
func (c Command) String() string {
- name := c.Name
- args := c.Args
-
+ var sb strings.Builder
switch c.Name {
case "model":
- name = "from"
- args = c.Args
+ fmt.Fprintf(&sb, "FROM %s", c.Args)
case "license", "template", "system", "adapter":
- args = quote(args)
+ fmt.Fprintf(&sb, "%s %s", strings.ToUpper(c.Name), quote(c.Args))
case "message":
role, message, _ := strings.Cut(c.Args, ": ")
- args = role + " " + quote(message)
+ fmt.Fprintf(&sb, "MESSAGE %s %s", role, quote(message))
default:
- name = "parameter"
- args = c.Name + " " + quote(c.Args)
+ fmt.Fprintf(&sb, "PARAMETER %s %s", c.Name, quote(c.Args))
}
- return fmt.Sprintf("%s %s", strings.ToUpper(name), args)
+ return sb.String()
}
type state int