feat: sync AI compose and ChatBot features
This commit is contained in:
parent
35e5d38f4d
commit
b7269b135f
75 changed files with 5426 additions and 123 deletions
|
|
@ -20,13 +20,13 @@ func TestLoadDefaultsAdvertiseIPToLoopback(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLoadUsesExplicitAdvertiseIP(t *testing.T) {
|
||||
t.Setenv("TELESRV_ADVERTISE_IP", "192.0.2.10")
|
||||
t.Setenv("TELESRV_ADVERTISE_IP", "203.0.113.10")
|
||||
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatalf("Load: %v", err)
|
||||
}
|
||||
if cfg.AdvertiseIP != "192.0.2.10" {
|
||||
if cfg.AdvertiseIP != "203.0.113.10" {
|
||||
t.Fatalf("AdvertiseIP = %q, want explicit env", cfg.AdvertiseIP)
|
||||
}
|
||||
}
|
||||
|
|
@ -55,6 +55,40 @@ func TestLoadBusinessAIProviderDefaultsToEcho(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLoadAIProviders(t *testing.T) {
|
||||
t.Setenv("TELESRV_AI_PROVIDERS", "local,openai,gemini")
|
||||
t.Setenv("TELESRV_AI_OPENAI_API_KEY", "openai-key")
|
||||
t.Setenv("TELESRV_AI_OPENAI_MODEL", "gpt-test")
|
||||
t.Setenv("TELESRV_AI_GEMINI_API_KEY", "gemini-key")
|
||||
t.Setenv("TELESRV_AI_GEMINI_BASE_URL", "https://gemini.example")
|
||||
t.Setenv("TELESRV_AI_GEMINI_TEMPERATURE", "0.6")
|
||||
t.Setenv("TELESRV_AI_GEMINI_OMIT_TEMPERATURE", "true")
|
||||
t.Setenv("TELESRV_AI_GEMINI_THINKING", "disabled")
|
||||
t.Setenv("TELESRV_AI_TIMEOUT", "3s")
|
||||
t.Setenv("TELESRV_AI_RATE_LIMIT", "7")
|
||||
t.Setenv("TELESRV_AI_RATE_WINDOW", "30s")
|
||||
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatalf("Load: %v", err)
|
||||
}
|
||||
if len(cfg.AIProviders) != 3 {
|
||||
t.Fatalf("AIProviders len = %d, want 3", len(cfg.AIProviders))
|
||||
}
|
||||
if cfg.AIProviders[0].Kind != "local" {
|
||||
t.Fatalf("AIProviders[0].Kind = %q, want local", cfg.AIProviders[0].Kind)
|
||||
}
|
||||
if cfg.AIProviders[1].Kind != "openai_responses" || cfg.AIProviders[1].APIKey != "openai-key" || cfg.AIProviders[1].Model != "gpt-test" {
|
||||
t.Fatalf("openai provider = %#v", cfg.AIProviders[1])
|
||||
}
|
||||
if cfg.AIProviders[2].Kind != "gemini" || cfg.AIProviders[2].BaseURL != "https://gemini.example" || cfg.AIProviders[2].Temperature != 0.6 || !cfg.AIProviders[2].OmitTemperature || cfg.AIProviders[2].Thinking != "disabled" {
|
||||
t.Fatalf("gemini provider = %#v", cfg.AIProviders[2])
|
||||
}
|
||||
if cfg.AITimeout != 3*time.Second || cfg.AIRateLimit != 7 || cfg.AIRateWindow != 30*time.Second {
|
||||
t.Fatalf("AI timing/rate config = %v/%d/%v", cfg.AITimeout, cfg.AIRateLimit, cfg.AIRateWindow)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadReadsEnvStyleConfigFile(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "telesrv.env")
|
||||
writeConfigFile(t, path, `
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue