domain

package
v1.4.452 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTemperature      = 0.7
	DefaultTopP             = 0.9
	DefaultPresencePenalty  = 0.0
	DefaultFrequencyPenalty = 0.0
)

Default values for chat options (must match cli/flags.go defaults)

View Source
const (
	// TokenBudgetLow is suitable for basic reasoning or smaller models (e.g., 1k context window).
	TokenBudgetLow int64 = 1024
	// TokenBudgetMedium is suitable for intermediate reasoning or mid-sized models (e.g., 2k context window).
	TokenBudgetMedium int64 = 2048
	// TokenBudgetHigh is suitable for advanced reasoning or large models (e.g., 4k context window).
	TokenBudgetHigh int64 = 4096
)

ThinkingBudgets defines standardized token budgets for reasoning-enabled models. The map assigns a maximum token count to each ThinkingLevel, representing the amount of context or computation that can be used for reasoning at that level. These values (e.g., 1024 for low, 2048 for medium, 4096 for high) are used to Token budget constants for each ThinkingLevel. These values are chosen to align with typical context window sizes for LLMs at different reasoning levels. Adjust these if model capabilities change.

View Source
const ChatMessageRoleMeta = "meta"
View Source
const FileChangesMarker = "__CREATE_CODING_FEATURE_FILE_CHANGES__"

FileChangesMarker identifies the start of a file changes section in output

View Source
const (
	// MaxFileSize is the maximum size of a file that can be created (10MB)
	MaxFileSize = 10 * 1024 * 1024
)

Variables

ThinkingBudgets defines standardized token budgets for reasoning-enabled models.

Functions

func ApplyFileChanges

func ApplyFileChanges(projectRoot string, changes []FileChange) error

ApplyFileChanges applies the parsed file changes to the file system

func NormalizeMessages

func NormalizeMessages(msgs []*chat.ChatCompletionMessage, defaultUserMessage string) (ret []*chat.ChatCompletionMessage)

NormalizeMessages remove empty messages and ensure messages order user-assist-user

func StripThinkBlocks added in v1.4.252

func StripThinkBlocks(input, startTag, endTag string) string

Types

type Attachment

type Attachment struct {
	Type    *string `json:"type,omitempty"`
	Path    *string `json:"path,omitempty"`
	URL     *string `json:"url,omitempty"`
	Content []byte  `json:"content,omitempty"`
	ID      *string `json:"id,omitempty"`
}

func NewAttachment

func NewAttachment(value string) (ret *Attachment, err error)

func (*Attachment) Base64Content

func (a *Attachment) Base64Content() (ret string, err error)

func (*Attachment) ContentBytes

func (a *Attachment) ContentBytes() (ret []byte, err error)

func (*Attachment) GetId

func (a *Attachment) GetId() (ret string, err error)

func (*Attachment) ResolveType

func (a *Attachment) ResolveType() (ret string, err error)

type ChatOptions

type ChatOptions struct {
	Model               string
	Temperature         float64
	TopP                float64
	PresencePenalty     float64
	FrequencyPenalty    float64
	Raw                 bool
	Seed                int
	Thinking            ThinkingLevel
	ModelContextLength  int
	MaxTokens           int
	Search              bool
	SearchLocation      string
	ImageFile           string
	ImageSize           string
	ImageQuality        string
	ImageCompression    int
	ImageBackground     string
	SuppressThink       bool
	ThinkStartTag       string
	ThinkEndTag         string
	AudioOutput         bool
	AudioFormat         string
	Voice               string
	Notification        bool
	NotificationCommand string
	ShowMetadata        bool
	Quiet               bool
	UpdateChan          chan StreamUpdate `json:"-"`
}

type ChatRequest

type ChatRequest struct {
	ContextName           string
	SessionName           string
	PatternName           string
	PatternVariables      map[string]string
	Message               *chat.ChatCompletionMessage
	Language              string
	Meta                  string
	InputHasVars          bool
	NoVariableReplacement bool
	StrategyName          string
}

type FileChange

type FileChange struct {
	Operation string `json:"operation"` // "create" or "update"
	Path      string `json:"path"`      // Relative path from project root
	Content   string `json:"content"`   // New file content
}

FileChange represents a single file change operation to be performed

func ParseFileChanges

func ParseFileChanges(output string) (changeSummary string, changes []FileChange, err error)

ParseFileChanges extracts and parses the file change marker section from LLM output

type StreamType added in v1.4.367

type StreamType string

StreamType distinguishes between partial text content and metadata events.

const (
	StreamTypeContent StreamType = "content"
	StreamTypeUsage   StreamType = "usage"
	StreamTypeError   StreamType = "error"
)

type StreamUpdate added in v1.4.367

type StreamUpdate struct {
	Type    StreamType     `json:"type"`
	Content string         `json:"content,omitempty"` // For text deltas
	Usage   *UsageMetadata `json:"usage,omitempty"`   // For token counts
}

StreamUpdate is the unified payload sent through the internal channels.

type ThinkingLevel added in v1.4.286

type ThinkingLevel string

ThinkingLevel represents reasoning/thinking levels supported across providers.

const (
	ThinkingOff    ThinkingLevel = "off"
	ThinkingLow    ThinkingLevel = "low"
	ThinkingMedium ThinkingLevel = "medium"
	ThinkingHigh   ThinkingLevel = "high"
)

type UsageMetadata added in v1.4.367

type UsageMetadata struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
	TotalTokens  int `json:"total_tokens"`
}

UsageMetadata normalizes token counts across different providers.

Jump to

Keyboard shortcuts

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