feat: add configurable AgentRouter AI provider
This commit is contained in:
37
internal/growthreport/agentrouter_smoke_test.go
Normal file
37
internal/growthreport/agentrouter_smoke_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package growthreport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAgentRouterGrowthRawSmoke(t *testing.T) {
|
||||
if os.Getenv("AGENTROUTER_GROWTH_SMOKE") != "1" {
|
||||
t.Skip("set AGENTROUTER_GROWTH_SMOKE=1 to inspect the real provider contract")
|
||||
}
|
||||
evidence := json.RawMessage(os.Getenv("AGENTROUTER_GROWTH_EVIDENCE"))
|
||||
if !json.Valid(evidence) {
|
||||
t.Fatal("AGENTROUTER_GROWTH_EVIDENCE is not valid JSON")
|
||||
}
|
||||
client := NewAgentRouterClient(AgentRouterConfig{
|
||||
BaseURL: os.Getenv("AGENTROUTER_BASE_URL"), APIKey: os.Getenv("AGENTROUTER_API_KEY"),
|
||||
Model: os.Getenv("AGENTROUTER_MODEL"), Timeout: 30 * time.Second,
|
||||
}, &http.Client{})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
result, _, _, err := client.do(ctx, []any{
|
||||
map[string]any{"role": "system", "content": growthCopyInstructions},
|
||||
map[string]any{"role": "user", "content": string(evidence)},
|
||||
}, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(result.Choices) != 1 {
|
||||
t.Fatalf("choices=%d", len(result.Choices))
|
||||
}
|
||||
t.Logf("agentrouter_content=%s", result.Choices[0].Message.Content)
|
||||
}
|
||||
Reference in New Issue
Block a user