Documentation
¶
Index ¶
- Variables
- func CountToken(text string) int
- func CountTokenInput(input any, model string) int
- func CountTokenMessages(messages []model.Message, model string) int
- func CountTokenText(text string, model string) int
- func ErrorWrapper(err error, code string, statusCode int) *model.ErrorWithStatusCode
- func GetCompatibleChannelMeta(channelType int) (string, []string)
- func GetFullRequestURL(baseURL string, requestURL string, channelType int) string
- func Handler(c *gin.Context, resp *http.Response, promptTokens int, modelName string) (*model.ErrorWithStatusCode, *model.Usage)
- func ImageHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *model.Usage)
- func InitTokenEncoders()
- func ResponseText2Usage(responseText string, modelName string, promptTokens int) *model.Usage
- func StreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*model.ErrorWithStatusCode, string, *model.Usage)
- type Adaptor
- func (a *Adaptor) ConvertImageRequest(request *model.ImageRequest) (any, error)
- func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.GeneralOpenAIRequest) (any, error)
- func (a *Adaptor) DoRequest(c *gin.Context, meta *meta.Meta, requestBody io.Reader) (*http.Response, error)
- func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Meta) (usage *model.Usage, err *model.ErrorWithStatusCode)
- func (a *Adaptor) GetChannelName() string
- func (a *Adaptor) GetModelList() []string
- func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error)
- func (a *Adaptor) Init(meta *meta.Meta)
- func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error
- type ChatCompletionsStreamResponse
- type ChatCompletionsStreamResponseChoice
- type ChatRequest
- type CompletionsStreamResponse
- type EmbeddingResponse
- type EmbeddingResponseItem
- type ImageContent
- type ImageData
- type ImageRequest
- type ImageResponse
- type Segment
- type SlimTextResponse
- type TextContent
- type TextRequest
- type TextResponse
- type TextResponseChoice
- type TextToSpeechRequest
- type UsageOrResponseText
- type WhisperJSONResponse
- type WhisperVerboseJSONResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var CompatibleChannels = []int{ channeltype.AzureAI, channeltype.AI360, channeltype.Moonshot, channeltype.Baichuan, channeltype.Minimax, channeltype.Doubao, channeltype.Mistral, channeltype.Groq, channeltype.LingYiWanWu, channeltype.StepFun, channeltype.DeepSeek, channeltype.TogetherAI, channeltype.Novita, channeltype.SiliconFlow, channeltype.XAI, }
View Source
var ModelList = []string{
"gpt-3.5-turbo", "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125",
"gpt-3.5-turbo-16k", "gpt-3.5-turbo-16k-0613",
"gpt-3.5-turbo-instruct",
"gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-1106-preview", "gpt-4-0125-preview",
"gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-0613",
"gpt-4-turbo-preview", "gpt-4-turbo", "gpt-4-turbo-2024-04-09",
"gpt-4o", "gpt-4o-2024-05-13",
"gpt-4o-2024-08-06",
"gpt-4o-2024-11-20",
"chatgpt-4o-latest",
"gpt-4o-mini", "gpt-4o-mini-2024-07-18",
"gpt-4-vision-preview",
"text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large",
"text-curie-001", "text-babbage-001", "text-ada-001", "text-davinci-002", "text-davinci-003",
"text-moderation-latest", "text-moderation-stable",
"text-davinci-edit-001",
"davinci-002", "babbage-002",
"dall-e-2", "dall-e-3",
"whisper-1",
"tts-1", "tts-1-1106", "tts-1-hd", "tts-1-hd-1106",
"o1", "o1-2024-12-17",
"o1-preview", "o1-preview-2024-09-12",
"o1-mini", "o1-mini-2024-09-12",
}
Functions ¶
func CountToken ¶
func CountTokenInput ¶
func CountTokenText ¶
func ErrorWrapper ¶
func ErrorWrapper(err error, code string, statusCode int) *model.ErrorWithStatusCode
func GetFullRequestURL ¶
func ImageHandler ¶
func InitTokenEncoders ¶
func InitTokenEncoders()
func ResponseText2Usage ¶
Types ¶
type Adaptor ¶
type Adaptor struct {
ChannelType int
}
func (*Adaptor) ConvertImageRequest ¶
func (a *Adaptor) ConvertImageRequest(request *model.ImageRequest) (any, error)
func (*Adaptor) ConvertRequest ¶
func (*Adaptor) DoResponse ¶
func (*Adaptor) GetChannelName ¶
func (*Adaptor) GetModelList ¶
type ChatRequest ¶
type EmbeddingResponse ¶
type EmbeddingResponse struct { Object string `json:"object"` Data []EmbeddingResponseItem `json:"data"` Model string `json:"model"` model.Usage `json:"usage"` }
type EmbeddingResponseItem ¶
type ImageContent ¶
type ImageRequest ¶
type ImageRequest struct { Model string `json:"model"` Prompt string `json:"prompt" binding:"required"` N int `json:"n,omitempty"` Size string `json:"size,omitempty"` Quality string `json:"quality,omitempty"` ResponseFormat string `json:"response_format,omitempty"` Style string `json:"style,omitempty"` User string `json:"user,omitempty"` }
ImageRequest docs: https://platform.openai.com/docs/api-reference/images/create
type ImageResponse ¶
type Segment ¶
type Segment struct { Id int `json:"id"` Seek int `json:"seek"` Start float64 `json:"start"` End float64 `json:"end"` Text string `json:"text"` Tokens []int `json:"tokens"` Temperature float64 `json:"temperature"` AvgLogprob float64 `json:"avg_logprob"` CompressionRatio float64 `json:"compression_ratio"` NoSpeechProb float64 `json:"no_speech_prob"` }
type SlimTextResponse ¶
type SlimTextResponse struct { Choices []TextResponseChoice `json:"choices"` model.Usage `json:"usage"` Error model.Error `json:"error"` }
type TextContent ¶
type TextRequest ¶
type TextResponse ¶
type TextResponseChoice ¶
type TextToSpeechRequest ¶
type UsageOrResponseText ¶
type WhisperJSONResponse ¶
type WhisperJSONResponse struct {
Text string `json:"text,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.