Documentation
¶
Index ¶
- Constants
- Variables
- func AnthropicMessagesURL(base string) string
- func ApplyChatReasoning(cfg *config.Root, p *openai.ChatCompletionNewParams, forceDisable bool)
- func ApplyMaxResponseTokens(cfg *config.Root, p *openai.ChatCompletionNewParams)
- func ApplyProviderSimpleParams(proto Protocol, cfg *config.Root, openaiParams *openai.ChatCompletionNewParams, ...)
- func ApplyProviderTurnParams(proto Protocol, cfg *config.Root, openaiParams *openai.ChatCompletionNewParams, ...)
- func ApplyReasoningDisable(p *openai.ChatCompletionNewParams)
- func ApplySimpleReasoning(cfg *config.Root, p *openai.ChatCompletionNewParams, forceDisable bool)
- func BackoffDelay(policy config.APIResiliencePolicy, attempt int, retryAfter time.Duration, ...) time.Duration
- func BackspaceOverAtomicReplToken(line []rune, pos int) ([]rune, int, bool)
- func BackspaceOverImgTag(line []rune, pos int) ([]rune, int, bool)
- func BuildUserContentParts(content string, imageFiles map[int]string) []openai.ChatCompletionContentPartUnionParam
- func CanonicalizeUserLineForStorage(line string, imageFiles map[int]string) string
- func CountTurnPrompt(req TurnRequest) int64
- func DeleteForwardOverAtomicReplToken(line []rune, pos int) ([]rune, int, bool)
- func DeleteForwardOverImgTag(line []rune, pos int) ([]rune, int, bool)
- func HostKeyFromBaseURL(baseURL string) string
- func ImagePlaceholder(seq int, imagePath string) string
- func JumpLeftOverAtomicReplToken(line []rune, pos int) int
- func JumpLeftOverImgTag(line []rune, pos int) int
- func JumpRightOverAtomicReplToken(line []rune, pos int) int
- func JumpRightOverImgTag(line []rune, pos int) int
- func LastAssistantIndex(msgs []chatstore.Message) int
- func MessageForAPI(m chatstore.Message, includeReasoning bool) chatstore.Message
- func MessageParams(system string, msgs []chatstore.Message, imageFiles map[int]string) []openai.ChatCompletionMessageParamUnion
- func MessagesForAPI(msgs []chatstore.Message) []chatstore.Message
- func ModelID(s string) shared.ChatModel
- func NewResilientHTTPClient(policy config.APIResiliencePolicy) *http.Client
- func NormalizeREPLBuffer(line []rune, pos int) ([]rune, int)
- func OpenAIClientFromBackend(b CompletionBackend) (openai.Client, bool)
- func ParseCursorToolEventFromChunkRawJSON(raw string) string
- func PopulateAssistantTurnUsage(dst *chatstore.Message, system string, msgsPrior []chatstore.Message, ...)
- func PromptDisplaySplit(system string, msgs []chatstore.Message, apiPromptTokens int64) (contextTok int64, lastUserTok int64)
- func RetryMessage(attempt, max int, err error, wait time.Duration) string
- func UsagePromptParts(system string, msgs []chatstore.Message, promptTokens int64, ...) (contextTok int64, lastUserTok int64, contextEstimated bool)
- func UsageTokensDisplayParts(system string, msgs []chatstore.Message, u UsageStats, turnCount int) (contextTok, lastUserTok int64, contextEstimated bool, ...)
- func UserFacingAPIError(err error) string
- type AnthropicAuth
- type AnthropicBackend
- type AnthropicUsagePayload
- type AssistantToolCall
- type AssistantTurnResult
- type CircuitRegistry
- type CompletionBackend
- type ErrorClass
- type OpenAIBackend
- func (b *OpenAIBackend) CompleteText(ctx context.Context, req SimpleCompletionRequest) (string, error)
- func (b *OpenAIBackend) ListModels(ctx context.Context) ([]string, error)
- func (b *OpenAIBackend) Protocol() Protocol
- func (b *OpenAIBackend) StreamText(ctx context.Context, req SimpleCompletionRequest, contentOut io.Writer, ...) (string, UsageStats, error)
- func (b *OpenAIBackend) StreamTurn(ctx context.Context, req TurnRequest, contentOut io.Writer, opts StreamOpts) (AssistantTurnResult, error)
- type Protocol
- type ProviderHTTPError
- type ResilientBackend
- func (b *ResilientBackend) CompleteText(ctx context.Context, req SimpleCompletionRequest) (string, error)
- func (b *ResilientBackend) ListModels(ctx context.Context) ([]string, error)
- func (b *ResilientBackend) Protocol() Protocol
- func (b *ResilientBackend) StreamText(ctx context.Context, req SimpleCompletionRequest, contentOut io.Writer, ...) (string, UsageStats, error)
- func (b *ResilientBackend) StreamTurn(ctx context.Context, req TurnRequest, contentOut io.Writer, opts StreamOpts) (AssistantTurnResult, error)
- type SimpleCompletionRequest
- type StreamOpts
- type ToolDef
- type TurnRequest
- type UsageStats
Constants ¶
View Source
const ( ProtocolOpenAI = apitype.ProtocolOpenAI ProtocolAnthropic = apitype.ProtocolAnthropic )
View Source
const AnthropicAPIVersion = anthropic.APIVersion
View Source
const AnthropicOAuthBeta = anthropic.OAuthBeta
Variables ¶
View Source
var ErrCircuitOpen = errors.New("provider temporarily unavailable")
View Source
var ErrStreamAccumulatorRejected = stream.ErrStreamAccumulatorRejected
Functions ¶
func AnthropicMessagesURL ¶
func ApplyChatReasoning ¶
func ApplyChatReasoning(cfg *config.Root, p *openai.ChatCompletionNewParams, forceDisable bool)
func ApplyMaxResponseTokens ¶
func ApplyMaxResponseTokens(cfg *config.Root, p *openai.ChatCompletionNewParams)
func ApplyProviderTurnParams ¶
func ApplyReasoningDisable ¶
func ApplyReasoningDisable(p *openai.ChatCompletionNewParams)
func ApplySimpleReasoning ¶
func ApplySimpleReasoning(cfg *config.Root, p *openai.ChatCompletionNewParams, forceDisable bool)
func BackoffDelay ¶
func BackspaceOverAtomicReplToken ¶ added in v2026.606.3
func BackspaceOverImgTag ¶ added in v2026.602.2
func BuildUserContentParts ¶
func BuildUserContentParts(content string, imageFiles map[int]string) []openai.ChatCompletionContentPartUnionParam
func CanonicalizeUserLineForStorage ¶ added in v2026.602.2
func CountTurnPrompt ¶ added in v2026.611.1
func CountTurnPrompt(req TurnRequest) int64
func DeleteForwardOverAtomicReplToken ¶ added in v2026.606.3
func DeleteForwardOverImgTag ¶ added in v2026.602.2
func HostKeyFromBaseURL ¶
func ImagePlaceholder ¶
func JumpLeftOverAtomicReplToken ¶ added in v2026.606.3
func JumpLeftOverImgTag ¶
func JumpRightOverAtomicReplToken ¶ added in v2026.606.3
func JumpRightOverImgTag ¶
func LastAssistantIndex ¶
func MessageForAPI ¶
func MessageParams ¶
func MessageParams(system string, msgs []chatstore.Message, imageFiles map[int]string) []openai.ChatCompletionMessageParamUnion
MessageParams builds OpenAI API message params from chatstore messages. If imageFiles is non-nil and contains entries for [img-<n>] placeholders found in user messages, those placeholders are replaced with image content parts.
func NewResilientHTTPClient ¶
func NewResilientHTTPClient(policy config.APIResiliencePolicy) *http.Client
func NormalizeREPLBuffer ¶ added in v2026.602.2
func OpenAIClientFromBackend ¶
func OpenAIClientFromBackend(b CompletionBackend) (openai.Client, bool)
func ParseCursorToolEventFromChunkRawJSON ¶ added in v2026.606.0
func PromptDisplaySplit ¶
func UsagePromptParts ¶
func UsageTokensDisplayParts ¶
func UserFacingAPIError ¶
Types ¶
type AnthropicAuth ¶
func AnthropicAuthFromAPIKey ¶
func AnthropicAuthFromAPIKey(token string) AnthropicAuth
func AnthropicAuthFromOAuthBearer ¶
func AnthropicAuthFromOAuthBearer(token string) AnthropicAuth
type AnthropicBackend ¶
func NewAnthropicBackend ¶
func NewAnthropicBackend(baseURL string, auth AnthropicAuth) *AnthropicBackend
func NewAnthropicBackendWithClient ¶
func NewAnthropicBackendWithClient(baseURL string, auth AnthropicAuth, client *http.Client) *AnthropicBackend
type AnthropicUsagePayload ¶
type AnthropicUsagePayload = anthropic.UsagePayload
type AssistantToolCall ¶
type AssistantToolCall = apitype.AssistantToolCall
type AssistantTurnResult ¶
type AssistantTurnResult = apitype.AssistantTurnResult
func StreamAssistantTurn ¶
func StreamAssistantTurn(ctx context.Context, client openai.Client, params openai.ChatCompletionNewParams, contentOut io.Writer, opts StreamOpts) (AssistantTurnResult, error)
type CircuitRegistry ¶
type CircuitRegistry struct {
// contains filtered or unexported fields
}
func NewCircuitRegistry ¶
func NewCircuitRegistry() *CircuitRegistry
func (*CircuitRegistry) IsOpen ¶
func (c *CircuitRegistry) IsOpen(hostKey string) bool
func (*CircuitRegistry) Reset ¶
func (c *CircuitRegistry) Reset(hostKey string)
type CompletionBackend ¶
type CompletionBackend = apitype.CompletionBackend
func NewCompletionBackend ¶
type ErrorClass ¶
type ErrorClass int
const ( ErrorPermanent ErrorClass = iota ErrorRetryable ErrorCircuitOpen )
func ClassifyAPIError ¶
type OpenAIBackend ¶
func (*OpenAIBackend) CompleteText ¶
func (b *OpenAIBackend) CompleteText(ctx context.Context, req SimpleCompletionRequest) (string, error)
func (*OpenAIBackend) ListModels ¶
func (b *OpenAIBackend) ListModels(ctx context.Context) ([]string, error)
func (*OpenAIBackend) Protocol ¶
func (b *OpenAIBackend) Protocol() Protocol
func (*OpenAIBackend) StreamText ¶
func (b *OpenAIBackend) StreamText(ctx context.Context, req SimpleCompletionRequest, contentOut io.Writer, opts StreamOpts) (string, UsageStats, error)
func (*OpenAIBackend) StreamTurn ¶
func (b *OpenAIBackend) StreamTurn(ctx context.Context, req TurnRequest, contentOut io.Writer, opts StreamOpts) (AssistantTurnResult, error)
type ProviderHTTPError ¶
type ProviderHTTPError = transport.ProviderHTTPError
func NewProviderHTTPError ¶
func NewProviderHTTPError(status int, message string, retryAfter time.Duration) *ProviderHTTPError
type ResilientBackend ¶
type ResilientBackend struct {
Inner CompletionBackend
HostKey string
Policy config.APIResiliencePolicy
Circuits *CircuitRegistry
SidecarRevive func(context.Context, error)
// contains filtered or unexported fields
}
func NewResilientBackend ¶
func NewResilientBackend(inner CompletionBackend, hostKey string, policy config.APIResiliencePolicy, circuits *CircuitRegistry) *ResilientBackend
func (*ResilientBackend) CompleteText ¶
func (b *ResilientBackend) CompleteText(ctx context.Context, req SimpleCompletionRequest) (string, error)
func (*ResilientBackend) ListModels ¶
func (b *ResilientBackend) ListModels(ctx context.Context) ([]string, error)
func (*ResilientBackend) Protocol ¶
func (b *ResilientBackend) Protocol() Protocol
func (*ResilientBackend) StreamText ¶
func (b *ResilientBackend) StreamText(ctx context.Context, req SimpleCompletionRequest, contentOut io.Writer, opts StreamOpts) (string, UsageStats, error)
func (*ResilientBackend) StreamTurn ¶
func (b *ResilientBackend) StreamTurn(ctx context.Context, req TurnRequest, contentOut io.Writer, opts StreamOpts) (AssistantTurnResult, error)
type SimpleCompletionRequest ¶
type SimpleCompletionRequest = apitype.SimpleCompletionRequest
type StreamOpts ¶
type StreamOpts = apitype.StreamOpts
type ToolDef ¶
func ToolDefsFromOpenAI ¶
func ToolDefsFromOpenAI(tools []openai.ChatCompletionToolUnionParam) []ToolDef
type TurnRequest ¶
type TurnRequest = apitype.TurnRequest
type UsageStats ¶
type UsageStats = apitype.UsageStats
func AggregateConsecutiveTurnUsage ¶
func AggregateConsecutiveTurnUsage(usages []UsageStats) UsageStats
func NormalizeAnthropicUsage ¶
func NormalizeAnthropicUsage(u AnthropicUsagePayload) UsageStats
func StreamText ¶
func StreamText(ctx context.Context, client openai.Client, params openai.ChatCompletionNewParams, contentOut io.Writer, opts StreamOpts) (string, UsageStats, error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.