modelbuilder

package
v0.0.0-...-a3cc282 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildModel

func BuildModel(ctx context.Context, cfg *ModelConfig, opts ...BuildOption) (model.ToolCallingChatModel, error)

func SupportedModelClass

func SupportedModelClass(modelClass ModelClass) bool

Types

type ArkConnectionInfo

type ArkConnectionInfo struct {
	Region string `json:"region,omitempty" yaml:"region,omitempty"`
}

type BuildOption

type BuildOption func(p *LLMParams)

func WithLLMEnableThinking

func WithLLMEnableThinking(enable bool) BuildOption

func WithLLMFrequencyPenalty

func WithLLMFrequencyPenalty(penalty float32) BuildOption

func WithLLMMaxTokens

func WithLLMMaxTokens(maxTokens int) BuildOption

func WithLLMPresencePenalty

func WithLLMPresencePenalty(penalty float32) BuildOption

func WithLLMResponseFormat

func WithLLMResponseFormat(format ResponseFormat) BuildOption

func WithLLMTemperature

func WithLLMTemperature(temp float32) BuildOption

func WithLLMTopK

func WithLLMTopK(topK int32) BuildOption

func WithLLMTopP

func WithLLMTopP(topP float32) BuildOption

type Builder

type Builder interface {
	Build(ctx context.Context, params *LLMParams) (model.ToolCallingChatModel, error)
}

func NewBuilder

func NewBuilder(cfg *ModelConfig) (Builder, error)

type ConnectionInfo

type ConnectionInfo struct {
	APIKey  string `json:"api_key" yaml:"api_key"`
	BaseURL string `json:"base_url,omitempty" yaml:"base_url,omitempty"`
	Model   string `json:"model" yaml:"model"`

	Ark    *ArkConnectionInfo    `json:"ark,omitempty" yaml:"ark,omitempty"`
	OpenAI *OpenAIConnectionInfo `json:"openai,omitempty" yaml:"openai,omitempty"`
	Gemini *GeminiConnectionInfo `json:"gemini,omitempty" yaml:"gemini,omitempty"`
}

type GeminiConnectionInfo

type GeminiConnectionInfo struct {
	Backend  string `json:"backend,omitempty" yaml:"backend,omitempty"`
	Project  string `json:"project,omitempty" yaml:"project,omitempty"`
	Location string `json:"location,omitempty" yaml:"location,omitempty"`
}

type LLMParams

type LLMParams struct {
	Temperature      *float32       `json:"temperature,omitempty" yaml:"temperature,omitempty"`
	FrequencyPenalty *float32       `json:"frequency_penalty,omitempty" yaml:"frequency_penalty,omitempty"`
	PresencePenalty  *float32       `json:"presence_penalty,omitempty" yaml:"presence_penalty,omitempty"`
	MaxTokens        *int           `json:"max_tokens,omitempty" yaml:"max_tokens,omitempty"`
	TopP             *float32       `json:"top_p,omitempty" yaml:"top_p,omitempty"`
	TopK             *int32         `json:"top_k,omitempty" yaml:"top_k,omitempty"`
	ResponseFormat   ResponseFormat `json:"response_format,omitempty" yaml:"response_format,omitempty"`
	EnableThinking   *bool          `json:"enable_thinking,omitempty" yaml:"enable_thinking,omitempty"`
}

type ModelClass

type ModelClass string
const (
	ModelClassArk      ModelClass = "ark"
	ModelClassOpenAI   ModelClass = "openai"
	ModelClassClaude   ModelClass = "claude"
	ModelClassDeepSeek ModelClass = "deepseek"
	ModelClassGemini   ModelClass = "gemini"
	ModelClassOllama   ModelClass = "ollama"
	ModelClassQwen     ModelClass = "qwen"
)

func ListSupportedModelClasses

func ListSupportedModelClasses() []ModelClass

type ModelConfig

type ModelConfig struct {
	ModelClass   ModelClass      `json:"model_class" yaml:"model_class"`
	Connection   *ConnectionInfo `json:"connection" yaml:"connection"`
	ThinkingType ThinkingType    `json:"thinking_type,omitempty" yaml:"thinking_type,omitempty"`
}

func LoadConfigFromEnv

func LoadConfigFromEnv() *ModelConfig

type OpenAIConnectionInfo

type OpenAIConnectionInfo struct {
	ByAzure    bool   `json:"by_azure,omitempty" yaml:"by_azure,omitempty"`
	APIVersion string `json:"api_version,omitempty" yaml:"api_version,omitempty"`
}

type ResponseFormat

type ResponseFormat string
const (
	ResponseFormatText     ResponseFormat = "text"
	ResponseFormatJSON     ResponseFormat = "json"
	ResponseFormatMarkdown ResponseFormat = "markdown"
)

type ThinkingType

type ThinkingType string
const (
	ThinkingTypeAuto    ThinkingType = "auto"
	ThinkingTypeEnable  ThinkingType = "enable"
	ThinkingTypeDisable ThinkingType = "disable"
)

Jump to

Keyboard shortcuts

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