ali

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const EnableSearchModelSuffix = "-internet"

Variables

View Source
var ChannelName = "ali"
View Source
var ModelList = []string{
	"qwen-turbo",
	"qwen-plus",
	"qwen-max",
	"qwen-max-longcontext",
	"qwq-32b",
	"qwen3-235b-a22b",
	"text-embedding-v1",
	"gte-rerank-v2",
}

Functions

func RerankHandler

func RerankHandler(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (*types.MaxAPIError, *dto.Usage)

Types

type Adaptor

type Adaptor struct {
	IsSyncImageModel bool
}

func (*Adaptor) ConvertAudioRequest

func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.AudioRequest) (io.Reader, error)

func (*Adaptor) ConvertClaudeRequest

func (a *Adaptor) ConvertClaudeRequest(c *gin.Context, info *relaycommon.RelayInfo, req *dto.ClaudeRequest) (any, error)

func (*Adaptor) ConvertEmbeddingRequest

func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.EmbeddingRequest) (any, error)

func (*Adaptor) ConvertGeminiRequest

func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dto.GeminiChatRequest) (any, error)

func (*Adaptor) ConvertImageRequest

func (a *Adaptor) ConvertImageRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.ImageRequest) (any, error)

func (*Adaptor) ConvertOpenAIRequest

func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeneralOpenAIRequest) (any, error)

func (*Adaptor) ConvertOpenAIResponsesRequest

func (a *Adaptor) ConvertOpenAIResponsesRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.OpenAIResponsesRequest) (any, error)

func (*Adaptor) ConvertRerankRequest

func (a *Adaptor) ConvertRerankRequest(c *gin.Context, relayMode int, request dto.RerankRequest) (any, error)

func (*Adaptor) DoRequest

func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, requestBody io.Reader) (any, error)

func (*Adaptor) DoResponse

func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (usage any, err *types.MaxAPIError)

func (*Adaptor) GetChannelName

func (a *Adaptor) GetChannelName() string

func (*Adaptor) GetModelList

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

func (*Adaptor) GetRequestURL

func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error)

func (*Adaptor) Init

func (a *Adaptor) Init(info *relaycommon.RelayInfo)

func (*Adaptor) SetupRequestHeader

func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error

type AliChatRequest

type AliChatRequest struct {
	Model      string        `json:"model"`
	Input      AliInput      `json:"input,omitempty"`
	Parameters AliParameters `json:"parameters,omitempty"`
}

type AliEmbedding

type AliEmbedding struct {
	Embedding []float64 `json:"embedding"`
	TextIndex int       `json:"text_index"`
}

type AliEmbeddingRequest

type AliEmbeddingRequest struct {
	Model string `json:"model"`
	Input struct {
		Texts []string `json:"texts"`
	} `json:"input"`
	Parameters *struct {
		TextType string `json:"text_type,omitempty"`
	} `json:"parameters,omitempty"`
}

type AliEmbeddingResponse

type AliEmbeddingResponse struct {
	Output struct {
		Embeddings []AliEmbedding `json:"embeddings"`
	} `json:"output"`
	Usage AliUsage `json:"usage"`
	AliError
}

type AliError

type AliError struct {
	Code      string `json:"code"`
	Message   string `json:"message"`
	RequestId string `json:"request_id"`
}

type AliImageInput

type AliImageInput struct {
	Prompt         string       `json:"prompt,omitempty"`
	NegativePrompt string       `json:"negative_prompt,omitempty"`
	Messages       []AliMessage `json:"messages,omitempty"`
}

type AliImageParameters

type AliImageParameters struct {
	Size             *string `json:"size,omitempty"`
	N                *int    `json:"n,omitempty"`
	Steps            *string `json:"steps,omitempty"`
	Scale            *string `json:"scale,omitempty"`
	Watermark        *bool   `json:"watermark,omitempty"`
	PromptExtend     *bool   `json:"prompt_extend,omitempty"`
	ThinkingMode     *bool   `json:"thinking_mode,omitempty"`
	EnableSequential *bool   `json:"enable_sequential,omitempty"`
	BboxList         any     `json:"bbox_list,omitempty"`
	ColorPalette     any     `json:"color_palette,omitempty"`
	Seed             *int    `json:"seed,omitempty"`
}

func (*AliImageParameters) NValue added in v1.0.5

func (p *AliImageParameters) NValue() int

func (*AliImageParameters) PromptExtendValue

func (p *AliImageParameters) PromptExtendValue() bool

type AliImageRequest

type AliImageRequest struct {
	Model          string             `json:"model"`
	Input          any                `json:"input"`
	Parameters     AliImageParameters `json:"parameters,omitempty"`
	ResponseFormat *string            `json:"response_format,omitempty"`
}

type AliInput

type AliInput struct {
	Prompt string `json:"prompt,omitempty"`
	//History []AliMessage `json:"history,omitempty"`
	Messages []AliMessage `json:"messages"`
}

type AliMediaContent

type AliMediaContent struct {
	Image string `json:"image,omitempty"`
	Text  string `json:"text,omitempty"`
}

type AliMessage

type AliMessage struct {
	Content any    `json:"content"`
	Role    string `json:"role"`
}

type AliOutput

type AliOutput struct {
	TaskId       string       `json:"task_id,omitempty"`
	TaskStatus   string       `json:"task_status,omitempty"`
	Text         string       `json:"text"`
	FinishReason string       `json:"finish_reason"`
	Message      string       `json:"message,omitempty"`
	Code         string       `json:"code,omitempty"`
	Results      []TaskResult `json:"results,omitempty"`
	Choices      []struct {
		FinishReason string `json:"finish_reason,omitempty"`
		Message      struct {
			Role             string            `json:"role,omitempty"`
			Content          []AliMediaContent `json:"content,omitempty"`
			ReasoningContent string            `json:"reasoning_content,omitempty"`
		} `json:"message,omitempty"`
	} `json:"choices,omitempty"`
}

func (*AliOutput) ChoicesToOpenAIImageDate

func (o *AliOutput) ChoicesToOpenAIImageDate(c *gin.Context, responseFormat string) []dto.ImageData

func (*AliOutput) ResultToOpenAIImageDate

func (o *AliOutput) ResultToOpenAIImageDate(c *gin.Context, responseFormat string) []dto.ImageData

type AliParameters

type AliParameters 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"`
}

type AliRerankInput

type AliRerankInput struct {
	Query     string `json:"query"`
	Documents []any  `json:"documents"`
}

type AliRerankParameters

type AliRerankParameters struct {
	TopN            *int  `json:"top_n,omitempty"`
	ReturnDocuments *bool `json:"return_documents,omitempty"`
}

type AliRerankRequest

type AliRerankRequest struct {
	Model      string              `json:"model"`
	Input      AliRerankInput      `json:"input"`
	Parameters AliRerankParameters `json:"parameters,omitempty"`
}

func ConvertRerankRequest

func ConvertRerankRequest(request dto.RerankRequest) *AliRerankRequest

type AliRerankResponse

type AliRerankResponse struct {
	Output struct {
		Results []dto.RerankResponseResult `json:"results"`
	} `json:"output"`
	Usage     AliUsage `json:"usage"`
	RequestId string   `json:"request_id"`
	AliError
}

type AliResponse

type AliResponse struct {
	Output AliOutput `json:"output"`
	Usage  AliUsage  `json:"usage"`
	AliError
}

type AliUsage

type AliUsage struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
	TotalTokens  int `json:"total_tokens"`
	ImageCount   int `json:"image_count,omitempty"`
}

type TaskResult

type TaskResult struct {
	B64Image string `json:"b64_image,omitempty"`
	Url      string `json:"url,omitempty"`
	Code     string `json:"code,omitempty"`
	Message  string `json:"message,omitempty"`
}

type WanImageInput

type WanImageInput struct {
	Prompt         string   `json:"prompt"`                    // 必需:文本提示词,描述生成图像中期望包含的元素和视觉特点
	Images         []string `json:"images"`                    // 必需:图像URL数组,长度不超过2,支持HTTP/HTTPS URL或Base64编码
	NegativePrompt string   `json:"negative_prompt,omitempty"` // 可选:反向提示词,描述不希望在画面中看到的内容
}

type WanImageParameters

type WanImageParameters struct {
	N         int     `json:"n,omitempty"`         // 生成图片数量,取值范围1-4,默认4
	Watermark *bool   `json:"watermark,omitempty"` // 是否添加水印标识,默认false
	Seed      int     `json:"seed,omitempty"`      // 随机数种子,取值范围[0, 2147483647]
	Strength  float64 `json:"strength,omitempty"`  // 修改幅度 0.0-1.0,默认0.5(部分模型支持)
}

Jump to

Keyboard shortcuts

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