Documentation
¶
Index ¶
- type AnthropicProvider
- type CopilotProvider
- func (p *CopilotProvider) HasToken() bool
- func (p *CopilotProvider) Models(ctx context.Context) ([]string, error)
- func (p *CopilotProvider) Name() string
- func (p *CopilotProvider) Stream(ctx context.Context, model string, history []Message, tools []ToolSpec) (<-chan StreamChunk, error)
- func (p *CopilotProvider) TokenEnvName() string
- type GatewayProxyProvider
- type Message
- type OllamaProvider
- type Provider
- type Registry
- type RetryTransport
- type StreamChunk
- type ToolCall
- type ToolSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnthropicProvider ¶
type AnthropicProvider struct {
// contains filtered or unexported fields
}
func NewAnthropicProvider ¶
func NewAnthropicProvider(cfg config.GatewayConfig) *AnthropicProvider
func (*AnthropicProvider) Models ¶
func (p *AnthropicProvider) Models(ctx context.Context) ([]string, error)
func (*AnthropicProvider) Name ¶
func (p *AnthropicProvider) Name() string
func (*AnthropicProvider) Stream ¶
func (p *AnthropicProvider) Stream(ctx context.Context, model string, history []Message, tools []ToolSpec) (<-chan StreamChunk, error)
type CopilotProvider ¶ added in v0.5.2
type CopilotProvider struct {
// contains filtered or unexported fields
}
CopilotProvider talks to GitHub Copilot's OpenAI-compatible endpoint.
Copilot is not a plain bearer-token API. It uses two layers: a long-lived GitHub OAuth token (ghu_...) is exchanged for a short-lived Copilot JWT, and that exchange also returns the API base URL to address. The JWT is cached until shortly before it expires.
func NewCopilotProvider ¶ added in v0.5.2
func NewCopilotProvider(cfg config.CopilotConfig) *CopilotProvider
NewCopilotProvider builds a Copilot provider from config.
func (*CopilotProvider) HasToken ¶ added in v0.6.0
func (p *CopilotProvider) HasToken() bool
HasToken reports whether a GitHub OAuth token is available from either the environment or the saved token file.
This exists so `gocode doctor` can ask the provider itself instead of reimplementing the lookup. When it checked only the environment variable, a user who had completed `gocode auth copilot` was told they had no token even though the provider could authenticate fine.
func (*CopilotProvider) Models ¶ added in v0.5.2
func (p *CopilotProvider) Models(ctx context.Context) ([]string, error)
func (*CopilotProvider) Name ¶ added in v0.5.2
func (p *CopilotProvider) Name() string
func (*CopilotProvider) Stream ¶ added in v0.5.2
func (p *CopilotProvider) Stream(ctx context.Context, model string, history []Message, tools []ToolSpec) (<-chan StreamChunk, error)
func (*CopilotProvider) TokenEnvName ¶ added in v0.6.0
func (p *CopilotProvider) TokenEnvName() string
TokenEnvName returns the environment variable this provider reads first.
type GatewayProxyProvider ¶
type GatewayProxyProvider struct {
// contains filtered or unexported fields
}
func NewGatewayProxyProvider ¶
func NewGatewayProxyProvider(name string, cfg config.GatewayConfig) *GatewayProxyProvider
func (*GatewayProxyProvider) Models ¶
func (p *GatewayProxyProvider) Models(ctx context.Context) ([]string, error)
func (*GatewayProxyProvider) Name ¶
func (p *GatewayProxyProvider) Name() string
func (*GatewayProxyProvider) Stream ¶
func (p *GatewayProxyProvider) Stream(ctx context.Context, model string, history []Message, tools []ToolSpec) (<-chan StreamChunk, error)
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
// ReasoningContent holds a prior assistant turn's thinking output.
// Providers such as MiniMax and DeepSeek document that the complete
// assistant message — including its reasoning — must be replayed into
// history to keep the reasoning chain intact across a tool-call turn, so
// this is stored and sent back rather than discarded after display.
ReasoningContent string `json:"reasoning_content,omitempty"`
}
type OllamaProvider ¶
type OllamaProvider struct {
// contains filtered or unexported fields
}
func NewOllamaProvider ¶
func NewOllamaProvider(host string) (*OllamaProvider, error)
func (*OllamaProvider) Models ¶
func (o *OllamaProvider) Models(ctx context.Context) ([]string, error)
func (*OllamaProvider) Name ¶
func (o *OllamaProvider) Name() string
func (*OllamaProvider) Stream ¶
func (o *OllamaProvider) Stream(ctx context.Context, model string, history []Message, tools []ToolSpec) (<-chan StreamChunk, error)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) ActiveName ¶
type RetryTransport ¶ added in v0.4.0
type RetryTransport struct {
Base http.RoundTripper
MaxRetries int
InitialDelay time.Duration
MaxDelay time.Duration
}
RetryTransport wraps an http.RoundTripper with retry logic for transient errors.
func NewRetryTransport ¶ added in v0.4.0
func NewRetryTransport(base http.RoundTripper) *RetryTransport
NewRetryTransport creates a new RetryTransport with sensible defaults.
type StreamChunk ¶
type StreamChunk struct {
Delta string
// Reasoning carries model thinking output, which several providers
// (MiniMax, DeepSeek) stream in a separate field from the answer. It is
// preserved and echoed back on the next turn because those providers
// require the full reasoning chain in history for multi-turn tool calls.
Reasoning string
ToolCalls []ToolCall
Done bool
Err error
}