Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
511 changes: 228 additions & 283 deletions core/bifrost.go

Large diffs are not rendered by default.

69 changes: 35 additions & 34 deletions core/internal/llmtests/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,36 +207,36 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx context.Context,
{
Models: []string{"*"},
Weight: 1.0,
Aliases: map[string]string{
"claude-3.7-sonnet": "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"claude-4-sonnet": "global.anthropic.claude-sonnet-4-20250514-v1:0",
"claude-4.5-sonnet": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
"claude-4.5-haiku": "global.anthropic.claude-haiku-4-5-20251001-v1:0",
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
BedrockKeyConfig: &schemas.BedrockKeyConfig{
AccessKey: *schemas.NewEnvVar("env.AWS_ACCESS_KEY_ID"),
SecretKey: *schemas.NewEnvVar("env.AWS_SECRET_ACCESS_KEY"),
SessionToken: schemas.NewEnvVar("env.AWS_SESSION_TOKEN"),
Region: schemas.NewEnvVar(getEnvWithDefault("AWS_REGION", "us-east-1")),
ARN: schemas.NewEnvVar("env.AWS_ARN"),
Deployments: map[string]string{
"claude-3.7-sonnet": "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"claude-4-sonnet": "global.anthropic.claude-sonnet-4-20250514-v1:0",
"claude-4.5-sonnet": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
"claude-4.5-haiku": "global.anthropic.claude-haiku-4-5-20251001-v1:0",
},
},
},
{
Models: []string{"*"},
Weight: 1.0,
Aliases: map[string]string{
"claude-3.5-sonnet": "anthropic.claude-3-5-sonnet-20240620-v1:0",
"claude-3.7-sonnet": "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"claude-4-sonnet": "global.anthropic.claude-sonnet-4-20250514-v1:0",
"claude-4.5-sonnet": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
"claude-4.5-haiku": "global.anthropic.claude-haiku-4-5-20251001-v1:0",
},
BedrockKeyConfig: &schemas.BedrockKeyConfig{
AccessKey: *schemas.NewEnvVar("env.AWS_ACCESS_KEY_ID"),
SecretKey: *schemas.NewEnvVar("env.AWS_SECRET_ACCESS_KEY"),
SessionToken: schemas.NewEnvVar("env.AWS_SESSION_TOKEN"),
Region: schemas.NewEnvVar(getEnvWithDefault("AWS_REGION", "us-east-1")),
ARN: schemas.NewEnvVar("env.AWS_BEDROCK_ARN"),
Deployments: map[string]string{
"claude-3.5-sonnet": "anthropic.claude-3-5-sonnet-20240620-v1:0",
"claude-3.7-sonnet": "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"claude-4-sonnet": "global.anthropic.claude-sonnet-4-20250514-v1:0",
"claude-4.5-sonnet": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
"claude-4.5-haiku": "global.anthropic.claude-haiku-4-5-20251001-v1:0",
},
},
UseForBatchAPI: bifrost.Ptr(true),
},
Expand Down Expand Up @@ -266,18 +266,18 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx context.Context,
Value: *schemas.NewEnvVar("env.AZURE_API_KEY"),
Models: []string{"*"},
Weight: 1.0,
Aliases: schemas.KeyAliases{
"gpt-4o": "gpt-4o",
"gpt-4o-backup": "gpt-4o-3",
"claude-opus-4-5": "claude-opus-4-5",
"o1": "o1",
"gpt-image-1": "gpt-image-1",
"text-embedding-ada-002": "text-embedding-ada-002",
"sora-2": "sora-2",
},
AzureKeyConfig: &schemas.AzureKeyConfig{
Endpoint: *schemas.NewEnvVar("env.AZURE_ENDPOINT"),
APIVersion: schemas.NewEnvVar("env.AZURE_API_VERSION"),
Deployments: map[string]string{
"gpt-4o": "gpt-4o",
"gpt-4o-backup": "gpt-4o-3",
"claude-opus-4-5": "claude-opus-4-5",
"o1": "o1",
"gpt-image-1": "gpt-image-1",
"text-embedding-ada-002": "text-embedding-ada-002",
"sora-2": "sora-2",
},
Endpoint: *schemas.NewEnvVar("env.AZURE_ENDPOINT"),
APIVersion: schemas.NewEnvVar("env.AZURE_API_VERSION"),
ClientID: schemas.NewEnvVar("env.AZURE_CLIENT_ID"),
ClientSecret: schemas.NewEnvVar("env.AZURE_CLIENT_SECRET"),
TenantID: schemas.NewEnvVar("env.AZURE_TENANT_ID"),
Expand All @@ -288,14 +288,15 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx context.Context,
Value: *schemas.NewEnvVar("env.AZURE_API_KEY"),
Models: []string{"*"},
Weight: 1.0,
Aliases: schemas.KeyAliases{
"whisper": "whisper",
"whisper-1": "whisper",
"gpt-4o-mini-tts": "gpt-4o-mini-tts",
"gpt-4o-mini-audio-preview": "gpt-4o-mini-audio-preview",
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
AzureKeyConfig: &schemas.AzureKeyConfig{
Endpoint: *schemas.NewEnvVar("env.AZURE_ENDPOINT"),
APIVersion: schemas.NewEnvVar("env.AZURE_API_VERSION"),
Deployments: map[string]string{
"whisper": "whisper",
"gpt-4o-mini-tts": "gpt-4o-mini-tts",
"gpt-4o-mini-audio-preview": "gpt-4o-mini-audio-preview",
},
},
},
}, nil
Expand Down Expand Up @@ -329,15 +330,15 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx context.Context,
Value: *schemas.NewEnvVar("env.VERTEX_API_KEY"),
Models: []string{"claude-sonnet-4-5", "claude-4.5-haiku", "claude-opus-4-5"},
Weight: 1.0,
Aliases: schemas.KeyAliases{
"claude-sonnet-4-5": "claude-sonnet-4-5",
"claude-4.5-haiku": "claude-haiku-4-5@20251001",
"claude-opus-4-5": "claude-opus-4-5",
},
VertexKeyConfig: &schemas.VertexKeyConfig{
ProjectID: *schemas.NewEnvVar("env.VERTEX_PROJECT_ID"),
Region: *schemas.NewEnvVar(getEnvWithDefault("VERTEX_REGION_ANTHROPIC", "us-east5")),
AuthCredentials: *schemas.NewEnvVar("env.VERTEX_CREDENTIALS"),
Deployments: map[string]string{
"claude-sonnet-4-5": "claude-sonnet-4-5",
"claude-4.5-haiku": "claude-haiku-4-5@20251001",
"claude-opus-4-5": "claude-opus-4-5",
},
},
UseForBatchAPI: bifrost.Ptr(true),
},
Expand Down
6 changes: 3 additions & 3 deletions core/internal/llmtests/image_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ func RunImageEditTest(t *testing.T, client *bifrost.Bifrost, ctx context.Context
t.Error("❌ ExtraFields.Provider is empty")
}

