ali

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpenaiBaseURL = "https://dashscope.aliyuncs.com/compatible-mode"
	AliBaseURL    = "https://dashscope.aliyuncs.com"
)
View Source
const (
	// VisionModelKeywords 定义视觉模型的关键词
	VisionModelKeywords = "-vl,qvq,vision"
	// WebSearchSupportedModels 定义支持web_search插件的模型关键词
	WebSearchSupportedModels = "qwen-plus,qwen-turbo,qwen-max,qwq-plus"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AliChatRequest

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

type AliChatResponse

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

type AliChoice

type AliChoice struct {
	FinishReason string                      `json:"finish_reason"`
	Message      types.ChatCompletionMessage `json:"message"`
}

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 AliInput

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

type AliMessage

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

type AliMessagePart

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

type AliOutput

type AliOutput struct {
	Choices      []types.ChatCompletionChoice `json:"choices"`
	FinishReason string                       `json:"finish_reason,omitempty"`
}

func (*AliOutput) ToChatCompletionChoices

func (o *AliOutput) ToChatCompletionChoices() []types.ChatCompletionChoice

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"`
	ResultFormat      string  `json:"result_format,omitempty"`
	EnableThinking    *bool   `json:"enable_thinking,omitempty"` // qwen3 thinking switch
}

type AliProvider

type AliProvider struct {
	openai.OpenAIProvider

	UseOpenaiAPI bool
}

func (*AliProvider) CreateEmbeddings

func (*AliProvider) GetFullRequestURL

func (p *AliProvider) GetFullRequestURL(requestURL string, modelName string) string

func (*AliProvider) GetModelList

func (p *AliProvider) GetModelList() ([]string, error)

func (*AliProvider) GetRequestHeaders

func (p *AliProvider) GetRequestHeaders() (headers map[string]string)

获取请求头

type AliProviderFactory

type AliProviderFactory struct{}

定义供应商工厂

type AliUsage

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

Jump to

Keyboard shortcuts

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