huggingface

package
v1.3.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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)

View Source
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 FalAIImage struct {
	URL         string `json:"url,omitempty"`
	B64JSON     string `json:"b64_json,omitempty"`
	Width       int    `json:"width,omitempty"`
	Height      int    `json:"height,omitempty"`
	ContentType string `json:"content_type,omitempty"`
}

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 HuggingFaceErrorDetail struct {
	Loc  []interface{}          `json:"loc"`
	Msg  string                 `json:"msg"`
	Type string                 `json:"type"`
	Ctx  map[string]interface{} `json:"ctx,omitempty"`
}

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 HuggingFaceFalAISize struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

type HuggingFaceHFInferenceImageGenerationRequest added in v1.3.9

type HuggingFaceHFInferenceImageGenerationRequest struct {
	Inputs string `json:"inputs"`
}

HuggingFaceHFInferenceImageGenerationRequest for hf-inference image generation

type HuggingFaceHubError

type HuggingFaceHubError struct {
	Error   string `json:"error"`
	Message string `json:"message"`
}

type HuggingFaceInferenceProviderInfo

type HuggingFaceInferenceProviderInfo struct {
	Status          string `json:"status"`
	ProviderModelID string `json:"providerId"`
	Task            string `json:"task"`
	IsModelAuthor   bool   `json:"isModelAuthor"`
}

type HuggingFaceInferenceProviderMapping

type HuggingFaceInferenceProviderMapping struct {
	ProviderTask    string
	ProviderModelID string
}

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

BatchCancel is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) BatchCreate

BatchCreate is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) BatchList

BatchList is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) BatchResults

BatchResults is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) BatchRetrieve

BatchRetrieve is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) ChatCompletion

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

CountTokens is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) Embedding

func (*HuggingFaceProvider) FileContent

FileContent is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) FileDelete

FileDelete is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) FileList

FileList is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) FileRetrieve

FileRetrieve is not supported by the Hugging Face provider.

func (*HuggingFaceProvider) FileUpload

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 (*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

ListModels queries the Hugging Face model hub API to list models served by the inference provider.

func (*HuggingFaceProvider) Responses

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 (*HuggingFaceProvider) SpeechStream

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) 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

type HuggingFaceTranscriptionEarlyStopping struct {
	BoolValue   *bool
	StringValue *string
}

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL