Repository navigation
Expand file tree
/
Copy pathconfig.go
More file actions
89 lines (74 loc) · 2.07 KB
/
Copy pathconfig.go
File metadata and controls
89 lines (74 loc) · 2.07 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package wise
import (
"io"
"github.com/rs/zerolog"
)
// DefaultSystemPrompt is the default system prompt for the agent.
const DefaultSystemPrompt = `You are an autonomous agent that executes bash commands to complete tasks.
RULES:
1. You can ONLY execute bash commands by wrapping them in a markdown code block with the 'bash' language tag
2. Execute ONE command at a time and wait for the output
3. Use the command output to inform your next action
4. When the task is complete, output "TASK_COMPLETE" followed by a summary on the next line
Example command format:
` + "```bash" + `
ls -la
` + "```" + `
Example completion:
` + "```bash" + `
echo "TASK_COMPLETE"
echo "Summary: Created hello.txt with the requested content"
` + "```"
// Config holds the agent configuration (optional settings only).
type Config struct {
parser Parser
logger *zerolog.Logger
output io.Writer
maxSteps int
contextLimit int
systemPrompt string
actionHandler ActionHandler
}
// NewConfig creates a new Config with sensible defaults.
func NewConfig() Config {
return Config{
maxSteps: 25,
systemPrompt: DefaultSystemPrompt,
output: io.Discard,
}
}
// WithParser sets a custom response parser.
func (c Config) WithParser(p Parser) Config {
c.parser = p
return c
}
// WithLogger sets the logger.
func (c Config) WithLogger(l *zerolog.Logger) Config {
c.logger = l
return c
}
// WithOutput sets the output writer for streaming results.
func (c Config) WithOutput(w io.Writer) Config {
c.output = w
return c
}
// WithMaxSteps sets the maximum number of agent steps.
func (c Config) WithMaxSteps(n int) Config {
c.maxSteps = n
return c
}
// WithContextLimit sets the context window size in tokens.
func (c Config) WithContextLimit(n int) Config {
c.contextLimit = n
return c
}
// WithSystemPrompt sets the system prompt.
func (c Config) WithSystemPrompt(p string) Config {
c.systemPrompt = p
return c
}
// WithActionHandler sets a custom action handler for extensibility.
func (c Config) WithActionHandler(h ActionHandler) Config {
c.actionHandler = h
return c
}