if imageEditResponse.ExtraFields.ModelRequested == "" {
t.Error("❌ ExtraFields.ModelRequested is empty")
if imageEditResponse.ExtraFields.OriginalModelRequested == "" {
t.Error("❌ ExtraFields.OriginalModelRequested is empty")
}

// Validate RequestType is ImageEditRequest
Expand All @@ -374,7 +374,7 @@ func RunImageEditTest(t *testing.T, client *bifrost.Bifrost, ctx context.Context
}

t.Logf("✅ Image edit successful: ID=%s, Provider=%s, Model=%s, Images=%d",
imageEditResponse.ID, imageEditResponse.ExtraFields.Provider, imageEditResponse.ExtraFields.ModelRequested, len(imageEditResponse.Data))
imageEditResponse.ID, imageEditResponse.ExtraFields.Provider, imageEditResponse.ExtraFields.OriginalModelRequested, len(imageEditResponse.Data))
})
}

Expand Down
6 changes: 3 additions & 3 deletions core/internal/llmtests/image_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ func RunImageGenerationTest(t *testing.T, client *bifrost.Bifrost, ctx context.C
t.Error("❌ ExtraFields.Provider is empty")
}

if imageGenerationResponse.ExtraFields.ModelRequested == "" {
t.Error("❌ ExtraFields.ModelRequested is empty")
if imageGenerationResponse.ExtraFields.OriginalModelRequested == "" {
t.Error("❌ ExtraFields.OriginalModelRequested is empty")
}

t.Logf("✅ Image generation successful: ID=%s, Provider=%s, Model=%s, Images=%d",
imageGenerationResponse.ID, imageGenerationResponse.ExtraFields.Provider, imageGenerationResponse.ExtraFields.ModelRequested, len(imageGenerationResponse.Data))
imageGenerationResponse.ID, imageGenerationResponse.ExtraFields.Provider, imageGenerationResponse.ExtraFields.OriginalModelRequested, len(imageGenerationResponse.Data))
})
}

