Documentation
¶
Index ¶
- Constants
- func EstimateMessageTokens(messages []providers.ChatMessage) int
- func PruneHistoryToFit(messages []providers.ChatMessage, maxChars int) []providers.ChatMessage
- func RecordRequest(entry RequestLog)
- func SanitizeAndGuardrailMessages(messages []providers.ChatMessage, maxToolChars int) []providers.ChatMessage
- type AnthropicContentBlock
- type AnthropicMessage
- type AnthropicMessageRequest
- type ExtractedToolCall
- type LogHub
- type RequestLog
- type Server
- type VncManager
- type VncSession
- type XmlStreamParser
Constants ¶
const ( // DefaultMaxToolResultChars limits single tool output to ~30k chars (~7.5k tokens) DefaultMaxToolResultChars = 30000 // DefaultMaxTotalContextChars limits entire conversation history to ~800k chars (~200k tokens) // matching Claude Code, Gemini, and modern frontier LLM context windows. DefaultMaxTotalContextChars = 800000 )
Variables ¶
This section is empty.
Functions ¶
func EstimateMessageTokens ¶ added in v0.3.0
func EstimateMessageTokens(messages []providers.ChatMessage) int
EstimateMessageTokens provides an approximation of token count
func PruneHistoryToFit ¶ added in v0.3.0
func PruneHistoryToFit(messages []providers.ChatMessage, maxChars int) []providers.ChatMessage
PruneHistoryToFit keeps the leading system prompt and the latest N messages within maxChars
func RecordRequest ¶ added in v0.3.0
func RecordRequest(entry RequestLog)
RecordRequest records a completed request into the ring buffer and notifies SSE subscribers
func SanitizeAndGuardrailMessages ¶ added in v0.3.0
func SanitizeAndGuardrailMessages(messages []providers.ChatMessage, maxToolChars int) []providers.ChatMessage
SanitizeAndGuardrailMessages strips historical thinking blocks from older turns as required by upstream APIs, while preserving 100% of messages, turns, tool outputs, and context without artificial gateway limits.
Types ¶
type AnthropicContentBlock ¶ added in v0.2.0
type AnthropicMessage ¶ added in v0.2.0
type AnthropicMessage struct {
Role string `json:"role"`
Content interface{} `json:"content"` // string or []AnthropicContentBlock
}
type AnthropicMessageRequest ¶ added in v0.2.0
type AnthropicMessageRequest struct {
Model string `json:"model"`
Messages []AnthropicMessage `json:"messages"`
System interface{} `json:"system,omitempty"` // string or []contentBlock
MaxTokens int `json:"max_tokens,omitempty"`
Stream bool `json:"stream,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Tools []interface{} `json:"tools,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
}
AnthropicMessageRequest represents an incoming /v1/messages POST request
type ExtractedToolCall ¶ added in v0.3.0
type ExtractedToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Input map[string]interface{} `json:"input"`
}
func ExtractXmlToolCalls ¶ added in v0.3.0
func ExtractXmlToolCalls(text string) (string, []ExtractedToolCall)
ExtractXmlToolCalls finds <tool_use>, <tool_call>, or <invoke> blocks in static text
type LogHub ¶ added in v0.3.0
type LogHub struct {
// contains filtered or unexported fields
}
LogHub manages the in-memory request ring buffer and live SSE subscribers
type RequestLog ¶ added in v0.3.0
type RequestLog struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Endpoint string `json:"endpoint"`
Model string `json:"model"`
Provider string `json:"provider,omitempty"`
AccountID string `json:"account_id,omitempty"`
StatusCode int `json:"status_code"`
DurationMs int64 `json:"duration_ms"`
Tokens int `json:"tokens,omitempty"`
InputTokens int `json:"input_tokens,omitempty"`
OutputTokens int `json:"output_tokens,omitempty"`
Error string `json:"error,omitempty"`
PromptPreview string `json:"prompt_preview,omitempty"`
ResponsePreview string `json:"response_preview,omitempty"`
ClientIP string `json:"client_ip,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
TTFBMs int64 `json:"ttfb_ms,omitempty"`
}
RequestLog represents a single tracked request through GoRoute
func GetLogByID ¶ added in v0.5.0
func GetLogByID(id string) (RequestLog, bool)
GetLogByID looks up a log entry by ID in memory or SQLite
func GetRecentLogs ¶ added in v0.3.0
func GetRecentLogs() []RequestLog
GetRecentLogs returns a copy of recent request logs
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Reload ¶ added in v0.3.0
Reload reads the configuration from disk and re-registers all providers and combos dynamically
func (*Server) SetConfigPaths ¶ added in v0.3.0
type VncManager ¶ added in v0.4.0
type VncManager struct {
// contains filtered or unexported fields
}
type VncSession ¶ added in v0.4.0
type XmlStreamParser ¶ added in v0.3.0
type XmlStreamParser struct {
// contains filtered or unexported fields
}
XmlStreamParser handles streaming text deltas and intercepts XML tool calls across chunks.
func NewXmlStreamParser ¶ added in v0.3.0
func NewXmlStreamParser() *XmlStreamParser
func (*XmlStreamParser) Feed ¶ added in v0.3.0
func (p *XmlStreamParser) Feed(chunk string) (string, []ExtractedToolCall)
func (*XmlStreamParser) Flush ¶ added in v0.3.0
func (p *XmlStreamParser) Flush() string