summaryrefslogtreecommitdiff
path: root/agent/webagent.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-12-19 11:06:22 +0300
committerGrail Finder <wohilas@gmail.com>2025-12-19 11:06:22 +0300
commit67ea1aef0dafb9dc6f82e009cc1ecc613f71e520 (patch)
tree331743d4edc223508e96055c0ec5753901273b57 /agent/webagent.go
parent5f852418d8d12868df83a9591b15e0846971fff9 (diff)
Feat: two agent types; WebAgentB impl
Diffstat (limited to 'agent/webagent.go')
-rw-r--r--agent/webagent.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/agent/webagent.go b/agent/webagent.go
new file mode 100644
index 0000000..0087e8e
--- /dev/null
+++ b/agent/webagent.go
@@ -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
+}