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
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,9 @@ build: build-ui ## Build bifrost-http binary
echo "$(GREEN)╚═══════════════════════════════════════╝$(NC)"; \
fi
@if [ -n "$(DYNAMIC)" ]; then \
echo "$(YELLOW)Note: This will create a dynamically linked build.$(NC)"; \
echo "$(YELLOW)To build with dynamic plugin support.$(NC)"; \
echo "$(YELLOW)Note: This will create a dynamically linked build.$(NC)"; \
else \
echo "$(YELLOW)Note: This will create a statically linked build.$(NC)"; \
echo "$(YELLOW)To build with dynamic plugin support.$(NC)"; \
echo "$(YELLOW)Note: This will create a statically linked build.$(NC)"; \
fi
@mkdir -p ./tmp
@TARGET_OS="$(GOOS)"; \
Expand Down
219 changes: 158 additions & 61 deletions core/bifrost.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions core/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- feat: adds new parameter for each provider key config `use_for_batch_apis`. This helps users to select which APIs or accounts to be used for Batch APIs.
- feat: adds s3 bucket config support for Bedrock provider.
2 changes: 1 addition & 1 deletion core/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/maximhq/bifrost/core

go 1.24.3
go 1.25.5

require (
github.com/aws/aws-sdk-go-v2 v1.41.0
Expand Down
124 changes: 79 additions & 45 deletions core/internal/testutil/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ type ComprehensiveTestConfig struct {
TranscriptionModel string
SpeechSynthesisModel string
Scenarios TestScenarios
Fallbacks []schemas.Fallback // for chat, responses, image and reasoning tests
TextCompletionFallbacks []schemas.Fallback // for text completion tests
TranscriptionFallbacks []schemas.Fallback // for transcription tests
SpeechSynthesisFallbacks []schemas.Fallback // for speech synthesis tests
EmbeddingFallbacks []schemas.Fallback // for embedding tests
SkipReason string // Reason to skip certain tests
Fallbacks []schemas.Fallback // for chat, responses, image and reasoning tests
TextCompletionFallbacks []schemas.Fallback // for text completion tests
TranscriptionFallbacks []schemas.Fallback // for transcription tests
SpeechSynthesisFallbacks []schemas.Fallback // for speech synthesis tests
EmbeddingFallbacks []schemas.Fallback // for embedding tests
SkipReason string // Reason to skip certain tests
BatchExtraParams map[string]interface{} // Extra params for batch operations (e.g., role_arn, output_s3_uri for Bedrock)
FileExtraParams map[string]interface{} // Extra params for file operations (e.g., s3_bucket for Bedrock)
}
Expand Down Expand Up @@ -117,25 +117,28 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx *context.Context
case schemas.OpenAI:
return []schemas.Key{
{
Value: os.Getenv("OPENAI_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("OPENAI_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case ProviderOpenAICustom:
return []schemas.Key{
{
Value: os.Getenv("OPENAI_API_KEY"), // Use GROQ API key for OpenAI-compatible endpoint
Models: []string{},
Weight: 1.0,
Value: os.Getenv("OPENAI_API_KEY"), // Use GROQ API key for OpenAI-compatible endpoint
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Anthropic:
return []schemas.Key{
{
Value: os.Getenv("ANTHROPIC_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("ANTHROPIC_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Bedrock:
Expand All @@ -157,6 +160,25 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx *context.Context
},
},
},
{
Models: []string{},
Weight: 1.0,
BedrockKeyConfig: &schemas.BedrockKeyConfig{
AccessKey: os.Getenv("AWS_ACCESS_KEY_ID"),
SecretKey: os.Getenv("AWS_SECRET_ACCESS_KEY"),
SessionToken: bifrost.Ptr(os.Getenv("AWS_SESSION_TOKEN")),
Region: bifrost.Ptr(getEnvWithDefault("AWS_REGION", "us-east-1")),
ARN: bifrost.Ptr(os.Getenv("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),
},
{
Models: []string{"cohere.embed-v4:0"},
Weight: 1.0,
Expand All @@ -171,9 +193,10 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx *context.Context
case schemas.Cohere:
return []schemas.Key{
{
Value: os.Getenv("COHERE_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("COHERE_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Azure:
Expand All @@ -192,6 +215,7 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx *context.Context
"text-embedding-ada-002": "text-embedding-ada-002",
},
},
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Vertex:
Expand All @@ -205,78 +229,88 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx *context.Context
Region: getEnvWithDefault("VERTEX_REGION", "us-central1"),
AuthCredentials: os.Getenv("VERTEX_CREDENTIALS"),
},
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Mistral:
return []schemas.Key{
{
Value: os.Getenv("MISTRAL_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("MISTRAL_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Groq:
return []schemas.Key{
{
Value: os.Getenv("GROQ_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("GROQ_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Parasail:
return []schemas.Key{
{
Value: os.Getenv("PARASAIL_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("PARASAIL_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Elevenlabs:
return []schemas.Key{
{
Value: os.Getenv("ELEVENLABS_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("ELEVENLABS_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Perplexity:
return []schemas.Key{
{
Value: os.Getenv("PERPLEXITY_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("PERPLEXITY_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Cerebras:
return []schemas.Key{
{
Value: os.Getenv("CEREBRAS_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("CEREBRAS_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Gemini:
return []schemas.Key{
{
Value: os.Getenv("GEMINI_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("GEMINI_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.OpenRouter:
return []schemas.Key{
{
Value: os.Getenv("OPENROUTER_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("OPENROUTER_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
case schemas.Nebius:
return []schemas.Key{
{
Value: os.Getenv("NEBIUS_API_KEY"),
Models: []string{},
Weight: 1.0,
Value: os.Getenv("NEBIUS_API_KEY"),
Models: []string{},
Weight: 1.0,
UseForBatchAPI: bifrost.Ptr(true),
},
}, nil
default:
Expand Down
10 changes: 5 additions & 5 deletions core/internal/testutil/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func RunBatchCreateTest(t *testing.T, client *bifrost.Bifrost, ctx context.Conte
// Create a batch request with a simple chat completion
request := &schemas.BifrostBatchCreateRequest{
Provider: testConfig.Provider,
Model: testConfig.ChatModel,
Model: schemas.Ptr(testConfig.ChatModel),
Endpoint: schemas.BatchEndpointChatCompletions,
Requests: []schemas.BatchRequestItem{
{
Expand Down Expand Up @@ -113,7 +113,7 @@ func RunBatchRetrieveTest(t *testing.T, client *bifrost.Bifrost, ctx context.Con
// Note: In real tests, you might want to use an existing batch ID
createRequest := &schemas.BifrostBatchCreateRequest{
Provider: testConfig.Provider,
Model: testConfig.ChatModel,
Model: schemas.Ptr(testConfig.ChatModel),
Endpoint: schemas.BatchEndpointChatCompletions,
Requests: []schemas.BatchRequestItem{
{
Expand Down Expand Up @@ -185,7 +185,7 @@ func RunBatchCancelTest(t *testing.T, client *bifrost.Bifrost, ctx context.Conte
// First, create a batch to cancel
createRequest := &schemas.BifrostBatchCreateRequest{
Provider: testConfig.Provider,
Model: testConfig.ChatModel,
Model: schemas.Ptr(testConfig.ChatModel),
Endpoint: schemas.BatchEndpointChatCompletions,
Requests: []schemas.BatchRequestItem{
{
Expand Down Expand Up @@ -295,7 +295,7 @@ func RunBatchUnsupportedTest(t *testing.T, client *bifrost.Bifrost, ctx context.
// Try to create a batch - should fail with unsupported error
request := &schemas.BifrostBatchCreateRequest{
Provider: testConfig.Provider,
Model: testConfig.ChatModel,
Model: schemas.Ptr(testConfig.ChatModel),
Endpoint: schemas.BatchEndpointChatCompletions,
Requests: []schemas.BatchRequestItem{
{
Expand Down Expand Up @@ -691,7 +691,7 @@ func RunFileAndBatchIntegrationTest(t *testing.T, client *bifrost.Bifrost, ctx c
// Step 2: Create a batch using the uploaded file
batchRequest := &schemas.BifrostBatchCreateRequest{
Provider: testConfig.Provider,
Model: testConfig.ChatModel,
Model: schemas.Ptr(testConfig.ChatModel),
InputFileID: uploadResponse.ID,
Endpoint: schemas.BatchEndpointChatCompletions,
CompletionWindow: "24h",
Expand Down
Loading
Loading