-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolkit.go
53 lines (40 loc) · 1004 Bytes
/
toolkit.go
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
46
47
48
49
50
51
52
53
package llm
import (
"context"
)
////////////////////////////////////////////////////////////////////////////////
// TYPES
// ToolKit is a collection of tools
type ToolKit interface {
// Register a tool in the toolkit
Register(Tool) error
// Return all the tools
Tools(Agent) []Tool
// Run the tool calls in parallel and return the results
Run(context.Context, ...ToolCall) ([]ToolResult, error)
}
// Definition of a tool
type Tool interface {
// The name of the tool
Name() string
// The description of the tool
Description() string
// Run the tool with a deadline and return the result
Run(context.Context) (any, error)
}
// A call-out to a tool
type ToolCall interface {
// The tool name
Name() string
// The tool identifier
Id() string
// Decode the calling parameters
Decode(v any) error
}
// Results from calling tools
type ToolResult interface {
// The call associated with the result
Call() ToolCall
// The result, which can be encoded into json
Value() any
}