Expand Down
6 changes: 3 additions & 3 deletions core/internal/llmtests/image_variation.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ func RunImageVariationTest(t *testing.T, client *bifrost.Bifrost, ctx context.Co
t.Error("❌ ExtraFields.Provider is empty")
}

if imageVariationResponse.ExtraFields.ModelRequested == "" {
t.Error("❌ ExtraFields.ModelRequested is empty")
if imageVariationResponse.ExtraFields.OriginalModelRequested == "" {
t.Error("❌ ExtraFields.OriginalModelRequested is empty")
}

// Validate RequestType is ImageVariationRequest
Expand All @@ -172,7 +172,7 @@ func RunImageVariationTest(t *testing.T, client *bifrost.Bifrost, ctx context.Co
}

t.Logf("✅ Image variation successful: ID=%s, Provider=%s, Model=%s, Images=%d",
imageVariationResponse.ID, imageVariationResponse.ExtraFields.Provider, imageVariationResponse.ExtraFields.ModelRequested, len(imageVariationResponse.Data))
imageVariationResponse.ID, imageVariationResponse.ExtraFields.Provider, imageVariationResponse.ExtraFields.OriginalModelRequested, len(imageVariationResponse.Data))
})
}

Expand Down
5 changes: 2 additions & 3 deletions core/internal/llmtests/response_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ func validateResponsesBasicStructure(response *schemas.BifrostResponsesResponse,
}

provider := response.ExtraFields.Provider
model := response.ExtraFields.ModelDeployment
model := response.ExtraFields.ResolvedModelUsed

