mp_common

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

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)
}

func NewEmbeddingResp

func NewEmbeddingResp(raw string) IEmbeddingResp

type ILLMReq

type ILLMReq interface {
	Stream() bool
	Data() map[string]interface{}
	OpenAIReq() (*OpenAILLMReq, bool)
}

func NewLLMReq

func NewLLMReq(data map[string]interface{}) ILLMReq

type ILLMResp

type ILLMResp interface {
	String() string
	Data() (map[string]interface{}, bool)
	OpenAIResp() (*OpenAILLMResp, bool)
}

func NewLLMResp

func NewLLMResp(stream bool, raw string) ILLMResp

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)
}

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 OpenAIMsg

type OpenAIMsg struct {
	Role    string `json:"role" validate:"required"` // "system" | "user" | "assistant" | "function(已弃用)"
	Content string `json:"content" validate:"required"`
}

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 OpenAIRespChoiceMsg struct {
	Content string `json:"content"`
	Role    string `json:"role"`
}

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"
}

Jump to

Keyboard shortcuts

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