Documentation
¶
Index ¶
- func Embeddings(ctx context.Context, provider, apiKey, url string, req map[string]interface{}, ...) ([]byte, error)
- func Gui(ctx context.Context, provider, apiKey, url string, req *GuiReq, ...) ([]byte, error)
- func Ocr(ctx *gin.Context, provider, apiKey, url string, req *OcrReq, headers ...Header) ([]byte, error)
- func Rerank(ctx context.Context, provider, apiKey, url string, req map[string]interface{}, ...) ([]byte, error)
- type Document
- type EmbeddingData
- type EmbeddingReq
- type EmbeddingResp
- type FCType
- type FunctionCall
- type GuiContent
- type GuiReq
- type GuiResp
- type Header
- type IEmbeddingReq
- type IEmbeddingResp
- type IGuiReq
- type IGuiResp
- type ILLMReq
- type ILLMResp
- type IOcrReq
- type IOcrResp
- type IRerankReq
- type IRerankResp
- type LLMReq
- type LLMResp
- type MsgRole
- type OcrData
- type OcrReq
- type OcrResp
- type OpenAIFunction
- type OpenAIFunctionParameters
- type OpenAIFunctionParametersProperty
- type OpenAIMsg
- type OpenAIRespChoice
- type OpenAIRespChoiceMsg
- type OpenAIRespUsage
- type OpenAIResponseFormat
- type OpenAITool
- type RerankReq
- type RerankResp
- type Result
- type StreamOptions
- type Thinking
- type ToolCall
- type ToolType
- type Usage
- type WebSearch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Embeddings ¶ added in v0.1.5
Types ¶
type EmbeddingData ¶ added in v0.1.3
type EmbeddingReq ¶ added in v0.1.3
type EmbeddingReq struct {
Model string `json:"model" validate:"required"`
Input []string `json:"input" validate:"required"`
EncodingFormat *string `json:"encoding_format,omitempty"`
}
func (*EmbeddingReq) Check ¶ added in v0.1.3
func (req *EmbeddingReq) Check() error
func (*EmbeddingReq) Data ¶ added in v0.1.5
func (req *EmbeddingReq) Data() (map[string]interface{}, error)
type EmbeddingResp ¶ added in v0.1.3
type FunctionCall ¶ added in v0.1.4
type GuiContent ¶ added in v0.2.1
type GuiReq ¶ added in v0.2.1
type GuiReq struct {
Algo string `json:"algo,omitempty"` // 算法名称,默认gui_agent_v1
Platform string `json:"platform" validate:"required"` // 平台信息,移动端填写Mobile, Windows端填写WIN,Mac端填写MAC
CurrentScreenshotXml string `json:"current_screenshot_xml,omitempty"` // 屏幕布局导出的xml文件
CurrentScreenshot string `json:"current_screenshot" validate:"required"` // 当前屏幕截图,Base64编码的图像字符串
CurrentScreenshotWidth int `json:"current_screenshot_width" validate:"required,gt=0"` // 当前屏幕截图的宽度
CurrentScreenshotHeight int `json:"current_screenshot_height" validate:"required,gt=0"` // 当前屏幕截图的高度
Task string `json:"task" validate:"required"` //当前用户任务
History []string `json:"history"` //当前任务的历史返回结果,历次返回结果中的content字段
}
type GuiResp ¶ added in v0.2.1
type GuiResp struct {
Code int `json:"code"`
Message string `json:"message" validate:"required"`
Content GuiContent `json:"content" validate:"required"`
Usage Usage `json:"usage" validate:"required"`
}
type IEmbeddingReq ¶
type IEmbeddingReq interface {
Data() map[string]interface{}
}
func NewEmbeddingReq ¶
func NewEmbeddingReq(data map[string]interface{}) IEmbeddingReq
type IEmbeddingResp ¶
type IEmbeddingResp interface {
String() string
Data() (map[string]interface{}, bool)
ConvertResp() (*EmbeddingResp, bool)
}
func NewEmbeddingResp ¶
func NewEmbeddingResp(raw string) IEmbeddingResp
type IGuiResp ¶ added in v0.2.1
type IGuiResp interface {
String() string
Data() (interface{}, bool)
ConvertResp() (*GuiResp, bool)
}
func NewGuiResp ¶ added in v0.2.1
type ILLMResp ¶
type ILLMResp interface {
String() string
Data() (map[string]interface{}, bool)
ConvertResp() (*LLMResp, bool)
}
func ChatCompletions ¶ added in v0.1.5
func NewLLMResp ¶
type IOcrResp ¶ added in v0.1.5
type IOcrResp interface {
String() string
Data() (interface{}, bool)
ConvertResp() (*OcrResp, bool)
}
func NewOcrResp ¶ added in v0.1.5
type IRerankReq ¶
type IRerankReq interface {
Data() map[string]interface{}
}
func NewRerankReq ¶
func NewRerankReq(data map[string]interface{}) IRerankReq
type IRerankResp ¶
type IRerankResp interface {
String() string
Data() (interface{}, bool)
ConvertResp() (*RerankResp, bool)
}
func NewRerankResp ¶
func NewRerankResp(raw string) IRerankResp
type LLMReq ¶ added in v0.1.4
type LLMReq struct {
// general
Model string `json:"model" validate:"required"`
Messages []OpenAIMsg `json:"messages" validate:"required"`
Stream *bool `json:"stream,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
Stop *string `json:"stop,omitempty"`
ResponseFormat *OpenAIResponseFormat `json:"response_format,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
Tools []OpenAITool `json:"tools,omitempty"`
// custom
Thinking *Thinking `json:"thinking,omitempty"` // 控制模型是否开启深度思考模式。
EnableThinking *bool `json:"enable_thinking,omitempty"`
MaxCompletionTokens *int `json:"max_completion_tokens,omitempty"` // 控制模型输出的最大长度[0,64k]
LogitBias map[string]int `json:"logit_bias,omitempty"` // 调整指定 token 在模型输出内容中出现的概率
ToolChoice interface{} `json:"tool_choice,omitempty"` // 强制指定工具调用的策略
TopP *float64 `json:"top_p,omitempty"`
TopK *int `json:"top_k,omitempty"`
MinP *float64 `json:"min_p,omitempty"`
ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"` // 是否开启并行工具调用
StreamOptions *StreamOptions `json:"stream_options,omitempty"` //当启用流式输出时,可通过将本参数设置为{"include_usage": true},在输出的最后一行显示所使用的Token数。
PresencePenalty *float64 `json:"presence_penalty,omitempty"` // 控制模型生成文本时的内容重复度
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"` // 频率惩罚系数
RepetitionPenalty *float64 `json:"repetition_penalty,omitempty"`
Seed *int `json:"seed,omitempty"`
Logprobs *bool `json:"logprobs,omitempty"` // 是否返回输出 Token 的对数概率
TopLogprobs *int `json:"top_logprobs,omitempty"` // 指定在每一步生成时,返回模型最大概率的候选 Token 个数
N *int `json:"n,omitempty"`
ThinkingBudget *int `json:"thinking_budget,omitempty"` // 思考过程的最大长度,只在enable_thinking为true时生效
WebSearch *WebSearch `json:"web_search,omitempty"` //搜索增强
User *string `json:"user,omitempty"`
// Yuanjing
DoSample *bool `json:"do_sample,omitempty"`
}
type LLMResp ¶ added in v0.1.4
type LLMResp struct {
ID string `json:"id"` // 唯一标识
Object string `json:"object"` // 固定为 "chat.completion"
Created int `json:"created"` // 时间戳(秒)
Model string `json:"model" validate:"required"` // 使用的模型
Choices []OpenAIRespChoice `json:"choices" validate:"required,dive"` // 生成结果列表
Usage OpenAIRespUsage `json:"usage"` // token 使用统计
ServiceTier *string `json:"service_tier"` // (火山)指定是否使用TPM保障包。生效对象为购买了保障包推理接入点
SystemFingerprint *string `json:"system_fingerprint"`
}
type OcrReq ¶ added in v0.1.5
type OcrReq struct {
Files *multipart.FileHeader `form:"file" json:"file" validate:"required"`
}
type OpenAIFunction ¶ added in v0.1.4
type OpenAIFunction struct {
Name string `json:"name" validate:"required"`
Description string `json:"description,omitempty"`
Parameters *OpenAIFunctionParameters `json:"parameters,omitempty"`
}
type OpenAIFunctionParameters ¶ added in v0.1.4
type OpenAIFunctionParameters struct {
Type string `json:"type"`
Properties map[string]OpenAIFunctionParametersProperty `json:"properties"`
Required []string `json:"required"`
}
type OpenAIFunctionParametersProperty ¶ added in v0.1.4
type OpenAIMsg ¶
type OpenAIMsg struct {
Role MsgRole `json:"role"` // "system" | "user" | "assistant" | "function(已弃用)"
Content string `json:"content"`
ToolCallId *string `json:"tool_call_id,omitempty"`
ReasoningContent *string `json:"reasoning_content,omitempty"`
Name *string `json:"name,omitempty"`
FunctionCall *FunctionCall `json:"function_call,omitempty"`
ToolCalls []*ToolCall `json:"tool_calls,omitempty"`
}
type OpenAIRespChoice ¶
type OpenAIRespChoice struct {
Index int `json:"index"` // 选项索引
Message *OpenAIMsg `json:"message,omitempty"` // 非流式生成的消息
Delta *OpenAIMsg `json:"delta,omitempty"` // 流式生成的消息
FinishReason string `json:"finish_reason"` // 停止原因
Logprobs interface{} `json:"logprobs"`
}
OpenAIRespChoice 结构体表示单个生成选项
type OpenAIRespChoiceMsg ¶
type OpenAIRespUsage ¶
type OpenAIRespUsage struct {
CompletionTokens int `json:"completion_tokens"` // 输出 token 数
PromptTokens int `json:"prompt_tokens"` // 输入 token 数
TotalTokens int `json:"total_tokens"` // 总 token 数
}
OpenAIRespUsage 结构体表示 token 消耗
type OpenAIResponseFormat ¶
type OpenAIResponseFormat struct {
Type string `json:"type"` // "text" | "json"
}
type OpenAITool ¶ added in v0.1.4
type OpenAITool struct {
Type ToolType `json:"type" validate:"required"`
Function *OpenAIFunction `json:"function" validate:"required"`
}
type RerankReq ¶ added in v0.1.3
type RerankResp ¶ added in v0.1.3
type StreamOptions ¶ added in v0.1.4
type Thinking ¶ added in v0.1.4
type Thinking struct {
Type string `json:"type" default:"enabled"`
}
type ToolCall ¶ added in v0.1.4
type ToolCall struct {
ID string `json:"id"`
Type ToolType `json:"type"`
Function FunctionCall `json:"function"`
Index *int `json:"index,omitempty"`
}
type ToolType ¶ added in v0.1.4
type ToolType string
const (
ToolTypeFunction ToolType = "function"
)
Click to show internal directories.
Click to hide internal directories.