// Verify top level status is present for OpenAI and Azure with non-Claude models
if provider != "" && (provider == schemas.OpenAI || provider == schemas.Azure) && !strings.Contains(strings.ToLower(model), "claude") {
Expand Down Expand Up @@ -976,8 +976,7 @@ func validateResponsesTechnicalFields(t *testing.T, response *schemas.BifrostRes

// Check model field
if expectations.ShouldHaveModel {
if strings.TrimSpace(response.Model) == "" &&
strings.TrimSpace(response.ExtraFields.ModelDeployment) == "" {
if strings.TrimSpace(response.Model) == "" {
result.Passed = false
result.Errors = append(result.Errors, fmt.Sprintf("Expected model field but not present or empty (provider: %s)", response.ExtraFields.Provider))
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Expand Down
8 changes: 4 additions & 4 deletions core/internal/llmtests/speech_synthesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ func RunSpeechSynthesisAdvancedTest(t *testing.T, client *bifrost.Bifrost, ctx c
t.Fatalf("HD audio data too small: got %d bytes, expected at least 5000", audioSize)
}

if speechResponse.ExtraFields.ModelRequested != testConfig.SpeechSynthesisModel {
t.Logf("⚠️ Expected HD model, got: %s", speechResponse.ExtraFields.ModelRequested)
if speechResponse.ExtraFields.OriginalModelRequested != testConfig.SpeechSynthesisModel {
t.Logf("⚠️ Expected HD model, got: %s", speechResponse.ExtraFields.OriginalModelRequested)
}

t.Logf("✅ HD speech synthesis successful: %d bytes generated", len(speechResponse.Audio))
Expand Down Expand Up @@ -344,8 +344,8 @@ func validateSpeechSynthesisSpecific(t *testing.T, response *schemas.BifrostSpee
t.Fatalf("Audio data too small: got %d bytes, expected at least %d", audioSize, expectMinBytes)
}

if expectedModel != "" && response.ExtraFields.ModelRequested != expectedModel {
t.Logf("⚠️ Expected model, got: %s", response.ExtraFields.ModelRequested)
if expectedModel != "" && response.ExtraFields.OriginalModelRequested != expectedModel {
t.Logf("⚠️ Expected model, got: %s", response.ExtraFields.OriginalModelRequested)
}

t.Logf("✅ Audio validation passed: %d bytes generated", audioSize)
Expand Down
8 changes: 4 additions & 4 deletions core/internal/llmtests/speech_synthesis_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ func RunSpeechSynthesisStreamTest(t *testing.T, client *bifrost.Bifrost, ctx con
if response.BifrostSpeechStreamResponse.Type != "" && (response.BifrostSpeechStreamResponse.Type != schemas.SpeechStreamResponseTypeDelta && response.BifrostSpeechStreamResponse.Type != schemas.SpeechStreamResponseTypeDone) {
t.Logf("⚠️ Unexpected object type in stream: %s", response.BifrostSpeechStreamResponse.Type)
}
if response.BifrostSpeechStreamResponse.ExtraFields.ModelRequested != "" && response.BifrostSpeechStreamResponse.ExtraFields.ModelRequested != testConfig.SpeechSynthesisModel {
t.Logf("⚠️ Unexpected model in stream: %s", response.BifrostSpeechStreamResponse.ExtraFields.ModelRequested)
if response.BifrostSpeechStreamResponse.ExtraFields.OriginalModelRequested != "" && response.BifrostSpeechStreamResponse.ExtraFields.OriginalModelRequested != testConfig.SpeechSynthesisModel {
t.Logf("⚠️ Unexpected model in stream: %s", response.BifrostSpeechStreamResponse.ExtraFields.OriginalModelRequested)
}
}

Expand Down Expand Up @@ -348,8 +348,8 @@ func RunSpeechSynthesisStreamAdvancedTest(t *testing.T, client *bifrost.Bifrost,
t.Logf("✅ HD chunk %d: %d bytes", chunkCount, chunkSize)
}

if response.BifrostSpeechStreamResponse != nil && response.BifrostSpeechStreamResponse.ExtraFields.ModelRequested != "" && response.BifrostSpeechStreamResponse.ExtraFields.ModelRequested != testConfig.SpeechSynthesisModel {
t.Logf("⚠️ Unexpected HD model: %s", response.BifrostSpeechStreamResponse.ExtraFields.ModelRequested)
if response.BifrostSpeechStreamResponse != nil && response.BifrostSpeechStreamResponse.ExtraFields.OriginalModelRequested != "" && response.BifrostSpeechStreamResponse.ExtraFields.OriginalModelRequested != testConfig.SpeechSynthesisModel {
t.Logf("⚠️ Unexpected HD model: %s", response.BifrostSpeechStreamResponse.ExtraFields.OriginalModelRequested)
}
}

Expand Down
8 changes: 6 additions & 2 deletions core/internal/llmtests/transcription_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,12 @@ func RunTranscriptionStreamTest(t *testing.T, client *bifrost.Bifrost, ctx conte
if response.BifrostTranscriptionStreamResponse.Type != schemas.TranscriptionStreamResponseTypeDelta {
t.Logf("⚠️ Unexpected object type in stream: %s", response.BifrostTranscriptionStreamResponse.Type)
}
if response.BifrostTranscriptionStreamResponse.ExtraFields.ModelRequested != "" && response.BifrostTranscriptionStreamResponse.ExtraFields.ModelRequested != testConfig.TranscriptionModel {
t.Logf("⚠️ Unexpected model in stream: %s", response.BifrostTranscriptionStreamResponse.ExtraFields.ModelRequested)
gotModel := response.BifrostTranscriptionStreamResponse.ExtraFields.OriginalModelRequested
if gotModel == "" {
t.Fatal("❌ Stream chunk missing extra_fields.original_model_requested")
}
if gotModel != testConfig.TranscriptionModel {
t.Fatalf("❌ Unexpected original_model_requested in stream: got %q want %q", gotModel, testConfig.TranscriptionModel)
}

lastResponse = DeepCopyBifrostStreamChunk(response)
Expand Down
4 changes: 2 additions & 2 deletions core/internal/llmtests/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func RunVideoGenerationTest(t *testing.T, client *bifrost.Bifrost, ctx context.C
if resp.ExtraFields.Provider == "" {
t.Fatal("❌ Video generation extra_fields.provider is empty")
}
if resp.ExtraFields.ModelRequested == "" {
t.Fatal("❌ Video generation extra_fields.model_requested is empty")
if resp.ExtraFields.OriginalModelRequested == "" {
t.Fatal("❌ Video generation extra_fields.original_model_requested is empty")
}

t.Logf("✅ Video generation created job: id=%s status=%s", resp.ID, resp.Status)
Expand Down
Loading
Loading