summaryrefslogtreecommitdiff
path: root/agent/pw_agent.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-03-15 11:50:22 +0300
committerGrail Finder <wohilas@gmail.com>2026-03-15 11:50:22 +0300
commite47657533453270565caa5e94cfa59307d2a7970 (patch)
tree30fae510369e8d86c65f613302d08fc2221d10eb /agent/pw_agent.go
parent7e346b5e1971c21d24945c2f09c60b7463a619d1 (diff)
Chore: linter complaints
Diffstat (limited to 'agent/pw_agent.go')
-rw-r--r--agent/pw_agent.go9
1 files changed, 1 insertions, 8 deletions
diff --git a/agent/pw_agent.go b/agent/pw_agent.go
index 2807331..787d411 100644
--- a/agent/pw_agent.go
+++ b/agent/pw_agent.go
@@ -57,15 +57,12 @@ func (a *PWAgent) setToolCallOnLastMessage(resp []byte, toolCallID string) {
if toolCallID == "" {
return
}
-
var genericResp map[string]interface{}
if err := json.Unmarshal(resp, &genericResp); err != nil {
return
}
-
var name string
var args map[string]string
-
if choices, ok := genericResp["choices"].([]interface{}); ok && len(choices) > 0 {
if firstChoice, ok := choices[0].(map[string]interface{}); ok {
if message, ok := firstChoice["message"].(map[string]interface{}); ok {
@@ -74,19 +71,17 @@ func (a *PWAgent) setToolCallOnLastMessage(resp []byte, toolCallID string) {
if fn, ok := tc["function"].(map[string]interface{}); ok {
name, _ = fn["name"].(string)
argsStr, _ := fn["arguments"].(string)
- json.Unmarshal([]byte(argsStr), &args)
+ _ = json.Unmarshal([]byte(argsStr), &args)
}
}
}
}
}
}
-
if name == "" {
content, _ := genericResp["content"].(string)
name = extractToolNameFromText(content)
}
-
lastIdx := len(a.chatBody.Messages) - 1
if lastIdx >= 0 {
a.chatBody.Messages[lastIdx].ToolCallID = toolCallID
@@ -110,14 +105,12 @@ func extractToolNameFromText(text string) string {
jsStr = strings.TrimPrefix(jsStr, "__tool_call__")
jsStr = strings.TrimSuffix(jsStr, "__tool_call__")
jsStr = strings.TrimSpace(jsStr)
-
start := strings.Index(jsStr, "{")
end := strings.LastIndex(jsStr, "}")
if start == -1 || end == -1 || end <= start {
return ""
}
jsStr = jsStr[start : end+1]
-
var fc models.FuncCall
if err := json.Unmarshal([]byte(jsStr), &fc); err != nil {
return ""