Documentation
¶
Overview ¶
Package providers implements various LLM providers and their utility functions. This file contains the replicate provider implementation.
Index ¶
- func ParseReplicateTimestamp(timestamp string) int64
- func ToBifrostFileStatus(fileResp *ReplicateFileResponse) schemas.FileStatus
- func ToBifrostImageGenerationResponse(prediction *ReplicatePredictionResponse) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
- func ToBifrostListModelsResponse(deploymentsResponse *ReplicateDeploymentListResponse, ...) *schemas.BifrostListModelsResponse
- func ToBifrostPredictionStatus(status ReplicatePredictionStatus) string
- type ReplicateDeployment
- type ReplicateDeploymentConfiguration
- type ReplicateDeploymentListResponse
- type ReplicateDeploymentOwner
- type ReplicateDeploymentRelease
- type ReplicateDoneEvent
- type ReplicateError
- type ReplicateErrorEvent
- type ReplicateFileChecksum
- type ReplicateFileListResponse
- type ReplicateFileResponse
- func (r *ReplicateFileResponse) ToBifrostFileRetrieveResponse(providerName schemas.ModelProvider, latency time.Duration, ...) *schemas.BifrostFileRetrieveResponse
- func (r *ReplicateFileResponse) ToBifrostFileUploadResponse(providerName schemas.ModelProvider, latency time.Duration, ...) *schemas.BifrostFileUploadResponse
- type ReplicateFileURLs
- type ReplicateMetrics
- type ReplicateModelListRequest
- type ReplicateModelListResponse
- type ReplicateModelResponse
- type ReplicateModelVersion
- type ReplicateOutput
- type ReplicateOutputText
- type ReplicatePredictionListResponse
- type ReplicatePredictionRequest
- func ToReplicateChatRequest(bifrostReq *schemas.BifrostChatRequest) (*ReplicatePredictionRequest, error)
- func ToReplicateImageEditInput(bifrostReq *schemas.BifrostImageEditRequest) *ReplicatePredictionRequest
- func ToReplicateImageGenerationInput(bifrostReq *schemas.BifrostImageGenerationRequest) *ReplicatePredictionRequest
- func ToReplicateResponsesRequest(bifrostReq *schemas.BifrostResponsesRequest) (*ReplicatePredictionRequest, error)
- func ToReplicateTextRequest(bifrostReq *schemas.BifrostTextCompletionRequest) (*ReplicatePredictionRequest, error)
- type ReplicatePredictionRequestInput
- type ReplicatePredictionResponse
- func (response *ReplicatePredictionResponse) ToBifrostChatResponse() *schemas.BifrostChatResponse
- func (response *ReplicatePredictionResponse) ToBifrostResponsesResponse() *schemas.BifrostResponsesResponse
- func (response *ReplicatePredictionResponse) ToBifrostTextCompletionResponse() *schemas.BifrostTextCompletionResponse
- type ReplicatePredictionStatus
- type ReplicatePredictionURLs
- type ReplicateProvider
- func (provider *ReplicateProvider) BatchCancel(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostBatchCancelResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) BatchCreate(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostBatchCreateRequest) (*schemas.BifrostBatchCreateResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) BatchList(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchListRequest) (*schemas.BifrostBatchListResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) BatchResults(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostBatchResultsResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) BatchRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostBatchRetrieveResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ChatCompletion(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostChatResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ChatCompletionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
- func (provider *ReplicateProvider) ContainerCreate(_ *schemas.BifrostContext, _ schemas.Key, ...) (*schemas.BifrostContainerCreateResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ContainerDelete(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostContainerDeleteResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ContainerFileContent(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostContainerFileContentResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ContainerFileCreate(_ *schemas.BifrostContext, _ schemas.Key, ...) (*schemas.BifrostContainerFileCreateResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ContainerFileDelete(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostContainerFileDeleteResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ContainerFileList(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostContainerFileListResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ContainerFileRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostContainerFileRetrieveResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ContainerList(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostContainerListResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ContainerRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, ...) (*schemas.BifrostContainerRetrieveResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) CountTokens(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostResponsesRequest) (*schemas.BifrostCountTokensResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) Embedding(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostEmbeddingResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) FileContent(ctx *schemas.BifrostContext, keys []schemas.Key, ...) (*schemas.BifrostFileContentResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) FileDelete(ctx *schemas.BifrostContext, keys []schemas.Key, ...) (*schemas.BifrostFileDeleteResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) FileList(ctx *schemas.BifrostContext, keys []schemas.Key, ...) (*schemas.BifrostFileListResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) FileRetrieve(ctx *schemas.BifrostContext, keys []schemas.Key, ...) (*schemas.BifrostFileRetrieveResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) FileUpload(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostFileUploadResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) GetProviderKey() schemas.ModelProvider
- func (provider *ReplicateProvider) ImageEdit(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ImageEditStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
- func (provider *ReplicateProvider) ImageGeneration(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ImageGenerationStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
- func (provider *ReplicateProvider) ImageVariation(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ListModels(ctx *schemas.BifrostContext, keys []schemas.Key, ...) (*schemas.BifrostListModelsResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) Responses(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostResponsesResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) ResponsesStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
- func (provider *ReplicateProvider) Speech(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostSpeechResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) SpeechStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
- func (provider *ReplicateProvider) TextCompletion(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostTextCompletionResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) TextCompletionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
- func (provider *ReplicateProvider) Transcription(ctx *schemas.BifrostContext, key schemas.Key, ...) (*schemas.BifrostTranscriptionResponse, *schemas.BifrostError)
- func (provider *ReplicateProvider) TranscriptionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, ...) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
- type ReplicateSSEEvent
- type ReplicateStreamEvent
- type ReplicateWebhookPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseReplicateTimestamp ¶
ParseReplicateTimestamp parses a Replicate ISO 8601 timestamp to Unix timestamp
func ToBifrostFileStatus ¶
func ToBifrostFileStatus(fileResp *ReplicateFileResponse) schemas.FileStatus
ToBifrostFileStatus converts Replicate file status to Bifrost file status. Replicate doesn't explicitly provide status, so we infer from the response.
func ToBifrostImageGenerationResponse ¶
func ToBifrostImageGenerationResponse( prediction *ReplicatePredictionResponse, ) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
ToBifrostImageGenerationResponse converts a Replicate prediction response to Bifrost format
func ToBifrostListModelsResponse ¶
func ToBifrostListModelsResponse( deploymentsResponse *ReplicateDeploymentListResponse, providerKey schemas.ModelProvider, ) *schemas.BifrostListModelsResponse
ToBifrostListModelsResponse converts Replicate models and deployments to a Bifrost list models response
func ToBifrostPredictionStatus ¶
func ToBifrostPredictionStatus(status ReplicatePredictionStatus) string
ToBifrostPredictionStatus converts Replicate status to Bifrost status
Types ¶
type ReplicateDeployment ¶
type ReplicateDeployment struct {
Owner string `json:"owner"` // Owner username or org name
Name string `json:"name"` // Deployment name
CurrentRelease *ReplicateDeploymentRelease `json:"current_release"` // Current active release
}
ReplicateDeployment represents a deployment
type ReplicateDeploymentConfiguration ¶
type ReplicateDeploymentConfiguration struct {
Hardware string `json:"hardware"` // Hardware type (e.g., "gpu-t4")
MinInstances int `json:"min_instances"` // Minimum number of instances
MaxInstances int `json:"max_instances"` // Maximum number of instances
}
ReplicateDeploymentConfiguration represents the deployment configuration
type ReplicateDeploymentListResponse ¶
type ReplicateDeploymentListResponse struct {
Next *string `json:"next"` // URL for next page
Previous *string `json:"previous"` // URL for previous page
Results []ReplicateDeployment `json:"results"` // List of deployments
}
ReplicateDeploymentListResponse represents a paginated list of deployments
type ReplicateDeploymentOwner ¶
type ReplicateDeploymentOwner struct {
Type string `json:"type"` // "user" or "organization"
Username string `json:"username"` // Username or organization name
Name *string `json:"name,omitempty"` // Display name
AvatarURL *string `json:"avatar_url,omitempty"` // Avatar URL
GithubURL *string `json:"github_url,omitempty"` // GitHub URL
}
ReplicateDeploymentOwner represents the owner of a deployment
type ReplicateDeploymentRelease ¶
type ReplicateDeploymentRelease struct {
Number int `json:"number"` // Release number
Model string `json:"model"` // Model identifier (owner/name)
Version string `json:"version"` // Model version ID
CreatedAt string `json:"created_at"` // ISO 8601 timestamp
CreatedBy *ReplicateDeploymentOwner `json:"created_by"` // User or organization that created the release
Configuration *ReplicateDeploymentConfiguration `json:"configuration"` // Deployment configuration
}
ReplicateDeploymentRelease represents a deployment release
type ReplicateDoneEvent ¶
type ReplicateDoneEvent struct {
Reason string `json:"reason,omitempty"` // Reason for completion: "canceled", "error", or empty for success
Output interface{} `json:"output,omitempty"` // Output data if available (e.g., error message)
}
ReplicateDoneEvent represents the data payload of a "done" event
type ReplicateError ¶
type ReplicateError struct {
Detail string `json:"detail"` // Error message
Status int `json:"status"` // HTTP status code
Title *string `json:"title,omitempty"` // Error title
Type *string `json:"type,omitempty"` // Error type
}
ReplicateError represents an error response from the Replicate API
type ReplicateErrorEvent ¶
type ReplicateErrorEvent struct {
Detail string `json:"detail"` // Error message
}
ReplicateErrorEvent represents the data payload of an "error" event
type ReplicateFileChecksum ¶
type ReplicateFileChecksum struct {
SHA256 string `json:"sha256,omitempty"` // SHA256 checksum
}
ReplicateFileChecksum represents checksums for a file
type ReplicateFileListResponse ¶
type ReplicateFileListResponse struct {
Next *string `json:"next,omitempty"` // URL for next page
Previous *string `json:"previous,omitempty"` // URL for previous page
Results []ReplicateFileResponse `json:"results"` // List of files
}
ReplicateFileListResponse represents a paginated list of files
type ReplicateFileResponse ¶
type ReplicateFileResponse struct {
ID string `json:"id"` // Unique file identifier
Checksums *ReplicateFileChecksum `json:"checksums,omitempty"` // File checksums
ContentType string `json:"content_type"` // MIME type
CreatedAt string `json:"created_at"` // ISO 8601 timestamp
ExpiresAt string `json:"expires_at,omitempty"` // ISO 8601 timestamp
Metadata map[string]interface{} `json:"metadata,omitempty"` // User-provided metadata
Name string `json:"name,omitempty"` // File name
Size int64 `json:"size"` // File size in bytes
URLs *ReplicateFileURLs `json:"urls,omitempty"` // Associated URLs
}
ReplicateFileResponse represents a file resource from Replicate API
func (*ReplicateFileResponse) ToBifrostFileRetrieveResponse ¶
func (r *ReplicateFileResponse) ToBifrostFileRetrieveResponse(providerName schemas.ModelProvider, latency time.Duration, sendBackRawRequest bool, sendBackRawResponse bool, rawRequest interface{}, rawResponse interface{}) *schemas.BifrostFileRetrieveResponse
ToBifrostFileRetrieveResponse converts Replicate file response to Bifrost file retrieve response.
func (*ReplicateFileResponse) ToBifrostFileUploadResponse ¶
func (r *ReplicateFileResponse) ToBifrostFileUploadResponse(providerName schemas.ModelProvider, latency time.Duration, sendBackRawRequest bool, sendBackRawResponse bool, rawRequest interface{}, rawResponse interface{}) *schemas.BifrostFileUploadResponse
ToBifrostFileUploadResponse converts Replicate file response to Bifrost file upload response.
type ReplicateFileURLs ¶
type ReplicateFileURLs struct {
Get string `json:"get"` // URL to retrieve file metadata
}
ReplicateFileURLs represents URLs associated with a file
type ReplicateMetrics ¶
type ReplicateMetrics struct {
PredictTime *float64 `json:"predict_time,omitempty"` // Time spent in prediction (seconds)
TotalTime *float64 `json:"total_time,omitempty"` // Total time including queue (seconds)
ImageCount *int `json:"image_count,omitempty"` // Number of images generated
TimeToFirstToken *float64 `json:"time_to_first_token,omitempty"` // Time to first token (seconds)
TokensPerSecond *float64 `json:"tokens_per_second,omitempty"` // Tokens generated per second
}
ReplicateMetrics represents execution metrics
type ReplicateModelListRequest ¶
type ReplicateModelListRequest struct {
Query *string `json:"query,omitempty"` // Search query
Limit *int `json:"limit,omitempty"` // Maximum results (1-50, default 20)
}
ReplicateModelListRequest represents a request to list/search models
type ReplicateModelListResponse ¶
type ReplicateModelListResponse struct {
Next *string `json:"next"` // URL for next page
Previous *string `json:"previous"` // URL for previous page
Results []ReplicateModelResponse `json:"results"` // List of models
}
ReplicateModelListResponse represents a paginated list of models
func ToReplicateListModelsResponse ¶
func ToReplicateListModelsResponse(response *schemas.BifrostListModelsResponse) *ReplicateModelListResponse
ToReplicateListModelsResponse converts a Bifrost list models response to a Replicate list models response This is mainly used for testing and compatibility
type ReplicateModelResponse ¶
type ReplicateModelResponse struct {
URL string `json:"url"` // Model API URL
Owner string `json:"owner"` // Owner username or org name
Name string `json:"name"` // Model name
Description *string `json:"description,omitempty"` // Model description
Visibility string `json:"visibility"` // "public" or "private"
GithubURL *string `json:"github_url,omitempty"` // GitHub repository URL
PaperURL *string `json:"paper_url,omitempty"` // Research paper URL
LicenseURL *string `json:"license_url,omitempty"` // License URL
RunCount *int `json:"run_count,omitempty"` // Number of times run
CoverImageURL *string `json:"cover_image_url,omitempty"` // Cover image URL
DefaultExample *map[string]interface{} `json:"default_example,omitempty"` // Default example prediction
LatestVersion *ReplicateModelVersion `json:"latest_version,omitempty"` // Latest version details
FeaturedVersion *ReplicateModelVersion `json:"featured_version,omitempty"` // Featured version details
}
ReplicateModelResponse represents a model response
type ReplicateModelVersion ¶
type ReplicateModelVersion struct {
ID string `json:"id"` // Version ID
CreatedAt string `json:"created_at"` // ISO 8601 timestamp
CogVersion *string `json:"cog_version,omitempty"` // Cog version used
OpenAPISchema map[string]interface{} `json:"openapi_schema,omitempty"` // OpenAPI schema for the model
DockerImageID *string `json:"docker_image_id,omitempty"` // Docker image ID
}
ReplicateModelVersion represents a model version
type ReplicateOutput ¶
type ReplicateOutput struct {
OutputStr *string
OutputArray []string
OutputObject *ReplicateOutputText
}
func (ReplicateOutput) MarshalJSON ¶
func (mc ReplicateOutput) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshalling for ReplicateOutput. It marshals either OutputStr, OutputArray, or OutputObject directly without wrapping.
func (*ReplicateOutput) UnmarshalJSON ¶
func (mc *ReplicateOutput) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshalling for ReplicateOutput. It determines whether "content" is a string, array, or object and assigns to the appropriate field.
type ReplicateOutputText ¶
type ReplicatePredictionListResponse ¶
type ReplicatePredictionListResponse struct {
Next *string `json:"next"` // URL for next page
Previous *string `json:"previous"` // URL for previous page
Results []ReplicatePredictionResponse `json:"results"` // List of predictions
}
ReplicatePredictionListResponse represents a paginated list of predictions
type ReplicatePredictionRequest ¶
type ReplicatePredictionRequest struct {
Version *string `json:"version,omitempty"` // Required: Model version ID
Input *ReplicatePredictionRequestInput `json:"input"` // Required: Input parameters for the model
Stream *bool `json:"stream,omitempty"` // Enable streaming output
Webhook *string `json:"webhook,omitempty"` // Webhook URL for notifications
WebhookEventsFilter []string `json:"webhook_events_filter,omitempty"` // Filter webhook events: start, output, logs, completed
OutputFileURLPrefix *string `json:"output_file_url_prefix,omitempty"` // Custom prefix for output file URLs
PollTimeout *int `json:"poll_timeout,omitempty"` // Timeout in seconds for polling (used with Prefer: wait header)
UseFileOutput *bool `json:"use_file_output,omitempty"` // Output files as URLs instead of data URIs
ExtraParams map[string]interface{} `json:"-"` // Extra parameters to merge into the request
}
ReplicatePredictionRequest represents a request to create a prediction
func ToReplicateChatRequest ¶
func ToReplicateChatRequest(bifrostReq *schemas.BifrostChatRequest) (*ReplicatePredictionRequest, error)
func ToReplicateImageEditInput ¶
func ToReplicateImageEditInput(bifrostReq *schemas.BifrostImageEditRequest) *ReplicatePredictionRequest
ToReplicateImageEditInput converts a Bifrost image edit request to Replicate prediction input
func ToReplicateImageGenerationInput ¶
func ToReplicateImageGenerationInput(bifrostReq *schemas.BifrostImageGenerationRequest) *ReplicatePredictionRequest
ToReplicateImageGenerationInput converts a Bifrost image generation request to Replicate prediction input
func ToReplicateResponsesRequest ¶
func ToReplicateResponsesRequest(bifrostReq *schemas.BifrostResponsesRequest) (*ReplicatePredictionRequest, error)
func ToReplicateTextRequest ¶
func ToReplicateTextRequest(bifrostReq *schemas.BifrostTextCompletionRequest) (*ReplicatePredictionRequest, error)
func (*ReplicatePredictionRequest) GetExtraParams ¶
func (req *ReplicatePredictionRequest) GetExtraParams() map[string]interface{}
GetExtraParams implements the RequestBodyWithExtraParams interface
type ReplicatePredictionRequestInput ¶
type ReplicatePredictionRequestInput struct {
Prompt *string `json:"prompt,omitempty"`
Messages []schemas.ChatMessage `json:"messages,omitempty"`
SystemPrompt *string `json:"system_prompt,omitempty"`
Image *string `json:"image,omitempty"` // URL or data URI
NumberOfImages *int `json:"number_of_images,omitempty"` // Number of images to generate
Quality *string `json:"quality,omitempty"` // Quality of the image
Background *string `json:"background,omitempty"` // Background of the image
Seed *int `json:"seed,omitempty"` // Random seed
ReasoningEffort *string `json:"reasoning_effort,omitempty"` // Reasoning effort
NumInferenceStep *int `json:"num_inference_steps,omitempty"` // Number of inference steps
NegativePrompt *string `json:"negative_prompt,omitempty"` // Negative prompt
// Responses parameters
Instructions *string `json:"instructions,omitempty"`
InputItemList []schemas.ResponsesMessage `json:"input_item_list,omitempty"`
Tools []schemas.ResponsesTool `json:"tools,omitempty"`
MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
JsonSchema *schemas.ResponsesTextConfig `json:"json_schema,omitempty"`
// Chat parameters
Temperature *float64 `json:"temperature,omitempty"` // Temperature for sampling
TopP *float64 `json:"top_p,omitempty"` // Top-p sampling
TopK *int `json:"top_k,omitempty"` // Top-k sampling
MaxTokens *int `json:"max_tokens,omitempty"` // Maximum tokens to generate
MaxCompletionTokens *int `json:"max_completion_tokens,omitempty"` // Maximum completion tokens to generate
PresencePenalty *float64 `json:"presence_penalty,omitempty"` // Presence penalty
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"` // Frequency penalty
// Image generation parameters
AspectRatio *string `json:"aspect_ratio,omitempty"`
OutputFormat *string `json:"output_format,omitempty"`
Resolution *string `json:"resolution,omitempty"` // e.g., "1 MP"
InputImages []string `json:"input_images,omitempty"` // Image input for image-to-image models
ImagePrompt *string `json:"image_prompt,omitempty"` // Image prompt for image models (flux family)
ImageInput []string `json:"image_input,omitempty"` // Image input for chat models (openai family)
InputImage *string `json:"input_image,omitempty"` // Image input for image-to-image models
ExtraParams map[string]interface{} `json:"-"` // Additional model-specific parameters
}
ReplicatePredictionRequestInput represents the input parameters for a model prediction This is flexible to support different model types - exact fields depend on the model
func (*ReplicatePredictionRequestInput) MarshalJSON ¶
func (r *ReplicatePredictionRequestInput) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshalling for ReplicatePredictionRequestInput. It marshals all defined fields and then flattens ExtraParams at the top level.
func (*ReplicatePredictionRequestInput) UnmarshalJSON ¶
func (r *ReplicatePredictionRequestInput) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshalling for ReplicatePredictionRequestInput. It unmarshals known fields and captures any unrecognized fields in ExtraParams.
type ReplicatePredictionResponse ¶
type ReplicatePredictionResponse struct {
ID string `json:"id"`
Model string `json:"model"` // Model identifier (owner/name or owner/name:version)
Version string `json:"version"` // Model version ID
Input map[string]interface{} `json:"input"` // Input parameters used
Output *ReplicateOutput `json:"output,omitempty"` // Output data (can be various types)
Logs *string `json:"logs,omitempty"` // Execution logs
Error *string `json:"error,omitempty"` // Error message if failed
Status ReplicatePredictionStatus `json:"status"` // Current status
CreatedAt string `json:"created_at"` // ISO 8601 timestamp
StartedAt *string `json:"started_at,omitempty"` // ISO 8601 timestamp
CompletedAt *string `json:"completed_at,omitempty"` // ISO 8601 timestamp
URLs *ReplicatePredictionURLs `json:"urls,omitempty"` // URLs for API operations
Metrics *ReplicateMetrics `json:"metrics,omitempty"` // Execution metrics
DataRemoved *bool `json:"data_removed,omitempty"` // Whether data has been removed
Source *string `json:"source,omitempty"` // Source of the prediction (web/api)
WebhookCompleted *bool `json:"webhook_completed,omitempty"` // Whether webhook was completed
Stream *bool `json:"stream,omitempty"` // Whether the prediction is streaming
}
ReplicatePredictionResponse represents a prediction response
func (*ReplicatePredictionResponse) ToBifrostChatResponse ¶
func (response *ReplicatePredictionResponse) ToBifrostChatResponse() *schemas.BifrostChatResponse
ToBifrostChatResponse converts a Replicate prediction response to Bifrost format
func (*ReplicatePredictionResponse) ToBifrostResponsesResponse ¶
func (response *ReplicatePredictionResponse) ToBifrostResponsesResponse() *schemas.BifrostResponsesResponse
func (*ReplicatePredictionResponse) ToBifrostTextCompletionResponse ¶
func (response *ReplicatePredictionResponse) ToBifrostTextCompletionResponse() *schemas.BifrostTextCompletionResponse
ToBifrostTextCompletionResponse converts a Replicate prediction response to Bifrost format
type ReplicatePredictionStatus ¶
type ReplicatePredictionStatus string
ReplicatePredictionStatus represents the status of a prediction
const ( ReplicatePredictionStatusStarting ReplicatePredictionStatus = "starting" ReplicatePredictionStatusProcessing ReplicatePredictionStatus = "processing" ReplicatePredictionStatusSucceeded ReplicatePredictionStatus = "succeeded" ReplicatePredictionStatusFailed ReplicatePredictionStatus = "failed" ReplicatePredictionStatusCanceled ReplicatePredictionStatus = "canceled" )
type ReplicatePredictionURLs ¶
type ReplicatePredictionURLs struct {
Get string `json:"get"` // URL to get prediction details
Cancel string `json:"cancel"` // URL to cancel prediction
Stream *string `json:"stream,omitempty"` // URL for streaming output (if applicable)
Web *string `json:"web,omitempty"` // URL for web output (if applicable)
}
ReplicatePredictionURLs represents URLs for prediction operations
type ReplicateProvider ¶
type ReplicateProvider struct {
// contains filtered or unexported fields
}
ReplicateProvider implements the Provider interface for Replicate's API.
func NewReplicateProvider ¶
func NewReplicateProvider(config *schemas.ProviderConfig, logger schemas.Logger) (*ReplicateProvider, error)
NewReplicateProvider creates a new Replicate provider instance. It initializes the HTTP client with the provided configuration and sets up response pools. The client is configured with timeouts, concurrency limits, and optional proxy settings.
func (*ReplicateProvider) BatchCancel ¶
func (provider *ReplicateProvider) BatchCancel(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchCancelRequest) (*schemas.BifrostBatchCancelResponse, *schemas.BifrostError)
BatchCancel is not supported by replicate provider.
func (*ReplicateProvider) BatchCreate ¶
func (provider *ReplicateProvider) BatchCreate(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostBatchCreateRequest) (*schemas.BifrostBatchCreateResponse, *schemas.BifrostError)
BatchCreate is not supported by replicate provider.
func (*ReplicateProvider) BatchList ¶
func (provider *ReplicateProvider) BatchList(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchListRequest) (*schemas.BifrostBatchListResponse, *schemas.BifrostError)
BatchList is not supported by replicate provider.
func (*ReplicateProvider) BatchResults ¶
func (provider *ReplicateProvider) BatchResults(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchResultsRequest) (*schemas.BifrostBatchResultsResponse, *schemas.BifrostError)
BatchResults is not supported by replicate provider.
func (*ReplicateProvider) BatchRetrieve ¶
func (provider *ReplicateProvider) BatchRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostBatchRetrieveRequest) (*schemas.BifrostBatchRetrieveResponse, *schemas.BifrostError)
BatchRetrieve is not supported by replicate provider.
func (*ReplicateProvider) ChatCompletion ¶
func (provider *ReplicateProvider) ChatCompletion(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostChatRequest) (*schemas.BifrostChatResponse, *schemas.BifrostError)
ChatCompletion performs a chat completion request to the replicate API.
func (*ReplicateProvider) ChatCompletionStream ¶
func (provider *ReplicateProvider) ChatCompletionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostChatRequest) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
ChatCompletionStream performs a streaming chat completion request to the replicate API. It supports real-time streaming of responses using Server-Sent Events (SSE). Returns a channel containing BifrostResponse objects representing the stream or an error if the request fails.
func (*ReplicateProvider) ContainerCreate ¶
func (provider *ReplicateProvider) ContainerCreate(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostContainerCreateRequest) (*schemas.BifrostContainerCreateResponse, *schemas.BifrostError)
ContainerCreate is not supported by replicate provider.
func (*ReplicateProvider) ContainerDelete ¶
func (provider *ReplicateProvider) ContainerDelete(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostContainerDeleteRequest) (*schemas.BifrostContainerDeleteResponse, *schemas.BifrostError)
ContainerDelete is not supported by replicate provider.
func (*ReplicateProvider) ContainerFileContent ¶
func (provider *ReplicateProvider) ContainerFileContent(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostContainerFileContentRequest) (*schemas.BifrostContainerFileContentResponse, *schemas.BifrostError)
ContainerFileContent is not supported by replicate provider.
func (*ReplicateProvider) ContainerFileCreate ¶
func (provider *ReplicateProvider) ContainerFileCreate(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostContainerFileCreateRequest) (*schemas.BifrostContainerFileCreateResponse, *schemas.BifrostError)
ContainerFileCreate is not supported by replicate provider.
func (*ReplicateProvider) ContainerFileDelete ¶
func (provider *ReplicateProvider) ContainerFileDelete(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostContainerFileDeleteRequest) (*schemas.BifrostContainerFileDeleteResponse, *schemas.BifrostError)
ContainerFileDelete is not supported by replicate provider.
func (*ReplicateProvider) ContainerFileList ¶
func (provider *ReplicateProvider) ContainerFileList(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostContainerFileListRequest) (*schemas.BifrostContainerFileListResponse, *schemas.BifrostError)
ContainerFileList is not supported by replicate provider.
func (*ReplicateProvider) ContainerFileRetrieve ¶
func (provider *ReplicateProvider) ContainerFileRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostContainerFileRetrieveRequest) (*schemas.BifrostContainerFileRetrieveResponse, *schemas.BifrostError)
ContainerFileRetrieve is not supported by replicate provider.
func (*ReplicateProvider) ContainerList ¶
func (provider *ReplicateProvider) ContainerList(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostContainerListRequest) (*schemas.BifrostContainerListResponse, *schemas.BifrostError)
ContainerList is not supported by replicate provider.
func (*ReplicateProvider) ContainerRetrieve ¶
func (provider *ReplicateProvider) ContainerRetrieve(_ *schemas.BifrostContext, _ []schemas.Key, _ *schemas.BifrostContainerRetrieveRequest) (*schemas.BifrostContainerRetrieveResponse, *schemas.BifrostError)
ContainerRetrieve is not supported by replicate provider.
func (*ReplicateProvider) CountTokens ¶
func (provider *ReplicateProvider) CountTokens(_ *schemas.BifrostContext, _ schemas.Key, _ *schemas.BifrostResponsesRequest) (*schemas.BifrostCountTokensResponse, *schemas.BifrostError)
func (*ReplicateProvider) Embedding ¶
func (provider *ReplicateProvider) Embedding(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostEmbeddingRequest) (*schemas.BifrostEmbeddingResponse, *schemas.BifrostError)
Embedding is not supported by the replicate provider.
func (*ReplicateProvider) FileContent ¶
func (provider *ReplicateProvider) FileContent(ctx *schemas.BifrostContext, keys []schemas.Key, request *schemas.BifrostFileContentRequest) (*schemas.BifrostFileContentResponse, *schemas.BifrostError)
FileContent is not supported by replicate provider.
func (*ReplicateProvider) FileDelete ¶
func (provider *ReplicateProvider) FileDelete(ctx *schemas.BifrostContext, keys []schemas.Key, request *schemas.BifrostFileDeleteRequest) (*schemas.BifrostFileDeleteResponse, *schemas.BifrostError)
FileDelete deletes a file from Replicate's Files API by trying each key until successful.
func (*ReplicateProvider) FileList ¶
func (provider *ReplicateProvider) FileList(ctx *schemas.BifrostContext, keys []schemas.Key, request *schemas.BifrostFileListRequest) (*schemas.BifrostFileListResponse, *schemas.BifrostError)
FileList lists files using serial pagination across keys. Exhausts all pages from one key before moving to the next.
func (*ReplicateProvider) FileRetrieve ¶
func (provider *ReplicateProvider) FileRetrieve(ctx *schemas.BifrostContext, keys []schemas.Key, request *schemas.BifrostFileRetrieveRequest) (*schemas.BifrostFileRetrieveResponse, *schemas.BifrostError)
FileRetrieve retrieves file metadata from Replicate's Files API by trying each key until found.
func (*ReplicateProvider) FileUpload ¶
func (provider *ReplicateProvider) FileUpload(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostFileUploadRequest) (*schemas.BifrostFileUploadResponse, *schemas.BifrostError)
FileUpload uploads a file to Replicate's Files API.
func (*ReplicateProvider) GetProviderKey ¶
func (provider *ReplicateProvider) GetProviderKey() schemas.ModelProvider
GetProviderKey returns the provider identifier for Replicate.
func (*ReplicateProvider) ImageEdit ¶
func (provider *ReplicateProvider) ImageEdit(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostImageEditRequest) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
ImageEdit is not supported by the Replicate provider.
func (*ReplicateProvider) ImageEditStream ¶
func (provider *ReplicateProvider) ImageEditStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostImageEditRequest) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
ImageEditStream performs a streaming image edit request to the replicate API. It creates a prediction with streaming enabled and listens to the stream URL for progressive updates.
func (*ReplicateProvider) ImageGeneration ¶
func (provider *ReplicateProvider) ImageGeneration(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostImageGenerationRequest) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
ImageGeneration performs an image generation request to the replicate API using predictions.
func (*ReplicateProvider) ImageGenerationStream ¶
func (provider *ReplicateProvider) ImageGenerationStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostImageGenerationRequest) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
ImageGenerationStream performs a streaming image generation request to the replicate API. It creates a prediction with streaming enabled and listens to the stream URL for progressive updates.
func (*ReplicateProvider) ImageVariation ¶
func (provider *ReplicateProvider) ImageVariation(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostImageVariationRequest) (*schemas.BifrostImageGenerationResponse, *schemas.BifrostError)
ImageVariation is not supported by the Replicate provider.
func (*ReplicateProvider) ListModels ¶
func (provider *ReplicateProvider) ListModels(ctx *schemas.BifrostContext, keys []schemas.Key, request *schemas.BifrostListModelsRequest) (*schemas.BifrostListModelsResponse, *schemas.BifrostError)
ListModels performs a list models request to Replicate's API.
func (*ReplicateProvider) Responses ¶
func (provider *ReplicateProvider) Responses(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostResponsesRequest) (*schemas.BifrostResponsesResponse, *schemas.BifrostError)
Responses performs a responses request to the replicate API.
func (*ReplicateProvider) ResponsesStream ¶
func (provider *ReplicateProvider) ResponsesStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostResponsesRequest) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
ResponsesStream performs a streaming responses request to the replicate API.
func (*ReplicateProvider) Speech ¶
func (provider *ReplicateProvider) Speech(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostSpeechRequest) (*schemas.BifrostSpeechResponse, *schemas.BifrostError)
Speech is not supported by the replicate provider.
func (*ReplicateProvider) SpeechStream ¶
func (provider *ReplicateProvider) SpeechStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostSpeechRequest) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
SpeechStream is not supported by the replicate provider.
func (*ReplicateProvider) TextCompletion ¶
func (provider *ReplicateProvider) TextCompletion(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostTextCompletionRequest) (*schemas.BifrostTextCompletionResponse, *schemas.BifrostError)
TextCompletion performs a text completion request to the replicate API.
func (*ReplicateProvider) TextCompletionStream ¶
func (provider *ReplicateProvider) TextCompletionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostTextCompletionRequest) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
TextCompletionStream performs a streaming text completion request to replicate's API. It formats the request, sends it to replicate, and processes the response. Returns a channel of BifrostStream objects or an error if the request fails.
func (*ReplicateProvider) Transcription ¶
func (provider *ReplicateProvider) Transcription(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostTranscriptionRequest) (*schemas.BifrostTranscriptionResponse, *schemas.BifrostError)
Transcription is not supported by the replicate provider.
func (*ReplicateProvider) TranscriptionStream ¶
func (provider *ReplicateProvider) TranscriptionStream(ctx *schemas.BifrostContext, postHookRunner schemas.PostHookRunner, key schemas.Key, request *schemas.BifrostTranscriptionRequest) (chan *schemas.BifrostStreamChunk, *schemas.BifrostError)
TranscriptionStream is not supported by the replicate provider.
type ReplicateSSEEvent ¶
type ReplicateSSEEvent struct {
Event string // Event type: "output", "done", "error"
Data string // Event data - can be plain text, JSON object, or data URI
ID string // Event ID (e.g., "1690212292:0")
}
ReplicateSSEEvent represents a Server-Sent Event from Replicate streaming API
type ReplicateStreamEvent ¶
type ReplicateStreamEvent struct {
Event string `json:"event,omitempty"` // Event type (output, logs, done, error)
Data interface{} `json:"data,omitempty"` // Event data
Error *string `json:"error,omitempty"` // Error message if event is error
}
ReplicateStreamEvent represents a streaming event
type ReplicateWebhookPayload ¶
type ReplicateWebhookPayload struct {
ID string `json:"id"`
Model string `json:"model"`
Version string `json:"version"`
Input map[string]interface{} `json:"input"`
Output interface{} `json:"output,omitempty"`
Logs *string `json:"logs,omitempty"`
Error *string `json:"error,omitempty"`
Status ReplicatePredictionStatus `json:"status"`
CreatedAt string `json:"created_at"`
StartedAt *string `json:"started_at,omitempty"`
CompletedAt *string `json:"completed_at,omitempty"`
URLs *ReplicatePredictionURLs `json:"urls,omitempty"`
Metrics *ReplicateMetrics `json:"metrics,omitempty"`
}
ReplicateWebhookPayload represents a webhook payload