providers

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package providers owns provider metadata and explicitly requested HTTP work.

Index

Constants

View Source
const (
	DefaultCopilotAgent        = "GitHubCopilotChat/0.68.0"
	DefaultCopilotEditor       = "vscode/1.140.0"
	DefaultCopilotEditorPlugin = "copilot-chat/0.68.0"
)

Copilot's service identifies its editor client by these values.

View Source
const CatalogURL = "https://models.dev/api.json"
View Source
const DefaultCatalogVersion = "0.170.0"

DefaultCatalogVersion tracks the reviewed stable Codex release used to query the ChatGPT account's model catalog.

View Source
const DefaultClaudeAgent = "claude-cli/2.1.280 (external, cli)"
View Source
const LegacyCatalogVersion = "0.160.1"

Variables

This section is empty.

Functions

func APIKeyHeaderDefaults

func APIKeyHeaderDefaults(api protocol.ConversationModelApi) map[string]string

APIKeyHeaderDefaults keeps native model discovery and conversation requests on the same client and protocol defaults before applying provider overrides.

func AccountResourceEndpoint

func AccountResourceEndpoint(authentication protocol.Authentication, value string) bool

func AnthropicBaseURL

func AnthropicBaseURL(endpoint url.URL) url.URL

AnthropicBaseURL returns the mount before the versioned Messages and Models routes.

func BundledCatalogProvider

func BundledCatalogProvider(endpoint string) (string, error)

BundledCatalogProvider resolves an unambiguous catalog endpoint from the pinned snapshot independently of which model metadata snapshot is active.

func CatalogOutputs added in v0.2.4

func CatalogOutputs(outputs []string) (known []string)

CatalogOutputs keeps known native modalities without giving them a media route.

func ChannelCatalogNamespace added in v0.2.4

func ChannelCatalogNamespace(endpoint string, authentication protocol.Authentication) (string, error)

ChannelCatalogNamespace identifies a known offering namespace for a channel.

func CompleteChannelModel

CompleteChannelModel enriches a model with a reference from its channel lookup.

func CompleteModel

CompleteModel resolves metadata from a matched offering without replacing configured limits, explicit effort choices, user-chosen tags or compaction.

func CompleteModelInputs added in v0.2.4

func CompleteModelInputs(model protocol.ConversationModel, catalogInputs []string) protocol.ConversationModel

CompleteModelInputs updates just the input tags. Native vision overrides the catalog's image entry, but says nothing about the other modalities.

func Endpoint

func Endpoint(value string) (*url.URL, error)

func NormalizeScoreName

func NormalizeScoreName(name string) string

func OAuthFields

func OAuthFields(provider protocol.ConversationProvider) (map[string]string, error)

func OpenAIBaseURL

func OpenAIBaseURL(endpoint url.URL) url.URL

OpenAIBaseURL resolves the shared base for API-key inference and discovery. A bare origin uses /v1. A full operation URL can explicitly select another mount, including an API served at the root.

func ParsePresets

func ParsePresets(raw []byte) (protocol.ConversationPresetsCatalog, error)

func PathSegment

func PathSegment(value string) bool

PathSegment reports a value safe to place as one URL path segment, such as an Azure API version, deployment or a provider's job ID.

func RecoveryAccountIdentity

func RecoveryAccountIdentity(grant AccountGrant) string

RecoveryAccountIdentity names only service-issued principal and workspace identifiers. Missing identifiers cannot be replaced by an email, a label or a token: those do not prove that a fresh login owns the original task.

func RecoveryAuthenticationTarget

func RecoveryAuthenticationTarget(provider protocol.ConversationProvider, target *AccountTarget, grant AccountGrant) string

RecoveryAuthenticationTarget excludes installation-specific package digests while retaining the auth origin, flow and service/client target. The digest is an identity comparison, never an authorization or renewal credential.

func RefreshDiscoveredCapabilities

RefreshDiscoveredCapabilities updates the native request capabilities of a saved model while preserving its configuration.

func ReservedHeader

func ReservedHeader(name string) bool

ReservedHeader reports whether name is set only by the transport.

func ResolveScore

func ResolveScore(candidates []string, models []string, aliases map[string]string) *string

func RuntimeAccount

func RuntimeAccount(provider protocol.ConversationProvider, grant AccountGrant) (protocol.RuntimeCredential, error)

RuntimeAccount exports only fields used to execute an already selected model. Plugin extras enter the projection only through declared header injections.

func RuntimeAccountSecret

func RuntimeAccountSecret(value protocol.RuntimeCredential) (*protocol.Secret, error)

func RuntimeField

func RuntimeField(name string) bool

func ScoreEffortHint

func ScoreEffortHint(name string) string

ScoreEffortHint returns the reasoning effort encoded as a trailing suffix on a model identifier (for example "-high"), or "" when none is present.

func ValidateBinding

func ValidateBinding(provider protocol.ConversationProvider) error

func ValidateCloud

func ValidateCloud(provider protocol.ConversationProvider) error

ValidateCloud checks an Amazon Bedrock or Vertex AI provider: API-key authentication (the Bedrock API key or the service-account JSON), the region, or the project and location, its options name, and an endpoint that is a service host without a path.

func ValidateConfiguration

func ValidateConfiguration(provider protocol.ConversationProvider) error

func ValidateFeatures

func ValidateFeatures(api protocol.ConversationModelApi, model protocol.ConversationModel, selected map[string]string) error

func ValidateHeaders

