Documentation ¶
Index ¶
- Constants
- Variables
- func Base64Encode(data []byte) string
- func EmbeddingHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *model.Usage)
- func Handler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *model.Usage)
- func ImageHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *model.Usage)
- func StreamHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *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 ChatRequest
- type ChatResponse
- type Embedding
- type EmbeddingRequest
- type EmbeddingResponse
- type Error
- type Header
- type ImageRequest
- type Input
- type Message
- type Output
- type Parameters
- type Payload
- type TaskResponse
- type Usage
- type WSSMessage
Constants ¶
View Source
const EnableSearchModelSuffix = "-internet"
Variables ¶
View Source
var ModelList = []string{
"qwen-turbo", "qwen-plus", "qwen-max", "qwen-max-longcontext",
"text-embedding-v1",
"ali-stable-diffusion-xl", "ali-stable-diffusion-v1.5", "wanx-v1",
}
Functions ¶
func Base64Encode ¶
func EmbeddingHandler ¶
func ImageHandler ¶
func StreamHandler ¶
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 (*Adaptor) DoResponse ¶
func (*Adaptor) GetChannelName ¶
func (*Adaptor) GetModelList ¶
type ChatRequest ¶
type ChatRequest struct { Model string `json:"model"` Input Input `json:"input"` Parameters Parameters `json:"parameters,omitempty"` }
func ConvertRequest ¶
func ConvertRequest(request model.GeneralOpenAIRequest) *ChatRequest
type ChatResponse ¶
type EmbeddingRequest ¶
type EmbeddingRequest struct { Model string `json:"model"` Input struct { Texts []string `json:"texts"` } `json:"input"` Parameters *struct { TextType string `json:"text_type,omitempty"` } `json:"parameters,omitempty"` }
func ConvertEmbeddingRequest ¶
func ConvertEmbeddingRequest(request model.GeneralOpenAIRequest) *EmbeddingRequest
type EmbeddingResponse ¶
type Header ¶
type Header struct { Action string `json:"action,omitempty"` Streaming string `json:"streaming,omitempty"` TaskID string `json:"task_id,omitempty"` Event string `json:"event,omitempty"` ErrorCode string `json:"error_code,omitempty"` ErrorMessage string `json:"error_message,omitempty"` Attributes any `json:"attributes,omitempty"` }
type ImageRequest ¶
type ImageRequest struct { Model string `json:"model"` Input struct { Prompt string `json:"prompt"` NegativePrompt string `json:"negative_prompt,omitempty"` } `json:"input"` Parameters struct { Size string `json:"size,omitempty"` N int `json:"n,omitempty"` Steps string `json:"steps,omitempty"` Scale string `json:"scale,omitempty"` } `json:"parameters,omitempty"` ResponseFormat string `json:"response_format,omitempty"` }
func ConvertImageRequest ¶
func ConvertImageRequest(request model.ImageRequest) *ImageRequest
type Input ¶
type Input struct { //Prompt string `json:"prompt"` Messages []Message `json:"messages"` }
type Output ¶
type Output struct { //Text string `json:"text"` //FinishReason string `json:"finish_reason"` Choices []openai.TextResponseChoice `json:"choices"` }
type Parameters ¶
type Parameters struct { TopP float64 `json:"top_p,omitempty"` TopK int `json:"top_k,omitempty"` Seed uint64 `json:"seed,omitempty"` EnableSearch bool `json:"enable_search,omitempty"` IncrementalOutput bool `json:"incremental_output,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` Temperature float64 `json:"temperature,omitempty"` ResultFormat string `json:"result_format,omitempty"` Tools []model.Tool `json:"tools,omitempty"` }
type Payload ¶
type Payload struct { Model string `json:"model,omitempty"` Task string `json:"task,omitempty"` TaskGroup string `json:"task_group,omitempty"` Function string `json:"function,omitempty"` Parameters struct { SampleRate int `json:"sample_rate,omitempty"` Rate float64 `json:"rate,omitempty"` Format string `json:"format,omitempty"` } `json:"parameters,omitempty"` Input struct { Text string `json:"text,omitempty"` } `json:"input,omitempty"` Usage struct { Characters int `json:"characters,omitempty"` } `json:"usage,omitempty"` }
type TaskResponse ¶
type TaskResponse struct { StatusCode int `json:"status_code,omitempty"` RequestId string `json:"request_id,omitempty"` Code string `json:"code,omitempty"` Message string `json:"message,omitempty"` Output struct { TaskId string `json:"task_id,omitempty"` TaskStatus string `json:"task_status,omitempty"` Code string `json:"code,omitempty"` Message string `json:"message,omitempty"` Results []struct { B64Image string `json:"b64_image,omitempty"` Url string `json:"url,omitempty"` Code string `json:"code,omitempty"` Message string `json:"message,omitempty"` } `json:"results,omitempty"` TaskMetrics struct { Total int `json:"TOTAL,omitempty"` Succeeded int `json:"SUCCEEDED,omitempty"` Failed int `json:"FAILED,omitempty"` } `json:"task_metrics,omitempty"` } `json:"output,omitempty"` Usage Usage `json:"usage"` }
type WSSMessage ¶
Click to show internal directories.
Click to hide internal directories.