52 lines
1.8 KiB
Go
52 lines
1.8 KiB
Go
package ai
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"git.ipao.vip/rogee/go-sip/internal/configread"
|
|
)
|
|
|
|
func bailianFixture(t *testing.T) Binding {
|
|
t.Helper()
|
|
task, _ := currentFixture(t, "full_ai")
|
|
task = changeCurrentAgent(t, task, func(a map[string]any) {
|
|
asr := a["asr"].(map[string]any)
|
|
delete(asr, "interim")
|
|
asr["provider_id"] = "bailian"
|
|
delete(asr, "provider_ref")
|
|
asr["model"] = "fun-asr-flash-8k-realtime-2026-01-28"
|
|
asr["input"].(map[string]any)["sample_rate_hz"] = 8000
|
|
llm := a["llm"].(map[string]any)
|
|
llm["provider_id"] = "bailian"
|
|
llm["model"] = "Qwen3.8-Flash"
|
|
delete(llm, "provider_ref")
|
|
tts := a["tts"].(map[string]any)
|
|
tts["provider_id"] = "bailian"
|
|
delete(tts, "provider_ref")
|
|
tts["protocol"] = TTSProtocolDashScopeTask
|
|
tts["model"] = "cosyvoice-v3-flash"
|
|
tts["voice"] = "longanyang"
|
|
tts["speed"] = 1.25
|
|
})
|
|
var provider configread.Provider
|
|
if err := json.Unmarshal([]byte(`{"provider_id":"bailian","provider_code":"ali_bailian","api_endpoint":"https://dashscope.aliyuncs.com/compatible-mode/v1","ws_endpoint":"wss://dashscope.aliyuncs.com/api-ws/v1/inference","api_key":"mock-key","extra_config":{}}`), &provider); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
bound, err := Bind(task, map[string]configread.Provider{"bailian": provider})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return bound
|
|
}
|
|
|
|
func TestTaskModelsShareConnectionOnlyProvider(t *testing.T) {
|
|
bound := bailianFixture(t)
|
|
if bound.ASR.Provider.ProviderRef != "bailian" || bound.LLM.Provider.ProviderRef != "bailian" || bound.TTS.Provider.ProviderRef != "bailian" {
|
|
t.Fatal("task provider_id binding was lost")
|
|
}
|
|
if bound.TTS.Model != "cosyvoice-v3-flash" || bound.TTS.Voice != "longanyang" || bound.TTS.Speed != 1.25 {
|
|
t.Fatal("task TTS model/voice/speed must remain exact")
|
|
}
|
|
}
|