base

package
v0.0.0-...-e9a2108 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUpstreamShouldRetry = errors.New("upstream failed")
)

Functions

func EndpointHasModel

func EndpointHasModel(path string) bool

Types

type ChannelType

type ChannelType string
const (
	ChannelTypeOpenAI    ChannelType = "openai"
	ChannelTypeAzure     ChannelType = "azure"
	ChannelTypeCoze      ChannelType = "coze"
	ChannelTypeAnthropic ChannelType = "anthropic"
)

type Endpoint

type Endpoint string
const (
	EndpointChatCompletion  Endpoint = "/v1/chat/completions"
	EndpointCompletion      Endpoint = "/v1/completions"
	EndpointImageGeneration Endpoint = "/v1/images/generations"
	EndpointImageEdit       Endpoint = "/v1/images/edits"
	EndpointImageVariation  Endpoint = "/v1/images/variations"
	EndpointAudioSpeech     Endpoint = "/v1/audio/speech"
	EndpointAudioTranscript Endpoint = "/v1/audio/transcriptions"
	EndpointAudioTranslate  Endpoint = "/v1/audio/translations"
	EndpointModeration      Endpoint = "/v1/moderations"
	EndpointEmbedding       Endpoint = "/v1/embeddings"
)

type Handler

type Handler interface {
	Serve(ctx context.Context, w http.ResponseWriter, r *http.Request, errorHandler func(w http.ResponseWriter, r *http.Request, err error))
}

type Provider

type Provider interface {
	Completion(ctx context.Context, openaiReq openai.ChatCompletionRequest, w http.ResponseWriter) error
	CompletionStream(ctx context.Context, openaiReq openai.ChatCompletionRequest, w http.ResponseWriter) error
}

type ResponseError

type ResponseError struct {
	Err  error
	Resp *http.Response
}

func (ResponseError) Error

func (r ResponseError) Error() string

Jump to

Keyboard shortcuts

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