Documentation
¶
Index ¶
- Variables
- func HandleHuggingFaceImageGenerationStreaming(ctx *schemas.BifrostContext, client *fasthttp.Client, url string, ...) (chan *schemas.BifrostStream, *schemas.BifrostError)
- func ToBifrostResponsesResponseFromHuggingFace(resp *schemas.BifrostChatResponse, requestedModel string) (*schemas.BifrostResponsesResponse, error)
- func ToHuggingFaceImageGenerationRequest(bifrostReq *schemas.BifrostImageGenerationRequest) (any, error)
- func UnmarshalHuggingFaceEmbeddingResponse(data []byte, model string) (*schemas.BifrostEmbeddingResponse, error)
- func UnmarshalHuggingFaceImageGenerationResponse(data []byte, model string) (*schemas.BifrostImageGenerationResponse, error)
- type EncodingType
- type EnumStringType
- type FalAIImage
- type FalAIImageData
- type FalAITimings
- type HuggingFaceChatRequest
- type HuggingFaceEarlyStoppingUnion
- type HuggingFaceEmbeddingRequest
- type HuggingFaceErrorDetail
- type HuggingFaceFalAIImageGenerationRequest
- type HuggingFaceFalAIImageGenerationResponse
- type HuggingFaceFalAIImageStreamRequest
- type HuggingFaceFalAIImageStreamResponse
- type HuggingFaceFalAISize
- type HuggingFaceGenerationParameters
- type HuggingFaceHFInferenceImageGenerationRequest
- type HuggingFaceHubError
- type HuggingFaceInferenceProviderInfo
- type HuggingFaceInferenceProviderMapping
- type HuggingFaceInferenceProviderMappingResponse
- type HuggingFaceJSONSchema
- type HuggingFaceListModelsResponse
- type HuggingFaceModel
- type HuggingFaceProvider
- func (provider *HuggingFaceProvider) BatchCancel(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostBatchCancelResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) BatchCreate(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostBatchCreateRequest) (*schemas.BifrostBatchCreateResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) BatchList(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchListRequest) (*schemas.BifrostBatchListResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) BatchResults(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostBatchResultsResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) BatchRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostBatchRetrieveResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) ChatCompletion(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostChatResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) ChatCompletionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStream, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) CountTokens(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostResponsesRequest) (*schemas.BifrostCountTokensResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) Embedding(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostEmbeddingResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) FileContent(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostFileContentResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) FileDelete(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostFileDeleteResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) FileList(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostFileListRequest) (*schemas.BifrostFileListResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) FileRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostFileRetrieveResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) FileUpload(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostFileUploadRequest) (*schemas.BifrostFileUploadResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) GetProviderKey() schemas.ModelProvider
- func (provider *HuggingFaceProvider) ImageGeneration(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) ImageGenerationStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStream, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) ListModels(ctx *schemas.BifrostContext, keys []schemas.Key, ...) (*schemas.BifrostListModelsResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) Responses(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostResponsesResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) ResponsesStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStream, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) Speech(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostSpeechResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) SpeechStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStream, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) TextCompletion(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostTextCompletionResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) TextCompletionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStream, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) Transcription(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostTranscriptionResponse, *schemas.BifrostError)
- func (provider *HuggingFaceProvider) TranscriptionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStream, *schemas.BifrostError)
- type HuggingFaceResponseError
- type HuggingFaceResponseFormat
- type HuggingFaceSpeechAudio
- type HuggingFaceSpeechParameters
- type HuggingFaceSpeechRequest
- type HuggingFaceSpeechResponse
- type HuggingFaceTogetherImageData
- type HuggingFaceTogetherImageGenerationRequest
- type HuggingFaceTogetherImageGenerationResponse
- type HuggingFaceTogetherTimings
- type HuggingFaceToolChoice
- type HuggingFaceTranscriptionEarlyStopping
- type HuggingFaceTranscriptionGenerationParameters
- type HuggingFaceTranscriptionRequest
- type HuggingFaceTranscriptionRequestParameters
- type HuggingFaceTranscriptionResponse
- type HuggingFaceTranscriptionResponseChunk
- type InputsCustomType
Constants ¶
This section is empty.
Variables ¶
var INFERENCE_PROVIDERS = []inferenceProvider{
cerebras,
cohere,
falAI,
featherlessAI,
fireworksAI,
groq,
hfInference,
hyperbolic,
nebius,
novita,
nscale,
ovhcloud,
publicai,
replicate,
sambanova,
scaleway,
together,
wavespeed,
zaiOrg,
}
List of supported inference providers (kept in sync with HF docs/JS SDK)
var PROVIDERS_OR_POLICIES = func() []inferenceProvider { out := make([]inferenceProvider, 0, len(INFERENCE_PROVIDERS)+1) out = append(out, INFERENCE_PROVIDERS...) out = append(out, "auto") return out }()
PROVIDERS_OR_POLICIES is the above list plus the special "auto" policy
Functions ¶
func HandleHuggingFaceImageGenerationStreaming ¶ added in v1.3.9
func HandleHuggingFaceImageGenerationStreaming( ctx *schemas.BifrostContext, client *fasthttp.Client, url string, request *schemas.BifrostImageGenerationRequest, authHeader map[string]string, extraHeaders map[string]string, sendBackRawRequest bool, sendBackRawResponse bool, providerName schemas.ModelProvider, postHookRunner schemas.PostHookRunner, logger schemas.Logger, ) (chan *schemas.BifrostStream, *schemas.BifrostError)
HandleHuggingFaceImageGenerationStreaming handles image generation streaming for fal-ai through HuggingFace router.
func ToBifrostResponsesResponseFromHuggingFace ¶
func ToBifrostResponsesResponseFromHuggingFace(resp *schemas.BifrostChatResponse, requestedModel string) (*schemas.BifrostResponsesResponse, error)
ToBifrostResponsesResponseFromHuggingFace converts a Bifrost chat response into the Bifrost Responses response shape, preserving provider metadata.
func ToHuggingFaceImageGenerationRequest ¶ added in v1.3.9
func ToHuggingFaceImageGenerationRequest(bifrostReq *schemas.BifrostImageGenerationRequest) (any, error)
ToHuggingFaceImageGenerationRequest converts a Bifrost image generation request to provider-specific format
func UnmarshalHuggingFaceEmbeddingResponse ¶
func UnmarshalHuggingFaceEmbeddingResponse(data []byte, model string) (*schemas.BifrostEmbeddingResponse, error)
UnmarshalHuggingFaceEmbeddingResponse unmarshals HuggingFace API response directly into BifrostEmbeddingResponse Handles multiple formats: standard object, 2D array, or 1D array
func UnmarshalHuggingFaceImageGenerationResponse ¶ added in v1.3.9
func UnmarshalHuggingFaceImageGenerationResponse(data []byte, model string) (*schemas.BifrostImageGenerationResponse, error)
UnmarshalHuggingFaceImageGenerationResponse unmarshals HuggingFace image generation response to Bifrost format
Types ¶
type EncodingType ¶
type EncodingType string
const ( EncodingTypeFloat EncodingType = "float" EncodingTypeBase64 EncodingType = "base64" )
type EnumStringType ¶
type EnumStringType string
const ( EnumStringTypeAuto EnumStringType = "auto" EnumStringTypeNone EnumStringType = "none" EnumStringTypeRequired EnumStringType = "required" )
type FalAIImage ¶ added in v1.3.9
type FalAIImageData ¶ added in v1.3.9
type FalAIImageData struct {
Images []FalAIImage `json:"images,omitempty"`
Timings *FalAITimings `json:"timings,omitempty"`
Seed *int64 `json:"seed,omitempty"`
HasNSFWConcepts []bool `json:"has_nsfw_concepts,omitempty"`
Prompt string `json:"prompt,omitempty"`
}
FalAIImageData wraps the image data in the API envelope
type FalAITimings ¶ added in v1.3.9
type FalAITimings struct {
Inference float64 `json:"inference"`
}
type HuggingFaceChatRequest ¶
type HuggingFaceChatRequest struct {
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
Logprobs *bool `json:"logprobs,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
Messages []schemas.ChatMessage `json:"messages"`
Model string `json:"model" validate:"required"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
ResponseFormat *HuggingFaceResponseFormat `json:"response_format,omitempty"`
Seed *int `json:"seed,omitempty"`
Stop []string `json:"stop,omitempty"`
Stream *bool `json:"stream,omitempty"`
StreamOptions *schemas.ChatStreamOptions `json:"stream_options,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
ToolChoice *HuggingFaceToolChoice `json:"tool_choice,omitempty"`
ToolPrompt *string `json:"tool_prompt,omitempty"`
Tools []schemas.ChatTool `json:"tools,omitempty"`
TopLogprobs *int `json:"top_logprobs,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
}
Flexible/chat request types for HuggingFace-like chat completion payloads.
func ToHuggingFaceChatCompletionRequest ¶
func ToHuggingFaceChatCompletionRequest(bifrostReq *schemas.BifrostChatRequest) (*HuggingFaceChatRequest, error)
func ToHuggingFaceResponsesRequest ¶
func ToHuggingFaceResponsesRequest(bifrostReq *schemas.BifrostResponsesRequest) (*HuggingFaceChatRequest, error)
ToHuggingFaceResponsesRequest converts a Bifrost Responses request into the Hugging Face chat-completions payload that the provider already understands.
type HuggingFaceEarlyStoppingUnion ¶
type HuggingFaceEarlyStoppingUnion = HuggingFaceTranscriptionEarlyStopping
type HuggingFaceEmbeddingRequest ¶
type HuggingFaceEmbeddingRequest struct {
Input *InputsCustomType `json:"input,omitempty"` // string or []string used by all inference providers other than hf-inference
Inputs *InputsCustomType `json:"inputs,omitempty"` // string or []string used by hf-inference provider
Provider *string `json:"provider,omitempty"` // used by all inference providers other than hf-inference
Model *string `json:"model,omitempty"` // used by all inference providers other than hf-inference
Normalize *bool `json:"normalize,omitempty"`
PromptName *string `json:"prompt_name,omitempty"`
Truncate *bool `json:"truncate,omitempty"`
TruncationDirection *string `json:"truncation_direction,omitempty"` // "left" or "right"
EncodingFormat *EncodingType `json:"encoding_format,omitempty"`
Dimensions *int `json:"dimensions,omitempty"`
}
HuggingFaceEmbeddingRequest represents the request format for HuggingFace embeddings API Based on the HuggingFace Router API specification
func ToHuggingFaceEmbeddingRequest ¶
func ToHuggingFaceEmbeddingRequest(bifrostReq *schemas.BifrostEmbeddingRequest) (*HuggingFaceEmbeddingRequest, error)
ToHuggingFaceEmbeddingRequest converts a Bifrost embedding request to HuggingFace format
type HuggingFaceErrorDetail ¶ added in v1.3.9
type HuggingFaceFalAIImageGenerationRequest ¶ added in v1.3.9
type HuggingFaceFalAIImageGenerationRequest struct {
Prompt string `json:"prompt"`
NumImages *int `json:"num_images,omitempty"`
ResponseFormat *string `json:"response_format,omitempty"`
ImageSize *HuggingFaceFalAISize `json:"image_size,omitempty"`
NegativePrompt *string `json:"negative_prompt,omitempty"`
GuidanceScale *float64 `json:"guidance_scale,omitempty"`
NumInferenceSteps *int `json:"num_inference_steps,omitempty"`
Seed *int `json:"seed,omitempty"`
OutputFormat *string `json:"output_format,omitempty"`
SyncMode *bool `json:"sync_mode,omitempty"`
EnableSafetyChecker *bool `json:"enable_safety_checker,omitempty"`
Acceleration *string `json:"acceleration,omitempty"`
EnablePromptExpansion *bool `json:"enable_prompt_expansion,omitempty"`
}
HuggingFaceFalAIImageGenerationRequest for fal-ai image generation
type HuggingFaceFalAIImageGenerationResponse ¶ added in v1.3.9
type HuggingFaceFalAIImageGenerationResponse struct {
RequestID string `json:"request_id,omitempty"`
Status string `json:"status,omitempty"`
CreatedAt *int64 `json:"created_at,omitempty"`
Data *FalAIImageData `json:"data,omitempty"`
// Legacy flattened fields for backward compatibility
Images []FalAIImage `json:"images,omitempty"`
Timings *FalAITimings `json:"timings,omitempty"`
Seed *int64 `json:"seed,omitempty"`
HasNSFWConcepts []bool `json:"has_nsfw_concepts,omitempty"`
Prompt string `json:"prompt,omitempty"`
}
HuggingFaceFalAIImageGenerationResponse for fal-ai image generation Matches the API envelope structure with top-level metadata and data array
type HuggingFaceFalAIImageStreamRequest ¶ added in v1.3.9
type HuggingFaceFalAIImageStreamRequest struct {
Prompt string `json:"prompt"`
ResponseFormat *string `json:"response_format,omitempty"`
NumImages *int `json:"num_images,omitempty"`
ImageSize *HuggingFaceFalAISize `json:"image_size,omitempty"`
GuidanceScale *float64 `json:"guidance_scale,omitempty"`
Seed *int `json:"seed,omitempty"`
NumInferenceSteps *int `json:"num_inference_steps,omitempty"`
Acceleration *string `json:"acceleration,omitempty"`
EnablePromptExpansion *bool `json:"enable_prompt_expansion,omitempty"`
SyncMode *bool `json:"sync_mode,omitempty"`
EnableSafetyChecker *bool `json:"enable_safety_checker,omitempty"`
OutputFormat *string `json:"output_format,omitempty"`
}
HuggingFaceFalAIImageStreamRequest for fal-ai image generation streaming
func ToHuggingFaceImageStreamRequest ¶ added in v1.3.9
func ToHuggingFaceImageStreamRequest(bifrostReq *schemas.BifrostImageGenerationRequest) (*HuggingFaceFalAIImageStreamRequest, error)
ToHuggingFaceImageStreamRequest converts a Bifrost image generation request to fal-ai streaming format
type HuggingFaceFalAIImageStreamResponse ¶ added in v1.3.9
type HuggingFaceFalAIImageStreamResponse struct {
Images []FalAIImage `json:"images"`
}
HuggingFaceFalAIImageStreamResponse for fal-ai SSE events
type HuggingFaceFalAISize ¶ added in v1.3.9
type HuggingFaceGenerationParameters ¶
type HuggingFaceGenerationParameters = HuggingFaceTranscriptionGenerationParameters
type HuggingFaceHFInferenceImageGenerationRequest ¶ added in v1.3.9
type HuggingFaceHFInferenceImageGenerationRequest struct {
Inputs string `json:"inputs"`
}
HuggingFaceHFInferenceImageGenerationRequest for hf-inference image generation
type HuggingFaceHubError ¶
type HuggingFaceInferenceProviderMappingResponse ¶
type HuggingFaceInferenceProviderMappingResponse struct {
ID string `json:"_id"`
ModelID string `json:"id"`
PipelineTag string `json:"pipeline_tag"`
InferenceProviderMapping map[string]HuggingFaceInferenceProviderInfo `json:"inferenceProviderMapping"`
}
type HuggingFaceJSONSchema ¶
type HuggingFaceJSONSchema struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Schema json.RawMessage `json:"schema,omitempty"`
Strict *bool `json:"strict,omitempty"`
}
type HuggingFaceListModelsResponse ¶
type HuggingFaceListModelsResponse struct {
Models []HuggingFaceModel `json:"models"`
}
func (*HuggingFaceListModelsResponse) ToBifrostListModelsResponse ¶
func (response *HuggingFaceListModelsResponse) ToBifrostListModelsResponse(providerKey schemas.ModelProvider, inferenceProvider inferenceProvider) *schemas.BifrostListModelsResponse
func (*HuggingFaceListModelsResponse) UnmarshalJSON ¶
func (r *HuggingFaceListModelsResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON supports both the older object form `{"models": [...]}` and the current API which returns a top-level JSON array `[...]`.
type HuggingFaceModel ¶
type HuggingFaceModel struct {
ID string `json:"_id"`
ModelID string `json:"modelId"`
Likes int `json:"likes"`
TrendingScore int `json:"trendingScore"`
Private bool `json:"private"`
Downloads int `json:"downloads"`
Tags []string `json:"tags"`
PipelineTag string `json:"pipeline_tag"`
LibraryName string `json:"library_name"`
CreatedAt string `json:"createdAt"`
}
refered from https://huggingface.co/api/models
type HuggingFaceProvider ¶
type HuggingFaceProvider struct {
// contains filtered or unexported fields
}
HuggingFaceProvider implements the Provider interface for Hugging Face's inference APIs.
func NewHuggingFaceProvider ¶
func NewHuggingFaceProvider(config *schemas.ProviderConfig, logger schemas.Logger) *HuggingFaceProvider
NewHuggingFaceProvider creates a new Hugging Face provider instance configured with the provided settings.
func (*HuggingFaceProvider) BatchCancel ¶
func (provider *HuggingFaceProvider) BatchCancel(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchCancelRequest) (*schemas.BifrostBatchCancelResponse, *schemas.BifrostError)
BatchCancel is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) BatchCreate ¶
func (provider *HuggingFaceProvider) BatchCreate(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostBatchCreateRequest) (*schemas.BifrostBatchCreateResponse, *schemas.BifrostError)
BatchCreate is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) BatchList ¶
func (provider *HuggingFaceProvider) BatchList(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchListRequest) (*schemas.BifrostBatchListResponse, *schemas.BifrostError)
BatchList is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) BatchResults ¶
func (provider *HuggingFaceProvider) BatchResults(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchResultsRequest) (*schemas.BifrostBatchResultsResponse, *schemas.BifrostError)
BatchResults is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) BatchRetrieve ¶
func (provider *HuggingFaceProvider) BatchRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchRetrieveRequest) (*schemas.BifrostBatchRetrieveResponse, *schemas.BifrostError)
BatchRetrieve is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) ChatCompletion ¶
func (provider *HuggingFaceProvider) ChatCompletion(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostChatRequest) (*schemas.BifrostChatResponse, *schemas.BifrostError)
func (*HuggingFaceProvider) ChatCompletionStream ¶
func (provider *HuggingFaceProvider) ChatCompletionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostChatRequest) (chan *schemas.BifrostStream, *schemas.BifrostError)
func (*HuggingFaceProvider) CountTokens ¶ added in v1.2.43
func (provider *HuggingFaceProvider) CountTokens(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostResponsesRequest) (*schemas.BifrostCountTokensResponse, *schemas.BifrostError)
CountTokens is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) Embedding ¶
func (provider *HuggingFaceProvider) Embedding(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostEmbeddingRequest) (*schemas.BifrostEmbeddingResponse, *schemas.BifrostError)
func (*HuggingFaceProvider) FileContent ¶
func (provider *HuggingFaceProvider) FileContent(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostFileContentRequest) (*schemas.BifrostFileContentResponse, *schemas.BifrostError)
FileContent is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) FileDelete ¶
func (provider *HuggingFaceProvider) FileDelete(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostFileDeleteRequest) (*schemas.BifrostFileDeleteResponse, *schemas.BifrostError)
FileDelete is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) FileList ¶
func (provider *HuggingFaceProvider) FileList(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostFileListRequest) (*schemas.BifrostFileListResponse, *schemas.BifrostError)
FileList is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) FileRetrieve ¶
func (provider *HuggingFaceProvider) FileRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostFileRetrieveRequest) (*schemas.BifrostFileRetrieveResponse, *schemas.BifrostError)
FileRetrieve is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) FileUpload ¶
func (provider *HuggingFaceProvider) FileUpload(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostFileUploadRequest) (*schemas.BifrostFileUploadResponse, *schemas.BifrostError)
FileUpload is not supported by the Hugging Face provider.
func (*HuggingFaceProvider) GetProviderKey ¶
func (provider *HuggingFaceProvider) GetProviderKey() schemas.ModelProvider
GetProviderKey returns the provider key, taking custom providers into account.
func (*HuggingFaceProvider) ImageGeneration ¶ added in v1.3.9
func (provider *HuggingFaceProvider) ImageGeneration(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostImageGenerationRequest) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
func (*HuggingFaceProvider) ImageGenerationStream ¶ added in v1.3.9
func (provider *HuggingFaceProvider) ImageGenerationStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostImageGenerationRequest) (chan *schemas.BifrostStream, *schemas.BifrostError)
ImageGenerationStream handles streaming for fal-ai image generation. Only fal-ai inference provider supports streaming for HuggingFace.
func (*HuggingFaceProvider) ListModels ¶
func (provider *HuggingFaceProvider) ListModels(ctx *schemas.BifrostContext, keys []schemas.Key, request *schemas.BifrostListModelsRequest) (*schemas.BifrostListModelsResponse, *schemas.BifrostError)
ListModels queries the Hugging Face model hub API to list models served by the inference provider.
func (*HuggingFaceProvider) Responses ¶
func (provider *HuggingFaceProvider) Responses(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostResponsesRequest) (*schemas.BifrostResponsesResponse, *schemas.BifrostError)
func (*HuggingFaceProvider) ResponsesStream ¶
func (provider *HuggingFaceProvider) ResponsesStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostResponsesRequest) (chan *schemas.BifrostStream, *schemas.BifrostError)
func (*HuggingFaceProvider) Speech ¶
func (provider *HuggingFaceProvider) Speech(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostSpeechRequest) (*schemas.BifrostSpeechResponse, *schemas.BifrostError)
func (*HuggingFaceProvider) SpeechStream ¶
func (provider *HuggingFaceProvider) SpeechStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostSpeechRequest) (chan *schemas.BifrostStream, *schemas.BifrostError)
func (*HuggingFaceProvider) TextCompletion ¶
func (provider *HuggingFaceProvider) TextCompletion(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostTextCompletionRequest) (*schemas.BifrostTextCompletionResponse, *schemas.BifrostError)
func (*HuggingFaceProvider) TextCompletionStream ¶
func (provider *HuggingFaceProvider) TextCompletionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostTextCompletionRequest) (chan *schemas.BifrostStream, *schemas.BifrostError)
func (*HuggingFaceProvider) Transcription ¶
func (provider *HuggingFaceProvider) Transcription(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostTranscriptionRequest) (*schemas.BifrostTranscriptionResponse, *schemas.BifrostError)
func (*HuggingFaceProvider) TranscriptionStream ¶
func (provider *HuggingFaceProvider) TranscriptionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostTranscriptionRequest) (chan *schemas.BifrostStream, *schemas.BifrostError)
TranscriptionStream is not supported by the Hugging Face provider.
type HuggingFaceResponseError ¶
type HuggingFaceResponseError struct {
Error string `json:"error"`
Type string `json:"type"`
Message string `json:"message"`
Detail []HuggingFaceErrorDetail `json:"detail,omitempty"` // FastAPI validation errors
}
type HuggingFaceResponseFormat ¶
type HuggingFaceResponseFormat struct {
Type string `json:"type"`
JSONSchema *HuggingFaceJSONSchema `json:"json_schema,omitempty"`
}
type HuggingFaceSpeechAudio ¶
type HuggingFaceSpeechAudio struct {
URL string `json:"url"`
ContentType string `json:"content_type"`
FileName string `json:"file_name"`
FileSize int `json:"file_size"`
}
HuggingFaceSpeechAudio represents the audio object in the speech response
type HuggingFaceSpeechParameters ¶
type HuggingFaceSpeechParameters struct {
GenerationParameters *HuggingFaceTranscriptionGenerationParameters `json:"generation_parameters,omitempty"`
}
Speech parameters are additional inference parameters for Text To Speech
type HuggingFaceSpeechRequest ¶
type HuggingFaceSpeechRequest struct {
Text string `json:"text"`
Provider string `json:"provider" validate:"required"`
Model string `json:"model" validate:"required"`
Parameters *HuggingFaceSpeechParameters `json:"parameters,omitempty"`
Extra map[string]any `json:"-"`
}
Speech request represents the inputs for Text To Speech inference.
func ToHuggingFaceSpeechRequest ¶
func ToHuggingFaceSpeechRequest(request *schemas.BifrostSpeechRequest) (*HuggingFaceSpeechRequest, error)
type HuggingFaceSpeechResponse ¶
type HuggingFaceSpeechResponse struct {
Audio HuggingFaceSpeechAudio `json:"audio"`
}
Speech response represents the outputs of inference for the Text To Speech task.
func (*HuggingFaceSpeechResponse) ToBifrostSpeechResponse ¶
func (response *HuggingFaceSpeechResponse) ToBifrostSpeechResponse(requestedModel string, audioData []byte) (*schemas.BifrostSpeechResponse, error)
type HuggingFaceTogetherImageData ¶ added in v1.3.9
type HuggingFaceTogetherImageData struct {
B64JSON string `json:"b64_json,omitempty"`
URL string `json:"url,omitempty"`
Index int `json:"index"`
Timings *HuggingFaceTogetherTimings `json:"timings,omitempty"`
}
type HuggingFaceTogetherImageGenerationRequest ¶ added in v1.3.9
type HuggingFaceTogetherImageGenerationRequest struct {
Prompt string `json:"prompt"`
Model string `json:"model"`
ResponseFormat *string `json:"response_format,omitempty"`
Size *string `json:"size,omitempty"`
Width *int `json:"width,omitempty"`
Height *int `json:"height,omitempty"`
N *int `json:"n,omitempty"`
Steps *int `json:"steps,omitempty"`
}
HuggingFaceTogetherImageGenerationRequest for together image generation
type HuggingFaceTogetherImageGenerationResponse ¶ added in v1.3.9
type HuggingFaceTogetherImageGenerationResponse struct {
ID string `json:"id"`
Model string `json:"model"`
Object string `json:"object"`
Data []HuggingFaceTogetherImageData `json:"data"`
}
HuggingFaceTogetherImageGenerationResponse for together image generation
type HuggingFaceTogetherTimings ¶ added in v1.3.9
type HuggingFaceTogetherTimings struct {
Inference float64 `json:"inference"`
}
type HuggingFaceToolChoice ¶
type HuggingFaceToolChoice struct {
EnumValue *EnumStringType
// Function holds the function object when the field is a JSON object.
Function *schemas.ChatToolChoiceFunction
}
HuggingFaceToolChoice represents the flexible `tool_choice` field which can be either one of the enum strings: "auto", "none", "required", or an object with a `function` sub-object containing a required `name`.
func (HuggingFaceToolChoice) MarshalJSON ¶
func (t HuggingFaceToolChoice) MarshalJSON() ([]byte, error)
MarshalJSON will emit either a JSON string for enum values or an object containing the `function` key and `type` field.
type HuggingFaceTranscriptionEarlyStopping ¶
HuggingFaceTranscriptionEarlyStopping controls the stopping condition for beam-based methods Can be a boolean or the string "never"
func (HuggingFaceTranscriptionEarlyStopping) MarshalJSON ¶
func (e HuggingFaceTranscriptionEarlyStopping) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for HuggingFaceTranscriptionEarlyStopping
func (*HuggingFaceTranscriptionEarlyStopping) UnmarshalJSON ¶
func (e *HuggingFaceTranscriptionEarlyStopping) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for HuggingFaceTranscriptionEarlyStopping
type HuggingFaceTranscriptionGenerationParameters ¶
type HuggingFaceTranscriptionGenerationParameters struct {
DoSample *bool `json:"do_sample,omitempty"`
EarlyStopping *HuggingFaceTranscriptionEarlyStopping `json:"early_stopping,omitempty"`
EpsilonCutoff *float64 `json:"epsilon_cutoff,omitempty"`
EtaCutoff *float64 `json:"eta_cutoff,omitempty"`
MaxLength *int `json:"max_length,omitempty"`
MaxNewTokens *int `json:"max_new_tokens,omitempty"`
MinLength *int `json:"min_length,omitempty"`
MinNewTokens *int `json:"min_new_tokens,omitempty"`
NumBeamGroups *int `json:"num_beam_groups,omitempty"`
NumBeams *int `json:"num_beams,omitempty"`
PenaltyAlpha *float64 `json:"penalty_alpha,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopK *int `json:"top_k,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
TypicalP *float64 `json:"typical_p,omitempty"`
UseCache *bool `json:"use_cache,omitempty"`
}
HuggingFaceTranscriptionGenerationParameters contains parametrization of the text generation process
type HuggingFaceTranscriptionRequest ¶
type HuggingFaceTranscriptionRequest struct {
Inputs []byte `json:"inputs,omitempty"` // raw audio bytes
AudioURL string `json:"audio_url,omitempty"` // URL to audio file only needed for fal ai
Provider *string `json:"provider,omitempty"`
Model *string `json:"model,omitempty"`
Parameters *HuggingFaceTranscriptionRequestParameters `json:"parameters,omitempty"`
}
HuggingFaceTranscriptionRequest represents the request for Automatic Speech Recognition inference
func ToHuggingFaceTranscriptionRequest ¶
func ToHuggingFaceTranscriptionRequest(request *schemas.BifrostTranscriptionRequest) (*HuggingFaceTranscriptionRequest, error)
type HuggingFaceTranscriptionRequestParameters ¶
type HuggingFaceTranscriptionRequestParameters struct {
GenerationParameters *HuggingFaceTranscriptionGenerationParameters `json:"generation_parameters,omitempty"`
ReturnTimestamps *bool `json:"return_timestamps,omitempty"`
}
HuggingFaceTranscriptionRequestParameters contains additional inference parameters for Automatic Speech Recognition
type HuggingFaceTranscriptionResponse ¶
type HuggingFaceTranscriptionResponse struct {
Text string `json:"text"`
Chunks []HuggingFaceTranscriptionResponseChunk `json:"chunks,omitempty"`
}
HuggingFaceTranscriptionResponse represents the output of Automatic Speech Recognition inference
func (*HuggingFaceTranscriptionResponse) ToBifrostTranscriptionResponse ¶
func (response *HuggingFaceTranscriptionResponse) ToBifrostTranscriptionResponse(requestedModel string) (*schemas.BifrostTranscriptionResponse, error)
type HuggingFaceTranscriptionResponseChunk ¶
type HuggingFaceTranscriptionResponseChunk struct {
Text string `json:"text"`
Timestamp []float64 `json:"timestamp"`
}
HuggingFaceTranscriptionResponseChunk represents an audio chunk identified by the model
type InputsCustomType ¶
type InputsCustomType struct {
Texts []string `json:"texts,omitempty"`
Text *string `json:"text,omitempty"`
}
func (InputsCustomType) MarshalJSON ¶
func (i InputsCustomType) MarshalJSON() ([]byte, error)
func (*InputsCustomType) UnmarshalJSON ¶
func (i *InputsCustomType) UnmarshalJSON(data []byte) error