Skip to content

Commit

Permalink
#163: Covered config to model building
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-glushko committed Mar 11, 2024
1 parent d48724d commit c65b7c9
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions pkg/routers/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package routers
import (
"testing"

"glide/pkg/providers/cohere"

"github.com/stretchr/testify/require"
"glide/pkg/providers"
"glide/pkg/providers/clients"
Expand Down Expand Up @@ -70,6 +72,49 @@ func TestRouterConfig_BuildModels(t *testing.T) {
require.IsType(t, &routing.LeastLatencyRouting{}, routers[1].chatRouting)
}

func TestRouterConfig_BuildModelsPerType(t *testing.T) {
tel := telemetry.NewTelemetryMock()
openAIParams := openai.DefaultParams()
cohereParams := cohere.DefaultParams()

cfg := LangRouterConfig{
ID: "first_router",
Enabled: true,
RoutingStrategy: routing.Priority,
Retry: retry.DefaultExpRetryConfig(),
Models: []providers.LangModelConfig{
{
ID: "first_model",
Enabled: true,
Client: clients.DefaultClientConfig(),
ErrorBudget: health.DefaultErrorBudget(),
Latency: latency.DefaultConfig(),
OpenAI: &openai.Config{
APIKey: "ABC",
DefaultParams: &openAIParams,
},
},
{
ID: "second_model",
Enabled: true,
Client: clients.DefaultClientConfig(),
ErrorBudget: health.DefaultErrorBudget(),
Latency: latency.DefaultConfig(),
Cohere: &cohere.Config{
APIKey: "ABC",
DefaultParams: &cohereParams,
},
},
},
}

chatModels, streamChatModels, err := cfg.BuildModels(tel)

require.Len(t, chatModels, 2)
require.Len(t, streamChatModels, 1)
require.NoError(t, err)
}

func TestRouterConfig_InvalidSetups(t *testing.T) {
defaultParams := openai.DefaultParams()

Expand Down

0 comments on commit c65b7c9

Please sign in to comment.