Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
59
backend/sdk/cliproxy/auth/conductor_usage_test.go
Normal file
59
backend/sdk/cliproxy/auth/conductor_usage_test.go
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
cliproxyexecutor "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/executor"
|
||||
coreusage "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/usage"
|
||||
)
|
||||
|
||||
func TestContextWithRequestedModelAliasIncludesReasoningEffort(t *testing.T) {
|
||||
ctx := contextWithRequestedModelAlias(context.Background(), cliproxyexecutor.Options{
|
||||
Metadata: map[string]any{
|
||||
cliproxyexecutor.RequestedModelMetadataKey: "client-model",
|
||||
cliproxyexecutor.ReasoningEffortMetadataKey: "medium",
|
||||
cliproxyexecutor.ServiceTierMetadataKey: "auto",
|
||||
cliproxyexecutor.GenerateMetadataKey: false,
|
||||
},
|
||||
}, "fallback-model")
|
||||
|
||||
if got := coreusage.RequestedModelAliasFromContext(ctx); got != "client-model" {
|
||||
t.Fatalf("requested model alias = %q, want %q", got, "client-model")
|
||||
}
|
||||
if got := coreusage.ReasoningEffortFromContext(ctx); got != "medium" {
|
||||
t.Fatalf("reasoning effort = %q, want %q", got, "medium")
|
||||
}
|
||||
gotServiceTier := coreusage.ServiceTierFromContext(ctx)
|
||||
if gotServiceTier != "auto" {
|
||||
t.Fatalf("service tier = %q, want %q", gotServiceTier, "auto")
|
||||
}
|
||||
if got := coreusage.GenerateFromContext(ctx); got {
|
||||
t.Fatalf("generate = %v, want false", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextWithRequestedModelAliasDefaultsGenerateTrue(t *testing.T) {
|
||||
ctx := contextWithRequestedModelAlias(context.Background(), cliproxyexecutor.Options{
|
||||
Metadata: map[string]any{
|
||||
cliproxyexecutor.RequestedModelMetadataKey: "client-model",
|
||||
},
|
||||
}, "fallback-model")
|
||||
|
||||
if got := coreusage.GenerateFromContext(ctx); !got {
|
||||
t.Fatalf("generate = %v, want true", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextWithRequestedModelAliasPreservesExistingGenerateFalse(t *testing.T) {
|
||||
ctx := coreusage.WithGenerate(context.Background(), false)
|
||||
ctx = contextWithRequestedModelAlias(ctx, cliproxyexecutor.Options{
|
||||
Metadata: map[string]any{
|
||||
cliproxyexecutor.RequestedModelMetadataKey: "client-model",
|
||||
},
|
||||
}, "fallback-model")
|
||||
|
||||
if got := coreusage.GenerateFromContext(ctx); got {
|
||||
t.Fatalf("generate = %v, want false", got)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue