Documentation
¶
Index ¶
- Constants
- Variables
- func CleanCopilotResponse(response string) string
- func GetTimeout(flagTimeout time.Duration) time.Duration
- func IsCopilotAvailable() bool
- type APIError
- type AnthropicMessage
- type AnthropicRequest
- type AnthropicResponse
- type AuthType
- type ChatRequest
- type ChatResponse
- type Message
- type Provider
- type ProviderInfo
Constants ¶
const DefaultTimeout = 30 * time.Second
DefaultTimeout is the default timeout for API requests.
const TimeoutEnvVar = "HOWTO_TIMEOUT"
TimeoutEnvVar is the environment variable to override the default timeout.
Variables ¶
var ( OpenAI = &Provider{ Name: "OpenAI", Endpoint: "https://api.openai.com/v1/chat/completions", DefaultModel: "gpt-4o", EnvVar: "OPENAI_API_KEY", AuthType: AuthBearer, } Anthropic = &Provider{ Name: "Anthropic", Endpoint: "https://api.anthropic.com/v1/messages", DefaultModel: "claude-sonnet-4-20250514", EnvVar: "ANTHROPIC_API_KEY", AuthType: AuthAPIKey, } Gemini = &Provider{ Name: "Gemini", Endpoint: "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions", DefaultModel: "gemini-2.0-flash", EnvVar: "GEMINI_API_KEY", AuthType: AuthBearer, } DeepSeek = &Provider{ Name: "DeepSeek", Endpoint: "https://api.deepseek.com/chat/completions", DefaultModel: "deepseek-chat", EnvVar: "DEEPSEEK_API_KEY", AuthType: AuthBearer, } GitHubCopilot = &Provider{ Name: "GitHub Copilot", Endpoint: "", DefaultModel: "gpt-4", EnvVar: "", AuthType: AuthCLI, } )
Providers configuration.
Functions ¶
func CleanCopilotResponse ¶
CleanCopilotResponse removes markdown formatting from Copilot's response.
func GetTimeout ¶
GetTimeout returns the configured timeout duration. It checks the HOWTO_TIMEOUT environment variable first, then falls back to the provided default or DefaultTimeout.
func IsCopilotAvailable ¶
func IsCopilotAvailable() bool
IsCopilotAvailable checks if GitHub Copilot CLI is available.
Types ¶
type APIError ¶
type APIError struct {
Message string `json:"message"`
}
APIError represents an API error response.
type AnthropicMessage ¶
AnthropicMessage represents a message in Anthropic format.
type AnthropicRequest ¶
type AnthropicRequest struct {
Model string `json:"model"`
MaxTokens int `json:"maxTokens"`
Messages []AnthropicMessage `json:"messages"`
}
AnthropicRequest represents an Anthropic API request.
type AnthropicResponse ¶
type AnthropicResponse struct {
Content []struct {
Type string `json:"type"`
Text string `json:"text"`
} `json:"content"`
Error *struct {
Type string `json:"type"`
Message string `json:"message"`
} `json:"error,omitempty"`
}
AnthropicResponse represents an Anthropic API response.
type ChatRequest ¶
type ChatRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"maxTokens"`
}
ChatRequest represents a chat completion request.
type ChatResponse ¶
type ChatResponse struct {
Choices []struct {
Message Message `json:"message"`
} `json:"choices"`
Error *APIError `json:"error,omitempty"`
}
ChatResponse represents a chat completion response.
type Provider ¶
type Provider struct {
Name string
Endpoint string
DefaultModel string
EnvVar string
AuthType AuthType
Configured bool
}
Provider represents an AI provider configuration.
type ProviderInfo ¶
ProviderInfo contains provider information for display.