-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathoption.go
More file actions
112 lines (94 loc) · 2.23 KB
/
Copy pathoption.go
File metadata and controls
112 lines (94 loc) · 2.23 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package kimi
import (
"encoding/json"
)
type Option func(*option)
type option struct {
exec string
args []string
envs []string
tools []Tool
}
func WithExecutable(executable string) Option {
return func(opt *option) {
opt.exec = executable
}
}
func WithBaseURL(baseURL string) Option {
return func(opt *option) {
opt.envs = append(opt.envs, "KIMI_BASE_URL="+baseURL)
}
}
func WithAPIKey(apiKey string) Option {
return func(opt *option) {
opt.envs = append(opt.envs, "KIMI_API_KEY="+apiKey)
}
}
func WithConfig(config *Config) Option {
return func(opt *option) {
// SAFETY: we guaranteed that the config is valid to be marshalled to JSON
cfg, _ := json.Marshal(config)
opt.args = append(opt.args, "--config", string(cfg))
}
}
func WithConfigFile(file string) Option {
return func(opt *option) {
opt.args = append(opt.args, "--config-file", file)
}
}
func WithModel(model string) Option {
return func(opt *option) {
opt.args = append(opt.args, "--model", model)
}
}
func WithWorkDir(dir string) Option {
return func(opt *option) {
opt.args = append(opt.args, "--work-dir", dir)
}
}
func WithSession(session string) Option {
return func(opt *option) {
opt.args = append(opt.args, "--session", session)
}
}
func WithMCPConfigFile(file string) Option {
return func(opt *option) {
opt.args = append(opt.args, "--mcp-config-file", file)
}
}
func WithMCPConfig(config *MCPConfig) Option {
return func(opt *option) {
cfg, _ := json.Marshal(config)
opt.args = append(opt.args, "--mcp-config", string(cfg))
}
}
func WithAutoApprove() Option {
return func(opt *option) {
opt.args = append(opt.args, "--auto-approve")
}
}
func WithThinking(thinking bool) Option {
return func(opt *option) {
if thinking {
opt.args = append(opt.args, "--thinking")
} else {
opt.args = append(opt.args, "--no-thinking")
}
}
}
func WithSkillsDir(dir string) Option {
return func(opt *option) {
opt.args = append(opt.args, "--skills-dir", dir)
}
}
// WithArgs appends custom command line arguments.
func WithArgs(args ...string) Option {
return func(opt *option) {
opt.args = append(opt.args, args...)
}
}
func WithTools(tools ...Tool) Option {
return func(opt *option) {
opt.tools = append(opt.tools, tools...)
}
}