func ValidateHeaders(provider protocol.ConversationProvider) error

ValidateHeaders checks the custom request headers before saving or discovery.

func ValidatePreset

func ValidatePreset(preset protocol.ConversationPresetsPreset, builtin bool) error

func ValidateSelection

func ValidateSelection(provider protocol.ConversationProvider, config protocol.SessionConfig) error

Types

type AccountGrant

type AccountGrant struct {
	Kind              protocol.Authentication     `json:"kind"`
	Access            string                      `json:"access,omitempty"`
	IssuedAtMs        *uint64                     `json:"issued_at_ms,omitempty"`
	Refresh           string                      `json:"refresh,omitempty"`
	ExpiresAtMs       uint64                      `json:"expires_at_ms,omitempty"`
	EarliestRefreshAt *uint64                     `json:"earliest_refresh_at,omitempty"`
	AccountID         *string                     `json:"account_id,omitempty"`
	ClientID          string                      `json:"client_id,omitempty"`
	Subject           string                      `json:"subject,omitempty"`
	Email             *string                     `json:"email,omitempty"`
	IDToken           string                      `json:"id_token,omitempty"`
	Scopes            []string                    `json:"scopes,omitempty"`
	OrgID             *string                     `json:"org_id,omitempty"`
	OrgName           *string                     `json:"org_name,omitempty"`
	InstallationID    *string                     `json:"installation_id,omitempty"`
	Github            string                      `json:"github,omitempty"`
	Endpoint          string                      `json:"endpoint,omitempty"`
	Record            *AccountRecord              `json:"record,omitempty"`
	RenewalPending    bool                        `json:"renewal_pending"`
	RenewalUncertain  bool                        `json:"renewal_uncertain,omitempty"`
	RenewalRejected   bool                        `json:"renewal_rejected,omitempty"`
	Runtime           *protocol.RuntimeCredential `json:"runtime,omitempty"`
}

func AccountHeaders

func AccountHeaders(provider protocol.ConversationProvider, secret *protocol.Secret) (AccountGrant, http.Header, error)

func AccountResourceHeaders

func AccountResourceHeaders(provider protocol.ConversationProvider, secret *protocol.Secret, target string) (AccountGrant, http.Header, error)

func DecodeAccount

func DecodeAccount(secret *protocol.Secret, authentication protocol.Authentication) (AccountGrant, error)

func (AccountGrant) Expiry

func (grant AccountGrant) Expiry() *uint64

func (AccountGrant) Label

func (grant AccountGrant) Label() *string

func (AccountGrant) RenewalAt

func (grant AccountGrant) RenewalAt() *uint64

RenewalAt returns the next refresh time without inventing an unknown TTL. Legacy grants retain their former one-minute-before-expiry behavior.

func (AccountGrant) SameAccount

func (grant AccountGrant) SameAccount(other AccountGrant) bool

func (AccountGrant) Secrets

func (grant AccountGrant) Secrets() []protocol.Secret

type AccountRecord

type AccountRecord struct {
	Target AccountTarget        `json:"target"`
	Issued authorization.Issued `json:"issued"`
}

type AccountTarget

type AccountTarget struct {
	Provider    protocol.ProviderID                 `json:"provider"`
	Package     protocol.PluginReference            `json:"package"`
	Origin      protocol.ConversationConsentOrigin  `json:"origin"`
	Flow        string                              `json:"flow"`
	Endpoint    string                              `json:"endpoint"`
	Declaration protocol.PluginModelAuthDeclaration `json:"declaration"`
	Fields      map[string]string                   `json:"fields"`
}

func (AccountTarget) Matches

func (target AccountTarget) Matches(current AccountTarget) bool

type CatalogDownload

type CatalogDownload struct {
	Entries   []CatalogEntry
	Bytes     uint64
	Providers uint32
	Fault     *protocol.Fault
	// contains filtered or unexported fields
}

func BundledCatalog

func BundledCatalog() (*CatalogDownload, error)

BundledCatalog provides the build's validated offline metadata snapshot. Its returned entries and bodies are shared and must not be modified.

func ParseCatalog

func ParseCatalog(raw []byte) (*CatalogDownload, error)

type CatalogEntry

type CatalogEntry struct {
	Provider string
	ID       string
	Body     json.RawMessage
}

type Directory

type Directory struct {
	// contains filtered or unexported fields
}

func (*Directory) Read

type Prepared

type Prepared struct {
	Provider      *protocol.ConversationProvider
	Output        *protocol.Output
	Catalog       *CatalogDownload
	Scores        *ScoresDownload
	ScoreRevision uint64
}

func Run

func Run(ctx context.Context, work Work) (*Prepared, error)

type ScoreEntry

type ScoreEntry struct {
	Model  string
	Effort string
	Score  protocol.ConversationCatalogScoresEffortScore
}

type ScoresDataset

type ScoresDataset struct {
	Batch       string
	PublishedAt string
	Entries     []ScoreEntry
	Aliases     map[string]string
}

func ParseScores

func ParseScores(raw []byte) (*ScoresDataset, error)

type ScoresDownload

type ScoresDownload struct {
	Unchanged bool
	Dataset   *ScoresDataset
	ETag      *string
	Fault     *protocol.Fault
}

type Work

type Work struct {
	Command       protocol.Command
	Provider      *protocol.ConversationProvider
	Secret        *protocol.Secret
	ETag          *string
	Directory     *Directory
	Client        *http.Client
	ScoreRevision uint64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL