replicate

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReplicateChatRequest

type ReplicateChatRequest struct {
	TopK             float64  `json:"top_k,omitempty"`
	TopP             *float64 `json:"top_p,omitempty"`
	Prompt           string   `json:"prompt"`
	MaxTokens        int      `json:"max_tokens,omitempty"`
	MinTokens        int      `json:"min_tokens,omitempty"`
	Temperature      *float64 `json:"temperature,omitempty"`
	SystemPrompt     string   `json:"system_prompt,omitempty"`
	PresencePenalty  *float64 `json:"presence_penalty,omitempty"`
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
}

type ReplicateError

type ReplicateError struct {
	Detail string `json:"detail"`
	Status int    `json:"status"`
	Title  string `json:"title"`
}

type ReplicateImageRequest

type ReplicateImageRequest struct {
	Prompt           string  `json:"prompt"`
	AspectRatio      *string `json:"aspect_ratio,omitempty"`
	OutputFormat     string  `json:"output_format,omitempty"`
	OutputQuality    *int    `json:"output_quality,omitempty"`
	SafetyTolerance  *string `json:"safety_tolerance,omitempty"`
	PromptUpsampling *string `json:"prompt_upsampling,omitempty"`
	Size             string  `json:"size,omitempty"`
}

type ReplicateImageUrl

type ReplicateImageUrl struct {
	Stream string `json:"stream"`
}

type ReplicateMetrics

type ReplicateMetrics struct {
	InputTokenCount  int `json:"input_token_count,omitempty"`
	OutputTokenCount int `json:"output_token_count,omitempty"`
}

type ReplicateProvider

type ReplicateProvider struct {
	base.BaseProvider
	FetchPredictionUrl string
}

func (*ReplicateProvider) CreateChatCompletion

func (p *ReplicateProvider) CreateChatCompletion(request *types.ChatCompletionRequest) (response *types.ChatCompletionResponse, errWithCode *types.OpenAIErrorWithStatusCode)

func (*ReplicateProvider) CreateImageGenerations

func (p *ReplicateProvider) CreateImageGenerations(request *types.ImageRequest) (*types.ImageResponse, *types.OpenAIErrorWithStatusCode)

func (*ReplicateProvider) GetFullRequestURL

func (p *ReplicateProvider) GetFullRequestURL(requestURL string, model string) string

获取完整请求 URL

func (*ReplicateProvider) GetRequestHeaders

func (p *ReplicateProvider) GetRequestHeaders() (headers map[string]string)

获取请求头

type ReplicateProviderFactory

type ReplicateProviderFactory struct{}

func (ReplicateProviderFactory) Create

创建 ReplicateProvider

type ReplicateRequest

type ReplicateRequest[T any] struct {
	Stream bool `json:"stream,omitempty"`
	Input  T    `json:"input"`
}

type ReplicateResponse

type ReplicateResponse[T any] struct {
	ID      string            `json:"id"`
	Model   string            `json:"model"`
	Urls    ReplicateImageUrl `json:"urls"`
	Status  string            `json:"status"` // starting / succeeded
	Error   string            `json:"error,omitempty"`
	Output  T                 `json:"output,omitempty"`
	Metrics ReplicateMetrics  `json:"metrics,omitempty"`
}

type ReplicateStreamHandler

type ReplicateStreamHandler struct {
	Usage     *types.Usage
	ModelName string
	ID        string
	Provider  *ReplicateProvider
}

func (*ReplicateStreamHandler) HandlerChatStream

func (h *ReplicateStreamHandler) HandlerChatStream(rawLine *[]byte, dataChan chan string, errChan chan error)

Jump to

Keyboard shortcuts

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