replicate

package
v1.4.2 Latest Latest
Warning

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

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

Documentation

Overview

Package providers implements various LLM providers and their utility functions. This file contains the replicate provider implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseReplicateTimestamp

func ParseReplicateTimestamp(timestamp string) int64

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 ReplicateOutputText struct {
	ResponseId *string `json:"response_id,omitempty"`
	Text       *string `json:"text,omitempty"`
}

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

BatchCancel is not supported by replicate provider.

func (*ReplicateProvider) BatchCreate

BatchCreate is not supported by replicate provider.

func (*ReplicateProvider) BatchList

BatchList is not supported by replicate provider.

func (*ReplicateProvider) BatchResults

BatchResults is not supported by replicate provider.

func (*ReplicateProvider) BatchRetrieve

BatchRetrieve is not supported by replicate provider.

func (*ReplicateProvider) ChatCompletion

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

ContainerCreate is not supported by replicate provider.

func (*ReplicateProvider) ContainerDelete

ContainerDelete is not supported by replicate provider.

func (*ReplicateProvider) ContainerFileContent

ContainerFileContent is not supported by replicate provider.

func (*ReplicateProvider) ContainerFileCreate

ContainerFileCreate is not supported by replicate provider.

func (*ReplicateProvider) ContainerFileDelete

ContainerFileDelete is not supported by replicate provider.

func (*ReplicateProvider) ContainerFileList

ContainerFileList is not supported by replicate provider.

func (*ReplicateProvider) ContainerFileRetrieve

ContainerFileRetrieve is not supported by replicate provider.

func (*ReplicateProvider) ContainerList

ContainerList is not supported by replicate provider.

func (*ReplicateProvider) ContainerRetrieve

ContainerRetrieve is not supported by replicate provider.

func (*ReplicateProvider) Embedding

Embedding is not supported by the replicate provider.

func (*ReplicateProvider) FileContent

FileContent is not supported by replicate provider.

func (*ReplicateProvider) FileDelete

FileDelete deletes a file from Replicate's Files API by trying each key until successful.

func (*ReplicateProvider) FileList

FileList lists files using serial pagination across keys. Exhausts all pages from one key before moving to the next.

func (*ReplicateProvider) FileRetrieve

FileRetrieve retrieves file metadata from Replicate's Files API by trying each key until found.

func (*ReplicateProvider) FileUpload

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

ImageEdit is not supported by the Replicate provider.

func (*ReplicateProvider) ImageEditStream

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

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

ImageVariation is not supported by the Replicate provider.

func (*ReplicateProvider) ListModels

ListModels performs a list models request to Replicate's API.

func (*ReplicateProvider) Responses

Responses performs a responses request to the replicate API.

func (*ReplicateProvider) ResponsesStream

ResponsesStream performs a streaming responses request to the replicate API.

func (*ReplicateProvider) Speech

Speech is not supported by the replicate provider.

func (*ReplicateProvider) SpeechStream

SpeechStream is not supported by the replicate provider.

func (*ReplicateProvider) TextCompletion

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

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

Jump to

Keyboard shortcuts

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