Documentation
¶
Index ¶
- Constants
- Variables
- func FetchModels(ctx context.Context, client *http.Client, base, token string) (json.RawMessage, error)
- func PollDeviceFlow(ctx context.Context, client *http.Client, code DeviceCode) (string, error)
- func RequestJSON(ctx context.Context, client *http.Client, endpoint, bearer string, ...) error
- func TrustedAPI(raw string) bool
- type Account
- type Catalog
- type Compatibility
- type DeviceCode
- type HTTPError
- type Model
- type Route
- type Token
Constants ¶
const ( ModelPrefix = Provider + "/" Chat = "/chat/completions" Messages = "/v1/messages" Responses = "/responses" CatalogMaxAge = 2 * time.Hour )
const CLIEditor = "copilot/1.0.114"
const Provider = "copilot"
Variables ¶
var CLIUserAgent = func() string { platform := runtime.GOOS if platform == "windows" { platform = "win32" } return CLIEditor + " (" + platform + " v24.22.1) term/unknown" }()
var PresetCatalog = &Catalog{}
PresetCatalog is used only while a usable credential awaits its first discovery.
UnavailableCatalog records a revoked account until discovery succeeds again.
Functions ¶
func FetchModels ¶
func FetchModels(ctx context.Context, client *http.Client, base, token string) (json.RawMessage, error)
FetchModels returns the complete upstream response, including unknown fields.
func PollDeviceFlow ¶
func RequestJSON ¶
func TrustedAPI ¶
TrustedAPI restricts where inference credentials can be sent.
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is an immutable account snapshot shared by runtime auth clones.
func FetchCatalog ¶
func NewCatalog ¶
NewCatalog takes ownership of the nested model fields. The first entry for an ID wins.
func (*Catalog) SameModels ¶
type Compatibility ¶
type Compatibility struct {
SystemPrompt string `json:"system_prompt"`
Endpoint string `json:"endpoint"`
AdaptiveMode string `json:"adaptive_mode"`
NonStreamingOutput int `json:"max_non_streaming_output_tokens"`
LimitEfforts bool `json:"limit_efforts"`
DefaultVerbosity string `json:"default_verbosity"`
DefaultToolChoice string `json:"default_tool_choice"`
DisableSnippy bool `json:"disable_snippy"`
DefaultEffort string `json:"default_effort"`
DefaultBudget int `json:"default_budget"`
DefaultMaxTokens int `json:"default_max_tokens"`
AnthropicBetas []string `json:"anthropic_betas"`
}
type DeviceCode ¶
type DeviceCode struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
func StartDeviceFlow ¶
type Model ¶
type Model struct {
ID string `json:"id"`
DefaultEffort string `json:"default_reasoning_effort,omitempty"`
Name string `json:"name"`
Endpoints []string `json:"supported_endpoints"`
Picker *bool `json:"model_picker_enabled,omitempty"`
Policy struct {
State string `json:"state,omitempty"`
} `json:"policy"`
Capabilities struct {
Type string `json:"type,omitempty"`
Supports struct {
Tools *bool `json:"tool_calls,omitempty"`
Vision *bool `json:"vision,omitempty"`
Thinking *bool `json:"thinking,omitempty"`
Adaptive json.RawMessage `json:"adaptive_thinking,omitempty"`
Reasoning json.RawMessage `json:"reasoning_effort,omitempty"`
MinBudget int `json:"min_thinking_budget,omitempty"`
MaxBudget int `json:"max_thinking_budget,omitempty"`
} `json:"supports"`
Limits struct {
Context int `json:"max_context_window_tokens,omitempty"`
Input int `json:"max_prompt_tokens,omitempty"`
Output int `json:"max_output_tokens,omitempty"`
NonStreamingOutput int `json:"max_non_streaming_output_tokens,omitempty"`
} `json:"limits"`
} `json:"capabilities"`
}