utils

package
v0.0.0-...-21e0b36 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTypeUpstream    = "upstream_error"
	ErrorCodeBadResponse = "bad_response"
)

Variables

This section is empty.

Functions

func BuildAudioSpeechRequest

func BuildAudioSpeechRequest(model string) (io.Reader, error)

func BuildChatCompletionRequest

func BuildChatCompletionRequest(model string) (io.Reader, error)

func BuildEmbeddingsRequest

func BuildEmbeddingsRequest(model string) (io.Reader, error)

func BuildImagesGenerationsRequest

func BuildImagesGenerationsRequest(modelConfig *model.ModelConfig) (io.Reader, error)

func BuildModeDefaultPath

func BuildModeDefaultPath(mode int) string

func BuildModerationsRequest

func BuildModerationsRequest(model string) (io.Reader, error)

func BuildRequest

func BuildRequest(modelName string) (io.Reader, int, error)

func BuildRerankRequest

func BuildRerankRequest(model string) (io.Reader, error)

func DoRequest

func DoRequest(req *http.Request) (*http.Response, error)

func IsStreamResponse

func IsStreamResponse(resp *http.Response) bool

func RelayDefaultErrorHanlder

func RelayDefaultErrorHanlder(resp *http.Response) *model.ErrorWithStatusCode

func RelayErrorHandler

func RelayErrorHandler(meta *meta.Meta, resp *http.Response) *model.ErrorWithStatusCode

func RerankErrorHandler

func RerankErrorHandler(resp *http.Response) *model.ErrorWithStatusCode

func UnmarshalGeneralOpenAIRequest

func UnmarshalGeneralOpenAIRequest(req *http.Request) (*relaymodel.GeneralOpenAIRequest, error)

func UnmarshalImageRequest

func UnmarshalImageRequest(req *http.Request) (*relaymodel.ImageRequest, error)

func UnmarshalMap

func UnmarshalMap(req *http.Request) (map[string]any, error)

func UnmarshalRerankRequest

func UnmarshalRerankRequest(req *http.Request) (*relaymodel.RerankRequest, error)

func UnmarshalTTSRequest

func UnmarshalTTSRequest(req *http.Request) (*relaymodel.TextToSpeechRequest, error)

Types

type GeneralErrorResponse

type GeneralErrorResponse struct {
	Error    model.Error `json:"error"`
	Message  string      `json:"message"`
	Msg      string      `json:"msg"`
	Err      string      `json:"err"`
	ErrorMsg string      `json:"error_msg"`
	Header   struct {
		Message string `json:"message"`
	} `json:"header"`
	Response struct {
		Error struct {
			Message string `json:"message"`
		} `json:"error"`
	} `json:"response"`
}

func (GeneralErrorResponse) ToMessage

func (e GeneralErrorResponse) ToMessage() string

type UnsupportedModelTypeError

type UnsupportedModelTypeError struct {
	ModelType string
}

func NewErrUnsupportedModelType

func NewErrUnsupportedModelType(modelType string) *UnsupportedModelTypeError

func (*UnsupportedModelTypeError) Error

func (e *UnsupportedModelTypeError) Error() string

Jump to

Keyboard shortcuts

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