Skip to content
Closed
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
337 changes: 332 additions & 5 deletions core/bifrost.go

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions core/providers/anthropic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bufio"
"context"
"fmt"
"io"
"net/http"
"strings"
"sync"
Expand Down Expand Up @@ -876,12 +877,14 @@ func handleAnthropicStreaming(

// Check for HTTP errors
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
return nil, &schemas.BifrostError{
IsBifrostError: false,
StatusCode: &resp.StatusCode,
Error: schemas.ErrorField{
Message: fmt.Sprintf("HTTP error from %s: %d", providerType, resp.StatusCode),
Error: fmt.Errorf("%s", string(body)),
},
}
}
Expand Down Expand Up @@ -1290,3 +1293,19 @@ func handleAnthropicStreaming(

return responseChan, nil
}

func (provider *AnthropicProvider) Speech(ctx context.Context, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech", "anthropic")
}

func (provider *AnthropicProvider) SpeechStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech stream", "anthropic")
}

func (provider *AnthropicProvider) Transcription(ctx context.Context, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription", "anthropic")
}

func (provider *AnthropicProvider) TranscriptionStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription stream", "anthropic")
}
16 changes: 16 additions & 0 deletions core/providers/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,19 @@ func (provider *AzureProvider) ChatCompletionStream(ctx context.Context, postHoo
provider.logger,
)
}

func (provider *AzureProvider) Speech(ctx context.Context, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech", "azure")
}

func (provider *AzureProvider) SpeechStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech stream", "azure")
}

func (provider *AzureProvider) Transcription(ctx context.Context, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription", "azure")
}

func (provider *AzureProvider) TranscriptionStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription stream", "azure")
}
18 changes: 18 additions & 0 deletions core/providers/bedrock.go
Original file line number Diff line number Diff line change
Expand Up @@ -1418,12 +1418,14 @@ func (provider *BedrockProvider) ChatCompletionStream(ctx context.Context, postH

// Check for HTTP errors
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
return nil, &schemas.BifrostError{
IsBifrostError: false,
StatusCode: &resp.StatusCode,
Error: schemas.ErrorField{
Message: fmt.Sprintf("HTTP error from Bedrock: %d", resp.StatusCode),
Error: fmt.Errorf("%s", string(body)),
},
}
}
Expand Down Expand Up @@ -1716,3 +1718,19 @@ func (provider *BedrockProvider) ChatCompletionStream(ctx context.Context, postH

return responseChan, nil
}

func (provider *BedrockProvider) Speech(ctx context.Context, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech", "bedrock")
}

func (provider *BedrockProvider) SpeechStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech stream", "bedrock")
}

func (provider *BedrockProvider) Transcription(ctx context.Context, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription", "bedrock")
}

func (provider *BedrockProvider) TranscriptionStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription stream", "bedrock")
}
19 changes: 19 additions & 0 deletions core/providers/cohere.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bufio"
"context"
"fmt"
"io"
"slices"
"strings"
"sync"
Expand Down Expand Up @@ -786,12 +787,14 @@ func (provider *CohereProvider) ChatCompletionStream(ctx context.Context, postHo

// Check for HTTP errors
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
return nil, &schemas.BifrostError{
IsBifrostError: false,
StatusCode: &resp.StatusCode,
Error: schemas.ErrorField{
Message: fmt.Sprintf("HTTP error from Cohere: %d", resp.StatusCode),
Error: fmt.Errorf("%s", string(body)),
},
}
}
Expand Down Expand Up @@ -1020,3 +1023,19 @@ func (provider *CohereProvider) ChatCompletionStream(ctx context.Context, postHo

return responseChan, nil
}

func (provider *CohereProvider) Speech(ctx context.Context, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech", "cohere")
}

func (provider *CohereProvider) SpeechStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech stream", "cohere")
}

func (provider *CohereProvider) Transcription(ctx context.Context, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription", "cohere")
}

func (provider *CohereProvider) TranscriptionStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription stream", "cohere")
}
16 changes: 16 additions & 0 deletions core/providers/groq.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,19 @@ func (provider *GroqProvider) ChatCompletionStream(ctx context.Context, postHook
provider.logger,
)
}

func (provider *GroqProvider) Speech(ctx context.Context, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech", "groq")
}

func (provider *GroqProvider) SpeechStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech stream", "groq")
}

func (provider *GroqProvider) Transcription(ctx context.Context, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription", "groq")
}

func (provider *GroqProvider) TranscriptionStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription stream", "groq")
}
16 changes: 16 additions & 0 deletions core/providers/mistral.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,19 @@ func (provider *MistralProvider) ChatCompletionStream(ctx context.Context, postH
provider.logger,
)
}

func (provider *MistralProvider) Speech(ctx context.Context, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech", "mistral")
}

func (provider *MistralProvider) SpeechStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech stream", "mistral")
}

func (provider *MistralProvider) Transcription(ctx context.Context, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription", "mistral")
}

func (provider *MistralProvider) TranscriptionStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription stream", "mistral")
}
16 changes: 16 additions & 0 deletions core/providers/ollama.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,19 @@ func (provider *OllamaProvider) ChatCompletionStream(ctx context.Context, postHo
provider.logger,
)
}

func (provider *OllamaProvider) Speech(ctx context.Context, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech", "ollama")
}

func (provider *OllamaProvider) SpeechStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.SpeechInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("speech stream", "ollama")
}

func (provider *OllamaProvider) Transcription(ctx context.Context, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (*schemas.BifrostResponse, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription", "ollama")
}

func (provider *OllamaProvider) TranscriptionStream(ctx context.Context, postHookRunner schemas.PostHookRunner, model string, key schemas.Key, input *schemas.TranscriptionInput, params *schemas.ModelParameters) (chan *schemas.BifrostStream, *schemas.BifrostError) {
return nil, newUnsupportedOperationError("transcription stream", "ollama")
}
Loading