Feat: two agent types; WebAgentB impl

This commit is contained in:
Grail Finder
2025-12-19 11:06:22 +03:00
parent 5f852418d8
commit 67ea1aef0d
8 changed files with 101 additions and 185 deletions

34
agent/webagent.go Normal file
View File

@@ -0,0 +1,34 @@
package agent
import (
"fmt"
"log/slog"
)
// WebAgentB is a simple agent that applies formatting functions
type WebAgentB struct {
*AgentClient
sysprompt string
log slog.Logger
}
// NewWebAgentB creates a WebAgentB that uses the given formatting function
func NewWebAgentB(sysprompt string) *WebAgentB {
return &WebAgentB{sysprompt: sysprompt}
}
// Process applies the formatting function to raw output
func (a *WebAgentB) Process(args map[string]string, rawOutput []byte) []byte {
msg, err := a.FormMsg(a.sysprompt,
fmt.Sprintf("request:\n%+v\ntool response:\n%v", args, string(rawOutput)))
if err != nil {
a.log.Error("failed to process the request", "error", err)
return []byte("failed to process the request; err: " + err.Error())
}
resp, err := a.LLMRequest(msg)
if err != nil {
a.log.Error("failed to process the request", "error", err)
return []byte("failed to process the request; err: " + err.Error())
}
return resp
}