blob: 8824ecbba4d687e374423ae16d51449504f37418 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package agent
// I see two types of agents possible:
// ones who do their own tools calls
// ones that works only with the output
// A: main chat -> agent (handles everything: tool + processing)
// B: main chat -> tool -> agent (process tool output)
// AgenterA gets a task "find out weather in london"
// proceeds to make tool calls on its own
type AgenterA interface {
ProcessTask(task string) []byte
}
// AgenterB defines an interface for processing tool outputs
type AgenterB interface {
// Process takes the original tool arguments and the raw output from the tool,
// and returns a cleaned/summarized version suitable for the main LLM context
Process(args map[string]string, rawOutput []byte) []byte
}
// registry holds mapping from tool names to agents
var RegistryB = make(map[string]AgenterB)
var RegistryA = make(map[AgenterA][]string)
// Register adds an agent for a specific tool name
// If an agent already exists for the tool, it will be replaced
func RegisterB(toolName string, a AgenterB) {
RegistryB[toolName] = a
}
func RegisterA(toolNames []string, a AgenterA) {
RegistryA[a] = toolNames
}
// Get returns the agent registered for the given tool name, or nil if none.
func Get(toolName string) AgenterB {
return RegistryB[toolName]
}
// Register is a convenience wrapper for RegisterB.
func Register(toolName string, a AgenterB) {
RegisterB(toolName, a)
}
|