blob: 11e9014f65d4c65cafe678930bdfec09ad88a9c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package agent
import (
"fmt"
)
// WebAgentB is a simple agent that applies formatting functions
type WebAgentB struct {
*AgentClient
sysprompt string
}
// NewWebAgentB creates a WebAgentB that uses the given formatting function
func NewWebAgentB(client *AgentClient, sysprompt string) *WebAgentB {
return &WebAgentB{AgentClient: client, 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(
fmt.Sprintf("%s\n\nrequest:\n%+v\ntool response:\n%v", a.sysprompt, 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
}
|