feat: provider presets (openai, openrouter, ollama, dahl, gonkarouter, custom), /api/info, provider display in Android settings
This commit is contained in:
parent
d2ec0848c8
commit
7b92e259ad
14 changed files with 233 additions and 18 deletions
|
|
@ -13,6 +13,8 @@ import (
|
|||
)
|
||||
|
||||
type LLM struct {
|
||||
// Provider selects a preset: openai, openrouter, ollama, dahl, gonkarouter or custom.
|
||||
Provider string `yaml:"provider" json:"provider"`
|
||||
BaseURL string `yaml:"base_url" json:"base_url"`
|
||||
APIKey string `yaml:"api_key" json:"api_key"`
|
||||
Model string `yaml:"model" json:"model"`
|
||||
|
|
@ -61,8 +63,7 @@ func Default() Config {
|
|||
Listen: "127.0.0.1:8787",
|
||||
DataDir: "./data",
|
||||
LLM: LLM{
|
||||
BaseURL: "https://api.openai.com/v1",
|
||||
Model: "gpt-4o-mini",
|
||||
Provider: "openai",
|
||||
TimeoutSec: 120,
|
||||
Temperature: 0.7,
|
||||
},
|
||||
|
|
@ -98,6 +99,9 @@ func Load(path string) (Config, error) {
|
|||
}
|
||||
}
|
||||
applyEnv(&cfg, os.Getenv)
|
||||
if err := applyPreset(&cfg.LLM, os.Getenv); err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
if cfg.Workspace == "" {
|
||||
cfg.Workspace = filepath.Join(cfg.DataDir, "workspace")
|
||||
}
|
||||
|
|
@ -114,6 +118,7 @@ func applyEnv(c *Config, get func(string) string) {
|
|||
set("BYTECLAW_AUTH_TOKEN", &c.AuthToken)
|
||||
set("BYTECLAW_DATA_DIR", &c.DataDir)
|
||||
set("BYTECLAW_WORKSPACE", &c.Workspace)
|
||||
set("BYTECLAW_LLM_PROVIDER", &c.LLM.Provider)
|
||||
set("BYTECLAW_LLM_BASE_URL", &c.LLM.BaseURL)
|
||||
set("BYTECLAW_LLM_API_KEY", &c.LLM.APIKey)
|
||||
set("BYTECLAW_LLM_MODEL", &c.LLM.Model)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue