introduced .bantam.cfg in addition to model.cfg
This commit is contained in:
@@ -244,6 +244,15 @@ func setCfg(path, key, val string) error {
|
||||
return os.WriteFile(path, []byte(strings.Join(lines, "\n")), 0644)
|
||||
}
|
||||
|
||||
// configPath returns the configuration file to load: .bantam.cfg takes
|
||||
// priority over model.cfg when both exist in the current working directory,
|
||||
// falling back to model.cfg (which may be absent, triggering defaults).
|
||||
func configPath() string {
|
||||
if _, err := os.Stat(".bantam.cfg"); err == nil {
|
||||
return ".bantam.cfg"
|
||||
}
|
||||
return "model.cfg"
|
||||
}
|
||||
const defaultSystemPrompt = `You are Bantam, a tiny, powerful AI agent. Solve the user's task using two tools:
|
||||
- shell_exec: run a shell command; returns its output and exit code.
|
||||
- run_subagent: delegate a sub-task to a child agent; returns its reply.
|
||||
@@ -1586,7 +1595,7 @@ func doCompact(cfg *Cfg, msgs []Message) []Message {
|
||||
|
||||
func main() {
|
||||
sp := prompt("system.txt")
|
||||
cfg := getCfg("model.cfg")
|
||||
cfg := getCfg(configPath())
|
||||
cfg.ContextWindow = fetchContextWindow(&cfg)
|
||||
if td := toolsDir(&cfg); td != "" {
|
||||
sp += "\n\nExtra shell tools can be found at " + td
|
||||
@@ -1694,11 +1703,11 @@ func main() {
|
||||
}
|
||||
} else if len(parts) >= 3 {
|
||||
k, v := strings.TrimSpace(parts[1]), strings.TrimSpace(parts[2])
|
||||
if err := setCfg("model.cfg", k, v); err != nil {
|
||||
if err := setCfg(".bantam.cfg", k, v); err != nil {
|
||||
fmt.Println(c("[cfg error: "+err.Error()+"]", 31))
|
||||
continue
|
||||
}
|
||||
cfg = getCfg("model.cfg")
|
||||
cfg = getCfg(configPath())
|
||||
if k == "model" || k == "endpoint" || k == "api_key" {
|
||||
cfg.ContextWindow = fetchContextWindow(&cfg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user