Commit cf9efefd authored by YanzheL's avatar YanzheL
Browse files

fix(lint): satisfy errcheck for strings.Builder.WriteString calls

parent 4fb16030
......@@ -24,23 +24,23 @@ func deriveOpenAIContentSessionSeed(body []byte) string {
var b strings.Builder
if model := gjson.GetBytes(body, "model").String(); model != "" {
b.WriteString("model=")
b.WriteString(model)
_, _ = b.WriteString("model=")
_, _ = b.WriteString(model)
}
if tools := gjson.GetBytes(body, "tools"); tools.Exists() && tools.IsArray() && tools.Raw != "[]" {
b.WriteString("|tools=")
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(tools.Raw)))
_, _ = b.WriteString("|tools=")
_, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(tools.Raw)))
}
if funcs := gjson.GetBytes(body, "functions"); funcs.Exists() && funcs.IsArray() && funcs.Raw != "[]" {
b.WriteString("|functions=")
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(funcs.Raw)))
_, _ = b.WriteString("|functions=")
_, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(funcs.Raw)))
}
if instr := gjson.GetBytes(body, "instructions").String(); instr != "" {
b.WriteString("|instructions=")
b.WriteString(instr)
_, _ = b.WriteString("|instructions=")
_, _ = b.WriteString(instr)
}
firstUserCaptured := false
......@@ -51,15 +51,15 @@ func deriveOpenAIContentSessionSeed(body []byte) string {
role := msg.Get("role").String()
switch role {
case "system", "developer":
b.WriteString("|system=")
_, _ = b.WriteString("|system=")
if c := msg.Get("content"); c.Exists() {
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
_, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
}
case "user":
if !firstUserCaptured {
b.WriteString("|first_user=")
_, _ = b.WriteString("|first_user=")
if c := msg.Get("content"); c.Exists() {
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
_, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
}
firstUserCaptured = true
}
......@@ -68,30 +68,30 @@ func deriveOpenAIContentSessionSeed(body []byte) string {
})
} else if inp := gjson.GetBytes(body, "input"); inp.Exists() {
if inp.Type == gjson.String {
b.WriteString("|input=")
b.WriteString(inp.String())
_, _ = b.WriteString("|input=")
_, _ = b.WriteString(inp.String())
} else if inp.IsArray() {
inp.ForEach(func(_, item gjson.Result) bool {
role := item.Get("role").String()
switch role {
case "system", "developer":
b.WriteString("|system=")
_, _ = b.WriteString("|system=")
if c := item.Get("content"); c.Exists() {
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
_, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
}
case "user":
if !firstUserCaptured {
b.WriteString("|first_user=")
_, _ = b.WriteString("|first_user=")
if c := item.Get("content"); c.Exists() {
b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
_, _ = b.WriteString(normalizeCompatSeedJSON(json.RawMessage(c.Raw)))
}
firstUserCaptured = true
}
}
if !firstUserCaptured && item.Get("type").String() == "input_text" {
b.WriteString("|first_user=")
_, _ = b.WriteString("|first_user=")
if text := item.Get("text").String(); text != "" {
b.WriteString(text)
_, _ = b.WriteString(text)
}
firstUserCaptured = true
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment