Documentation
¶
Index ¶
- Variables
- type Anthropic
- func (p *Anthropic) AuthHeader() string
- func (p *Anthropic) BaseURL() string
- func (p *Anthropic) BridgedRoutes() []string
- func (p *Anthropic) CircuitBreakerConfig() *config.CircuitBreaker
- func (p *Anthropic) CreateInterceptor(w http.ResponseWriter, r *http.Request, tracer trace.Tracer) (_ intercept.Interceptor, outErr error)
- func (p *Anthropic) InjectAuthHeader(headers *http.Header)
- func (p *Anthropic) Name() string
- func (p *Anthropic) PassthroughRoutes() []string
- type Copilot
- func (p *Copilot) AuthHeader() string
- func (p *Copilot) BaseURL() string
- func (p *Copilot) BridgedRoutes() []string
- func (p *Copilot) CircuitBreakerConfig() *config.CircuitBreaker
- func (p *Copilot) CreateInterceptor(_ http.ResponseWriter, r *http.Request, tracer trace.Tracer) (_ intercept.Interceptor, outErr error)
- func (p *Copilot) InjectAuthHeader(_ *http.Header)
- func (p *Copilot) Name() string
- func (p *Copilot) PassthroughRoutes() []string
- type OpenAI
- func (p *OpenAI) AuthHeader() string
- func (p *OpenAI) BaseURL() string
- func (p *OpenAI) BridgedRoutes() []string
- func (p *OpenAI) CircuitBreakerConfig() *config.CircuitBreaker
- func (p *OpenAI) CreateInterceptor(w http.ResponseWriter, r *http.Request, tracer trace.Tracer) (_ intercept.Interceptor, outErr error)
- func (p *OpenAI) InjectAuthHeader(headers *http.Header)
- func (p *OpenAI) Name() string
- func (p *OpenAI) PassthroughRoutes() []string
- type Provider
Constants ¶
This section is empty.
Variables ¶
var UnknownRoute = errors.New("unknown route")
Functions ¶
This section is empty.
Types ¶
type Anthropic ¶
type Anthropic struct {
// contains filtered or unexported fields
}
Anthropic allows for interactions with the Anthropic API.
func NewAnthropic ¶
func NewAnthropic(cfg config.Anthropic, bedrockCfg *config.AWSBedrock) *Anthropic
func (*Anthropic) AuthHeader ¶
func (*Anthropic) BridgedRoutes ¶
func (*Anthropic) CircuitBreakerConfig ¶
func (p *Anthropic) CircuitBreakerConfig() *config.CircuitBreaker
func (*Anthropic) CreateInterceptor ¶
func (p *Anthropic) CreateInterceptor(w http.ResponseWriter, r *http.Request, tracer trace.Tracer) (_ intercept.Interceptor, outErr error)
func (*Anthropic) InjectAuthHeader ¶
func (*Anthropic) PassthroughRoutes ¶
type Copilot ¶
type Copilot struct {
// contains filtered or unexported fields
}
Copilot implements the Provider interface for GitHub Copilot. Unlike other providers, Copilot uses per-user API keys that are passed through the request headers rather than configured statically.
func NewCopilot ¶
func (*Copilot) AuthHeader ¶
func (*Copilot) BridgedRoutes ¶
func (*Copilot) CircuitBreakerConfig ¶
func (p *Copilot) CircuitBreakerConfig() *config.CircuitBreaker
func (*Copilot) CreateInterceptor ¶
func (p *Copilot) CreateInterceptor(_ http.ResponseWriter, r *http.Request, tracer trace.Tracer) (_ intercept.Interceptor, outErr error)
func (*Copilot) InjectAuthHeader ¶
InjectAuthHeader is a no-op for Copilot. Copilot uses per-user tokens passed in the original Authorization header, rather than a global key configured at the provider level. The original Authorization header flows through untouched from the client.
func (*Copilot) PassthroughRoutes ¶
type OpenAI ¶
type OpenAI struct {
// contains filtered or unexported fields
}
OpenAI allows for interactions with the OpenAI API.
func (*OpenAI) AuthHeader ¶
func (*OpenAI) BridgedRoutes ¶
func (*OpenAI) CircuitBreakerConfig ¶
func (p *OpenAI) CircuitBreakerConfig() *config.CircuitBreaker
func (*OpenAI) CreateInterceptor ¶
func (p *OpenAI) CreateInterceptor(w http.ResponseWriter, r *http.Request, tracer trace.Tracer) (_ intercept.Interceptor, outErr error)
func (*OpenAI) InjectAuthHeader ¶
func (*OpenAI) PassthroughRoutes ¶
PassthroughRoutes define the routes which are not currently intercepted but must be passed through to the upstream. The /v1/completions legacy API is deprecated and will not be passed through. See https://platform.openai.com/docs/api-reference/completions.
type Provider ¶
type Provider interface {
// Name returns the provider's name.
Name() string
// BaseURL defines the base URL endpoint for this provider's API.
BaseURL() string
// CreateInterceptor starts a new [Interceptor] which is responsible for intercepting requests,
// communicating with the upstream provider and formulating a response to be sent to the requesting client.
CreateInterceptor(http.ResponseWriter, *http.Request, trace.Tracer) (intercept.Interceptor, error)
// BridgedRoutes returns a slice of [http.ServeMux]-compatible routes which will have special handling.
// See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux.
BridgedRoutes() []string
// PassthroughRoutes returns a slice of whitelisted [http.ServeMux]-compatible* routes which are
// not currently intercepted and must be handled by the upstream directly.
//
// * only path routes can be specified, not ones containing HTTP methods. (i.e. GET /route).
// By default, these passthrough routes will accept any HTTP method.
PassthroughRoutes() []string
// AuthHeader returns the name of the header which the provider expects to find its authentication
// token in.
AuthHeader() string
// InjectAuthHeader allows [Provider]s to set its authentication header.
InjectAuthHeader(*http.Header)
// CircuitBreakerConfig returns the circuit breaker configuration for the provider.
CircuitBreakerConfig() *config.CircuitBreaker
}
Provider describes an AI provider client's behaviour. Provider clients are responsible for interacting with upstream AI providers.