deepl

package
v0.0.0-...-d98d1a9 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModelList = []string{
	"deepl-zh",
	"deepl-en",
	"deepl-ja",
}

Functions

func Handler

func Handler(c *gin.Context, resp *http.Response, modelName string) *model.ErrorWithStatusCode

func ResponseDeepL2OpenAI

func ResponseDeepL2OpenAI(deeplResponse *Response) *openai.TextResponse

func StreamHandler

func StreamHandler(c *gin.Context, resp *http.Response, modelName string) *model.ErrorWithStatusCode

func StreamResponseDeepL2OpenAI

func StreamResponseDeepL2OpenAI(deeplResponse *Response) *openai.ChatCompletionsStreamResponse

Types

type Adaptor

type Adaptor struct {
	// contains filtered or unexported fields
}

func (*Adaptor) ConvertImageRequest

func (a *Adaptor) ConvertImageRequest(request *model.ImageRequest) (any, error)

func (*Adaptor) ConvertRequest

func (a *Adaptor) ConvertRequest(_ *gin.Context, _ int, request *model.GeneralOpenAIRequest) (any, error)

func (*Adaptor) ConvertSTTRequest

func (a *Adaptor) ConvertSTTRequest(*http.Request) (io.ReadCloser, error)

func (*Adaptor) ConvertTTSRequest

func (a *Adaptor) ConvertTTSRequest(*model.TextToSpeechRequest) (any, error)

func (*Adaptor) DoRequest

func (a *Adaptor) DoRequest(c *gin.Context, meta *meta.Meta, requestBody io.Reader) (*http.Response, error)

func (*Adaptor) DoResponse

func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Meta) (usage *model.Usage, err *model.ErrorWithStatusCode)

func (*Adaptor) GetChannelName

func (a *Adaptor) GetChannelName() string

func (*Adaptor) GetModelList

func (a *Adaptor) GetModelList() []string

func (*Adaptor) GetRequestURL

func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error)

func (*Adaptor) Init

func (a *Adaptor) Init(meta *meta.Meta)

func (*Adaptor) SetupRequestHeader

func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error

type Request

type Request struct {
	TargetLang string   `json:"target_lang"`
	Text       []string `json:"text"`
}

func ConvertRequest

func ConvertRequest(textRequest *model.GeneralOpenAIRequest) (*Request, string)

type Response

type Response struct {
	Message      string        `json:"message,omitempty"`
	Translations []Translation `json:"translations,omitempty"`
}

type Translation

type Translation struct {
	DetectedSourceLanguage string `json:"detected_source_language,omitempty"`
	Text                   string `json:"text,omitempty"`
}

Jump to

Keyboard shortcuts

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