Documentation
¶
Index ¶
Constants ¶
const ChatGPTBackendAPIBase = "https://chatgpt.com/backend-api"
ChatGPTBackendAPIBase is the API base URL for ChatGPT/Codex OAuth provider
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnthropicBetaMessagesRequest ¶
type AnthropicBetaMessagesRequest struct {
Stream bool `json:"stream"`
anthropic.BetaMessageNewParams
}
Use official Anthropic SDK types directly
func (*AnthropicBetaMessagesRequest) UnmarshalJSON ¶
func (r *AnthropicBetaMessagesRequest) UnmarshalJSON(data []byte) error
type AnthropicMessagesRequest ¶
type AnthropicMessagesRequest struct {
Stream bool `json:"stream"`
anthropic.MessageNewParams
}
Request types
func (*AnthropicMessagesRequest) UnmarshalJSON ¶
func (r *AnthropicMessagesRequest) UnmarshalJSON(data []byte) error
type BetaRound ¶
type BetaRound struct {
Messages []anthropic.BetaMessageParam
IsCurrentRound bool
Stats *RoundStats // Optional metadata about the round structure
}
BetaRound represents a conversation round for v1beta API.
type Client ¶
type Client interface {
// APIStyle returns the type of provider this client implements
APIStyle() APIStyle
// Close closes any resources held by the client
Close() error
}
Client is the unified interface for AI provider clients
type Grouper ¶
type Grouper struct{}
Grouper provides methods to group messages into conversation rounds.
func (*Grouper) GroupBeta ¶
func (g *Grouper) GroupBeta(messages []anthropic.BetaMessageParam) []BetaRound
GroupBeta groups beta messages into conversation rounds.
func (*Grouper) GroupV1 ¶
func (g *Grouper) GroupV1(messages []anthropic.MessageParam) []V1Round
GroupV1 groups v1 messages into conversation rounds. A round starts with a pure user message and includes all subsequent messages (assistant with tool use, tool results) until the next pure user message (exclusive).
func (*Grouper) IsPureBetaUserMessage ¶
func (g *Grouper) IsPureBetaUserMessage(msg anthropic.BetaMessageParam) bool
IsPureBetaUserMessage checks if a beta message is a pure user instruction.
func (*Grouper) IsPureUserMessage ¶
func (g *Grouper) IsPureUserMessage(msg anthropic.MessageParam) bool
IsPureUserMessage checks if a v1 message is a pure user instruction (not a tool result).
type OpenAIChatCompletionRequest ¶
type OpenAIChatCompletionRequest struct {
openai.ChatCompletionNewParams
Stream bool `json:"stream"`
}
OpenAIChatCompletionRequest is a type alias for OpenAI chat completion request with extra fields.
func (*OpenAIChatCompletionRequest) UnmarshalJSON ¶
func (r *OpenAIChatCompletionRequest) UnmarshalJSON(data []byte) error
type RoundStats ¶
type RoundStats struct {
UserMessageCount int // Number of pure user messages in this round (should be 1)
AssistantCount int // Number of assistant messages
ToolResultCount int // Number of tool result messages
TotalMessages int // Total messages in the round
HasThinking bool // Whether any assistant message contains thinking blocks
}
RoundStats contains metadata about a round's message composition.
type Transformer ¶
type Transformer interface {
// HandleV1 handles compacting for Anthropic v1 requests.
HandleV1(req *anthropic.MessageNewParams) error
// HandleV1Beta handles compacting for Anthropic v1beta requests.
HandleV1Beta(req *anthropic.BetaMessageNewParams) error
}
Transformer defines the interface for request compacting transformations. Each handler method is responsible for a different request model type.
type V1Round ¶
type V1Round struct {
Messages []anthropic.MessageParam
IsCurrentRound bool
Stats *RoundStats // Optional metadata about the round structure
}
V1Round represents a conversation round for v1 API.