Skip to content

Commit 39d5ca5

Browse files
author
false
committed
feat: huggingface provider added
1 parent d072fac commit 39d5ca5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5208
-406
lines changed

.github/workflows/pr-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ jobs:
115115
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
116116
VERTEX_CREDENTIALS: ${{ secrets.VERTEX_CREDENTIALS }}
117117
VERTEX_PROJECT_ID: ${{ secrets.VERTEX_PROJECT_ID }}
118+
HUGGING_FACE_API_KEY: ${{ secrets.HUGGING_FACE_API_KEY }}
118119
run: |
119120
echo "Running tests for PR #${{ github.event.pull_request.number || 'manual run' }}"
120121
./.github/workflows/scripts/run-tests.sh

.github/workflows/release-pipeline.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ jobs:
115115
VERTEX_CREDENTIALS: ${{ secrets.VERTEX_CREDENTIALS }}
116116
VERTEX_PROJECT_ID: ${{ secrets.VERTEX_PROJECT_ID }}
117117
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
118+
HUGGING_FACE_API_KEY: ${{ secrets.HUGGING_FACE_API_KEY }}
118119
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
119120
AWS_BEDROCK_ROLE_ARN: ${{ secrets.AWS_BEDROCK_ROLE_ARN }}
120121
run: ./.github/workflows/scripts/release-core.sh "${{ needs.detect-changes.outputs.core-version }}"
@@ -189,6 +190,7 @@ jobs:
189190
VERTEX_CREDENTIALS: ${{ secrets.VERTEX_CREDENTIALS }}
190191
VERTEX_PROJECT_ID: ${{ secrets.VERTEX_PROJECT_ID }}
191192
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
193+
HUGGING_FACE_API_KEY: ${{ secrets.HUGGING_FACE_API_KEY }}
192194
run: ./.github/workflows/scripts/release-framework.sh "${{ needs.detect-changes.outputs.framework-version }}"
193195

194196
plugins-release:
@@ -265,6 +267,7 @@ jobs:
265267
VERTEX_CREDENTIALS: ${{ secrets.VERTEX_CREDENTIALS }}
266268
VERTEX_PROJECT_ID: ${{ secrets.VERTEX_PROJECT_ID }}
267269
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
270+
HUGGING_FACE_API_KEY: ${{ secrets.HUGGING_FACE_API_KEY }}
268271
run: ./.github/workflows/scripts/release-all-plugins.sh '${{ needs.detect-changes.outputs.changed-plugins }}'
269272

270273
bifrost-http-release:
@@ -353,6 +356,7 @@ jobs:
353356
VERTEX_CREDENTIALS: ${{ secrets.VERTEX_CREDENTIALS }}
354357
VERTEX_PROJECT_ID: ${{ secrets.VERTEX_PROJECT_ID }}
355358
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
359+
HUGGING_FACE_API_KEY: ${{ secrets.HUGGING_FACE_API_KEY }}
356360
run: ./.github/workflows/scripts/release-bifrost-http.sh "${{ needs.detect-changes.outputs.transport-version }}"
357361

358362
# Docker build amd64

core/bifrost.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/maximhq/bifrost/core/providers/elevenlabs"
2424
"github.com/maximhq/bifrost/core/providers/gemini"
2525
"github.com/maximhq/bifrost/core/providers/groq"
26+
"github.com/maximhq/bifrost/core/providers/huggingface"
2627
"github.com/maximhq/bifrost/core/providers/mistral"
2728
"github.com/maximhq/bifrost/core/providers/nebius"
2829
"github.com/maximhq/bifrost/core/providers/ollama"
@@ -1885,6 +1886,8 @@ func (bifrost *Bifrost) createBaseProvider(providerKey schemas.ModelProvider, co
18851886
return elevenlabs.NewElevenlabsProvider(config, bifrost.logger), nil
18861887
case schemas.Nebius:
18871888
return nebius.NewNebiusProvider(config, bifrost.logger)
1889+
case schemas.HuggingFace:
1890+
return huggingface.NewHuggingFaceProvider(config, bifrost.logger), nil
18881891
default:
18891892
return nil, fmt.Errorf("unsupported provider: %s", targetProviderKey)
18901893
}

