Documentation
¶
Index ¶
- Constants
- type AliChatRequest
- type AliChatResponse
- type AliChoice
- type AliEmbedding
- type AliEmbeddingRequest
- type AliEmbeddingResponse
- type AliError
- type AliInput
- type AliMessage
- type AliMessagePart
- type AliOutput
- type AliParameters
- type AliProvider
- func (p *AliProvider) CreateChatCompletion(request *types.ChatCompletionRequest) (*types.ChatCompletionResponse, *types.OpenAIErrorWithStatusCode)
- func (p *AliProvider) CreateChatCompletionStream(request *types.ChatCompletionRequest) (requester.StreamReaderInterface[string], *types.OpenAIErrorWithStatusCode)
- func (p *AliProvider) CreateEmbeddings(request *types.EmbeddingRequest) (*types.EmbeddingResponse, *types.OpenAIErrorWithStatusCode)
- func (p *AliProvider) GetFullRequestURL(requestURL string, modelName string) string
- func (p *AliProvider) GetModelList() ([]string, error)
- func (p *AliProvider) GetRequestHeaders() (headers map[string]string)
- type AliProviderFactory
- type AliUsage
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 AliChoice ¶
type AliChoice struct {
FinishReason string `json:"finish_reason"`
Message types.ChatCompletionMessage `json:"message"`
}
type AliEmbedding ¶
type AliEmbeddingRequest ¶
type AliEmbeddingResponse ¶
type AliEmbeddingResponse struct {
Output struct {
Embeddings []AliEmbedding `json:"embeddings"`
} `json:"output"`
Usage AliUsage `json:"usage"`
AliError
}
type AliInput ¶
type AliInput struct {
// Prompt string `json:"prompt"`
Messages []AliMessage `json:"messages"`
}
type AliMessage ¶
type AliMessagePart ¶
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) CreateChatCompletion ¶
func (p *AliProvider) CreateChatCompletion(request *types.ChatCompletionRequest) (*types.ChatCompletionResponse, *types.OpenAIErrorWithStatusCode)
func (*AliProvider) CreateChatCompletionStream ¶
func (p *AliProvider) CreateChatCompletionStream(request *types.ChatCompletionRequest) (requester.StreamReaderInterface[string], *types.OpenAIErrorWithStatusCode)
func (*AliProvider) CreateEmbeddings ¶
func (p *AliProvider) CreateEmbeddings(request *types.EmbeddingRequest) (*types.EmbeddingResponse, *types.OpenAIErrorWithStatusCode)
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{}
定义供应商工厂
func (AliProviderFactory) Create ¶
func (f AliProviderFactory) Create(channel *model.Channel) base.ProviderInterface
创建 AliProvider https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation
Click to show internal directories.
Click to hide internal directories.