model_setting

package
v0.2.0-beta.9 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ClaudeDefaultMaxTokens = 8192

ClaudeDefaultMaxTokens is supplied to request snapshots when the persisted configuration has no default entry. It is never written back implicitly.

View Source
const ClaudeMaxTokensLimit = math.MaxInt32 / 2

ClaudeMaxTokensLimit matches the request-side billing bound. Defaults are injected after request validation, so they need the same upper limit.

Variables

This section is empty.

Functions

func GetGeminiSafetySetting

func GetGeminiSafetySetting(key string) string

GetGeminiSafetySetting 获取安全设置

func GetGeminiVersionSetting

func GetGeminiVersionSetting(key string) string

GetGeminiVersionSetting 获取版本设置

func IsGeminiModelSupportImagine

func IsGeminiModelSupportImagine(model string) bool

func IsSyncImageModel

func IsSyncImageModel(model string) bool

IsSyncImageModel

func ShouldPreserveThinkingSuffix

func ShouldPreserveThinkingSuffix(modelName string) bool

ShouldPreserveThinkingSuffix 判断模型是否配置为保留 thinking/-nothinking/-low/-high/-medium 后缀

func ValidateClaudeDefaultMaxTokens

func ValidateClaudeDefaultMaxTokens(value string) error

ValidateClaudeDefaultMaxTokens validates the JSON persisted by the option API. Zero stays allowed — the current Messages API accepts max_tokens: 0 as cache pre-warming — but negative values are rejected because they would wrap into huge unsigned values during request conversion.

func ValidateClaudeThinkingAdapterBudgetTokensPercentage

func ValidateClaudeThinkingAdapterBudgetTokensPercentage(value float64) error

ValidateClaudeThinkingAdapterBudgetTokensPercentage validates the fraction used to derive thinking budget_tokens. Restricting it to (0,1] keeps the derived budget finite, non-negative, and no larger than max_tokens.

func ValidateGeminiSafetySettings

func ValidateGeminiSafetySettings(value string) error

ValidateGeminiSafetySettings validates the JSON persisted by the option API. Empty values remain valid because read-time fallback returns the default.

func ValidateGeminiThinkingAdapterBudgetTokensPercentage

func ValidateGeminiThinkingAdapterBudgetTokensPercentage(value float64) error

ValidateGeminiThinkingAdapterBudgetTokensPercentage keeps the derived thinking budget finite and within the range accepted by the settings UI.

Types

type ChatCompletionsToResponsesPolicy

type ChatCompletionsToResponsesPolicy struct {
	Enabled       bool     `json:"enabled"`
	AllChannels   bool     `json:"all_channels"`
	ChannelIDs    []int    `json:"channel_ids,omitempty"`
	ChannelTypes  []int    `json:"channel_types,omitempty"`
	ModelPatterns []string `json:"model_patterns,omitempty"`
}

func (ChatCompletionsToResponsesPolicy) IsChannelEnabled

func (p ChatCompletionsToResponsesPolicy) IsChannelEnabled(channelID int, channelType int) bool

type ClaudeSettings

type ClaudeSettings struct {
	HeadersSettings                       map[string]map[string][]string `json:"model_headers_settings"`
	DefaultMaxTokens                      map[string]int                 `json:"default_max_tokens"`
	ThinkingAdapterEnabled                bool                           `json:"thinking_adapter_enabled"`
	ThinkingAdapterBudgetTokensPercentage float64                        `json:"thinking_adapter_budget_tokens_percentage"`
}

ClaudeSettings 定义Claude模型的配置

func GetClaudeSettings

func GetClaudeSettings() *ClaudeSettings

GetClaudeSettings 获取Claude配置

func (*ClaudeSettings) GetDefaultMaxTokens

func (c *ClaudeSettings) GetDefaultMaxTokens(model string) int

func (*ClaudeSettings) WriteHeaders

func (c *ClaudeSettings) WriteHeaders(originModel string, httpHeader *http.Header)

type GeminiSettings

type GeminiSettings struct {
	SafetySettings                        map[string]string `json:"safety_settings"`
	VersionSettings                       map[string]string `json:"version_settings"`
	SupportedImagineModels                []string          `json:"supported_imagine_models"`
	ThinkingAdapterEnabled                bool              `json:"thinking_adapter_enabled"`
	ThinkingAdapterBudgetTokensPercentage float64           `json:"thinking_adapter_budget_tokens_percentage"`
	FunctionCallThoughtSignatureEnabled   bool              `json:"function_call_thought_signature_enabled"`
	RemoveFunctionResponseIdEnabled       bool              `json:"remove_function_response_id_enabled"`
}

GeminiSettings defines Gemini model configuration. 注意bool要以enabled结尾才可以生效编辑

func GetGeminiSettings

func GetGeminiSettings() *GeminiSettings

GetGeminiSettings 获取Gemini配置

func (GeminiSettings) SafetySetting

func (settings GeminiSettings) SafetySetting(key string) string

SafetySetting returns the effective safety threshold from this settings snapshot. Empty exact/default values retain the legacy fallback to OFF.

func (GeminiSettings) SupportsImagine

func (settings GeminiSettings) SupportsImagine(model string) bool

SupportsImagine reports whether this settings snapshot enables the model's image capability using the legacy exact-match rule.

type GlobalSettings

type GlobalSettings struct {
	PassThroughRequestEnabled        bool                             `json:"pass_through_request_enabled"`
	ThinkingModelBlacklist           []string                         `json:"thinking_model_blacklist"`
	ChatCompletionsToResponsesPolicy ChatCompletionsToResponsesPolicy `json:"chat_completions_to_responses_policy"`
}

func GetGlobalSettings

func GetGlobalSettings() *GlobalSettings

func (GlobalSettings) ShouldPreserveThinkingSuffix

func (settings GlobalSettings) ShouldPreserveThinkingSuffix(modelName string) bool

ShouldPreserveThinkingSuffix reports whether this settings snapshot keeps the model's thinking suffix using the existing exact-match rule.

type GrokSettings

type GrokSettings struct {
	ViolationDeductionEnabled bool    `json:"violation_deduction_enabled"`
	ViolationDeductionAmount  float64 `json:"violation_deduction_amount"`
}

GrokSettings defines Grok model configuration.

func GetGrokSettings

func GetGrokSettings() *GrokSettings

type QwenSettings

type QwenSettings struct {
	SyncImageModels []string `json:"sync_image_models"`
}

QwenSettings defines Qwen model configuration. 注意bool要以enabled结尾才可以生效编辑

func GetQwenSettings

func GetQwenSettings() *QwenSettings

GetQwenSettings

Jump to

Keyboard shortcuts

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