core/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
- feat: added HuggingFace provider using Inference Provider API, support for chat(with stream also), response(with stream also), TTS and speech synthesis
12
- fix(mcp): ensure properties field is always set for tools

core/internal/testutil/account.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func (account *ComprehensiveTestAccount) GetConfiguredProviders() ([]schemas.Mod
111111
schemas.Cerebras,
112112
schemas.Gemini,
113113
schemas.OpenRouter,
114+
schemas.HuggingFace,
114115
schemas.Nebius,
115116
ProviderOpenAICustom,
116117
}, nil
@@ -323,6 +324,14 @@ func (account *ComprehensiveTestAccount) GetKeysForProvider(ctx *context.Context
323324
UseForBatchAPI: bifrost.Ptr(true),
324325
},
325326
}, nil
327+
case schemas.HuggingFace:
328+
return []schemas.Key{
329+
{
330+
Value: os.Getenv("HUGGING_FACE_API_KEY"),
331+
Models: []string{},
332+
Weight: 1.0,
333+
},
334+
}, nil
326335
case schemas.Nebius:
327336
return []schemas.Key{
328337
{
@@ -577,6 +586,19 @@ func (account *ComprehensiveTestAccount) GetConfigForProvider(providerKey schema
577586
BufferSize: 10,
578587
},
579588
}, nil
589+
case schemas.HuggingFace:
590+
return &schemas.ProviderConfig{
591+
NetworkConfig: schemas.NetworkConfig{
592+
DefaultRequestTimeoutInSeconds: 300,
593+
MaxRetries: 10, // HuggingFace can be variable
594+
RetryBackoffInitial: 2 * time.Second,
595+
RetryBackoffMax: 30 * time.Second,
596+
},
597+
ConcurrencyAndBufferSize: schemas.ConcurrencyAndBufferSize{
598+
Concurrency: Concurrency,
599+
BufferSize: 10,
600+
},
601+
}, nil
580602
case schemas.Nebius:
581603
return &schemas.ProviderConfig{
582604
NetworkConfig: schemas.NetworkConfig{
@@ -995,4 +1017,38 @@ var AllProviderConfigs = []ComprehensiveTestConfig{
9951017
{Provider: schemas.OpenAI, Model: "gpt-4o-mini"},
9961018
},
9971019
},
1020+
{
1021+
Provider: schemas.HuggingFace,
1022+
ChatModel: "groq/openai/gpt-oss-120b",
1023+
VisionModel: "fireworks-ai/Qwen/Qwen2.5-VL-32B-Instruct",
1024+
EmbeddingModel: "sambanova/intfloat/e5-mistral-7b-instruct",
1025+
TranscriptionModel: "fal-ai/openai/whisper-large-v3",
1026+
SpeechSynthesisModel: "fal-ai/hexgrad/Kokoro-82M",
1027+
Scenarios: TestScenarios{
1028+
TextCompletion: false,
1029+
TextCompletionStream: false,
1030+
SimpleChat: true,
1031+
CompletionStream: true,
1032+
MultiTurnConversation: true,
1033+
ToolCalls: true,
1034+
ToolCallsStreaming: true,
1035+
MultipleToolCalls: false,
1036+
End2EndToolCalling: true,
1037+
AutomaticFunctionCall: true,
1038+
ImageURL: true,
1039+
ImageBase64: true,
1040+
MultipleImages: true,
1041+
CompleteEnd2End: true,
1042+
Embedding: true,
1043+
Transcription: true,
1044+
TranscriptionStream: false,
1045+
SpeechSynthesis: true,
1046+
SpeechSynthesisStream: false,
1047+
Reasoning: false,
1048+
ListModels: true,
1049+
},
1050+
Fallbacks: []schemas.Fallback{
1051+
{Provider: schemas.OpenAI, Model: "gpt-4o-mini"},
1052+
},
1053+
},
9981054
}

core/internal/testutil/responses_stream.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ func RunResponsesStreamTest(t *testing.T, client *bifrost.Bifrost, ctx context.C
690690
}
691691

692692
// Safety check to prevent infinite loops
693-
if responseCount > 100 {
693+
if responseCount > 300 {
694694
goto lifecycleComplete
695695
}
696696

Binary file not shown.
209 KB
Binary file not shown.
416 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)