Help us shape the future of Go! Take the 2026 Go Developer Survey

domain

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Models []ModelMetadata
View Source
var TypeModelMap map[consts.ModelType][]ModelMetadata

Functions

This section is empty.

Types

type CheckModelReq

type CheckModelReq struct {
	Provider   string      `` /* 181-byte string literal not displayed */
	Model      string      `json:"model" query:"model_name" validate:"required"`
	BaseURL    string      `json:"base_url" query:"base_url" validate:"required"`
	APIKey     string      `json:"api_key" query:"api_key"`
	APIHeader  string      `json:"api_header" query:"api_header"`
	APIVersion string      `json:"api_version" query:"api_version"` // for azure openai
	Type       string      `json:"type" query:"model_type" validate:"required,oneof=chat embedding rerank llm"`
	Param      *ModelParam `json:"param" query:"param"`
}

type CheckModelResp

type CheckModelResp struct {
	Error   string `json:"error"`
	Content string `json:"content"`
}

type GPUStackListModelResp added in v2.3.0

type GPUStackListModelResp struct {
	Items []*struct {
		Name string `json:"name"`
	} `json:"items"`
}

func (*GPUStackListModelResp) ParseModels added in v2.3.0

func (o *GPUStackListModelResp) ParseModels() []ModelListItem

ParseModels 实现ModelResponseParser接口

type GithubModel

type GithubModel struct {
	ID            string   `json:"id"`
	Name          string   `json:"name"`
	Registry      string   `json:"registry"`
	Publisher     string   `json:"publisher"`
	Summary       string   `json:"summary"`
	RateLimitTier string   `json:"rate_limit_tier"`
	HTMLURL       string   `json:"html_url"`
	Version       string   `json:"version"`
	Capabilities  []string `json:"capabilities"`
	Limits        struct {
		MaxInputTokens  int `json:"max_input_tokens"`
		MaxOutputTokens int `json:"max_output_tokens"`
	} `json:"limits"`
	Tags                      []string `json:"tags"`
	SupportedInputModalities  []string `json:"supported_input_modalities"`
	SupportedOutputModalities []string `json:"supported_output_modalities"`
}

type GithubResp

type GithubResp []GithubModel

func (*GithubResp) ParseModels

func (g *GithubResp) ParseModels() []ModelListItem

ParseModels 实现ModelResponseParser接口

type IModelProvider

type IModelProvider[T any] interface {
	ListModel(subType string, provider string) ([]T, error)
}

type ModelKit

type ModelKit interface {
}

type ModelListItem

type ModelListItem struct {
	Model string `json:"model"`
}

func From

func From(ModelProvider ModelProvider) []ModelListItem

type ModelListReq

type ModelListReq struct {
	Provider  string `json:"provider" query:"provider" validate:"required"`
	BaseURL   string `json:"base_url" query:"base_url" validate:"required"`
	APIKey    string `json:"api_key" query:"api_key"`
	APIHeader string `json:"api_header" query:"api_header"`
	Type      string `json:"type" query:"type" validate:"required"`
}

type ModelListResp

type ModelListResp struct {
	Models []ModelListItem `json:"models"`
	Error  string          `json:"error"`
}

type ModelMetadata

type ModelMetadata struct {
	// 基础参数
	ModelName string               `json:"id"`         // 模型的名字
	Object    string               `json:"object"`     // 总是model
	Created   int                  `json:"created"`    // 创建时间
	Provider  consts.ModelProvider `json:"provider"`   // 提供商
	ModelType consts.ModelType     `json:"model_type"` // 模型类型
	// api 调用相关参数
	BaseURL    string `json:"base_url"`
	APIKey     string `json:"api_key"`
	APIHeader  string `json:"api_header"`
	APIVersion string `json:"api_version"` // for azure openai
	// 高级参数
	// 限制生成的最大token数量,可选,默认为模型最大值, Ollama不支持
	MaxTokens *int `json:"max_tokens"`
	// 采样温度参数,建议与TopP二选一,范围0-2,值越大输出越随机,可选,默认1.0
	Temperature *float32 `json:"temperature"`
	// 控制采样多样性,建议与Temperature二选一,范围0-1,值越小输出越聚焦,可选,默认1.0
	TopP *float32 `json:"top_p"`
	// API停止生成的序列标记,可选,例如:[]string{"\n", "User:"}
	Stop []string `json:"stop"`
	// 基于存在惩罚重复,范围-2到2,正值增加新主题可能性,可选,默认0, Gemini不支持
	PresencePenalty *float32 `json:"presence_penalty"`
	// 指定模型响应的格式,可选,用于结构化输出, DS,Gemini,Ollama不支持
	ResponseFormat *openai.ChatCompletionResponseFormat `json:"response_format"`
	// 启用确定性采样以获得一致输出,可选,用于可重现结果,  DS,Gemini不支持
	Seed *int `json:"seed"`
	// 基于频率惩罚重复,范围-2到2,正值降低重复可能性,可选,默认0, Gemini不支持
	FrequencyPenalty *float32 `json:"frequency_penalty"`
	// 修改特定token在补全中出现的可能性,可选,token ID到偏置值(-100到100)的映射, DS,Gemini,Ollama不支持
	LogitBias map[string]int `json:"logit_bias"`
}

type ModelParam added in v2.5.0

type ModelParam struct {
	ContextWindow      int      `json:"context_window"`
	MaxTokens          int      `json:"max_tokens"`
	R1Enabled          bool     `json:"r1_enabled"`
	SupportComputerUse bool     `json:"support_computer_use"`
	SupportImages      bool     `json:"support_images"`
	SupportPromptCache bool     `json:"support_prompt_cache"`
	Temperature        *float32 `json:"temperature"`
}

type ModelProvider

type ModelProvider struct {
	OwnerName  consts.ModelProvider `json:"owner_name"`  // 提供商
	APIBase    string               `json:"api_base"`    // 接口地址 如:https://api.qwen.com
	APIKey     string               `json:"api_key"`     // 接口密钥 如:sk-xxxx
	APIVersion string               `json:"api_version"` // 接口版本 如:2023-05-15
	APIHeader  string               `json:"api_header"`  // 接口头 如:Authorization: Bearer sk-xxxx
	Models     []ModelMetadata      `json:"models"`      // 模型列表
}

type ModelResponseParser

type ModelResponseParser interface {
	ParseModels() []ModelListItem
}

ModelResponseParser 定义模型响应解析器接口

type OpenAIData

type OpenAIData struct {
	ID string `json:"id"`
}

type OpenAIResp

type OpenAIResp struct {
	Object string        `json:"object"`
	Data   []*OpenAIData `json:"data"`
}

func (*OpenAIResp) ParseModels

func (o *OpenAIResp) ParseModels() []ModelListItem

ParseModels 实现ModelResponseParser接口

type Response

type Response struct {
	Message string `json:"message"`
	Success bool   `json:"success"`
	Data    any    `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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