Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IEmbeddingReq ¶
type IEmbeddingReq interface {
Data() map[string]interface{}
}
func NewEmbeddingReq ¶
func NewEmbeddingReq(data map[string]interface{}) IEmbeddingReq
type IEmbeddingResp ¶
func NewEmbeddingResp ¶
func NewEmbeddingResp(raw string) IEmbeddingResp
type ILLMReq ¶
type ILLMReq interface {
Stream() bool
Data() map[string]interface{}
OpenAIReq() (*OpenAILLMReq, bool)
}
type ILLMResp ¶
type ILLMResp interface {
String() string
Data() (map[string]interface{}, bool)
OpenAIResp() (*OpenAILLMResp, bool)
}
func NewLLMResp ¶
type IRerankReq ¶
type IRerankReq interface {
Data() map[string]interface{}
}
func NewRerankReq ¶
func NewRerankReq(data map[string]interface{}) IRerankReq
type IRerankResp ¶
func NewRerankResp ¶
func NewRerankResp(raw string) IRerankResp
type OpenAILLMReq ¶
type OpenAILLMReq struct {
Model string `json:"model" validate:"required"`
Messages []OpenAIMsg `json:"messages" validate:"required"`
Stream bool `json:"stream,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
EnableThinking bool `json:"enable_thinking,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
TopK int `json:"top_k,omitempty"`
MinP float64 `json:"min_p,omitempty"`
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"`
TopLogprobs int `json:"top_logprobs,omitempty"`
N int `json:"n,omitempty"`
ResponseFormat *OpenAIResponseFormat `json:"response_format,omitempty"`
Stop string `json:"stop,omitempty"`
User string `json:"user,omitempty"`
}
type OpenAILLMResp ¶
type OpenAILLMResp struct {
ID string `json:"id"` // 唯一标识
Object string `json:"object"` // 固定为 "chat.completion"
Created int `json:"created"` // 时间戳(秒)
Model string `json:"model"` // 使用的模型
Choices []OpenAIRespChoice `json:"choices"` // 生成结果列表
Usage OpenAIRespUsage `json:"usage"` // token 使用统计
}
type OpenAIRespChoice ¶
type OpenAIRespChoice struct {
Index int `json:"index"` // 选项索引
Message *OpenAIRespChoiceMsg `json:"message,omitempty"` // 非流式生成的消息
Delta *OpenAIRespChoiceMsg `json:"delta,omitempty"` // 流式生成的消息
FinishReason string `json:"finish_reason"` // 停止原因
}
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"
}
Click to show internal directories.
Click to hide internal directories.