mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-12 16:15:24 +00:00
- HTTP synthesize + test-connection now read tenant tts.timeout_ms (default 120s, was hardcoded 15s/10s). Gemini client default also bumped 30s→120s so both layers align when tenant config unset. - Inline prefix "Speak naturally: " prepended to single-voice text; multi-speaker transcripts pass through unchanged. - ErrTextOnlyResponse sentinel for 400 "text generation" bodies; single-voice retries once with stronger prefix. Narrowed needle list avoids false positives on unrelated 400s. - SynthesizeWithFallbackAdapted now returns errors.Join so sentinel survives fallback chain; HTTP 422 mapping + locale-translated ForLLM in agent tool (EN/VI/ZH catalogs). - Default Gemini model bumped to gemini-3.1-flash-tts-preview.
43 lines
1.6 KiB
Go
43 lines
1.6 KiB
Go
package gemini
|
|
|
|
import "testing"
|
|
|
|
// TestBuildURL_AppendsModelAndAction verifies the URL is constructed correctly.
|
|
func TestBuildURL_AppendsModelAndAction(t *testing.T) {
|
|
base := "https://generativelanguage.googleapis.com"
|
|
model := "gemini-2.5-flash-preview-tts"
|
|
got := buildURL(base, model)
|
|
want := "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-tts:generateContent"
|
|
if got != want {
|
|
t.Errorf("buildURL = %q, want %q", got, want)
|
|
}
|
|
}
|
|
|
|
// TestBuildURL_TrimsTrailingSlash verifies trailing slash on base is stripped.
|
|
func TestBuildURL_TrimsTrailingSlash(t *testing.T) {
|
|
got := buildURL("https://generativelanguage.googleapis.com/", "gemini-2.5-pro-preview-tts")
|
|
want := "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro-preview-tts:generateContent"
|
|
if got != want {
|
|
t.Errorf("buildURL = %q, want %q", got, want)
|
|
}
|
|
}
|
|
|
|
// TestProviderClient_DefaultTimeoutIs120s pins the validation-locked decision that
|
|
// the Gemini HTTP client defaults to 120000ms when timeoutMs<=0, matching the handler
|
|
// default. Without this alignment, unset tenant configs silently cap at 30s.
|
|
func TestProviderClient_DefaultTimeoutIs120s(t *testing.T) {
|
|
c := newClient("key", "", 0)
|
|
if c.timeoutMs != 120000 {
|
|
t.Errorf("newClient timeoutMs=0 should default to 120000, got %d", c.timeoutMs)
|
|
}
|
|
}
|
|
|
|
// TestProviderClient_ExplicitTimeoutIsHonored verifies that an explicit timeoutMs
|
|
// is preserved and not overwritten by the default.
|
|
func TestProviderClient_ExplicitTimeoutIsHonored(t *testing.T) {
|
|
c := newClient("key", "", 45000)
|
|
if c.timeoutMs != 45000 {
|
|
t.Errorf("newClient timeoutMs=45000 should stay 45000, got %d", c.timeoutMs)
|
|
}
|
|
}
|