proxyapp

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 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 proxyapp re-exports the handful of internal symbols a host needs to build its own context-guru proxy binary.

WHY THIS EXISTS. cmd/context-guru-proxy is this module's own composition root, and it imports three internal/ packages: buildinfo, logging and modelinfo. (cheapmodel used to be a fourth — see below.) Go forbids importing an internal/ package from another module, so a deployment that needs the standard proxy PLUS its own routes — an enterprise build with SSO, a bespoke activation surface, a private landing page — cannot reuse that root. It has to copy it, and then it owns a 1300-line fork of somebody else's file for ever.

That is what this package removes. It is a FACADE, deliberately: aliases and thin wrappers over the existing internal packages, adding no behaviour and moving no code. Nothing internal is relocated, so all ~70 files that import those packages today are untouched.

ONE EXCEPTION, from the same dispatch.Dispatcher split noted below: AnthropicCheapModel and OpenAICheapModel lost their BaseURL/APIKey/AuthScheme/Client fields in favor of a dispatch.Dispatcher + dispatch.Ref, and proxy.Options.CheapModel changed type from components.Model to *proxy.CheapModelConfig. A host built on this facade that constructed either cheap-model type directly, or passed one to Options.CheapModel, stops compiling. There is no way to re-export the OLD shape here without also re-exporting the credential-holding code this project is removing from the core, so this one break is accepted rather than papered over.

WHY A FACADE RATHER THAN PROMOTING THE PACKAGES. Moving internal/modelinfo (38 importers) out of internal/ would churn ~70 files across the tree and publish its entire surface as API this project then has to keep stable. The composition root uses THIRTEEN of its symbols. Exporting those thirteen is a promise worth making; exporting the whole package by accident is not.

cheapmodel IS promoted, by exception: the dispatch.Dispatcher split (see dispatch/dispatch.go) requires it. Every host now builds its own cheapmodel.Anthropic/OpenAI directly over its own Dispatcher, and a host outside this module (Cortex, say) cannot do that with an internal/ package. Its surface is small and host-agnostic on purpose — wire format only, no transport, no credential — so promoting it is a promise this project can keep.

WHAT THIS IS NOT. It is not a plugin system and it does not run the proxy for you. A host still writes its own main(), and proxy.Options remains the contract. This only unblocks the parts a root cannot reach today.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Commit

func Commit() string

Commit is the revision this module was built from.

func ExactWindow

func ExactWindow(r Resolver, ctx context.Context, model string) (tokens int, exact, ok bool)

ExactWindow reports a model's window and whether the answer is exact rather than inferred. The distinction matters: a fraction-of-window trigger computed from a guessed window is a guess.

func SetupLogging

func SetupLogging() string

SetupLogging configures the process logger from the environment (CG_LOG_LEVEL, CG_LOG_FILE) and returns a one-line description of what it did, for the startup log.

It never fails the process: a log file that cannot be opened degrades to stderr with a warning, because refusing to boot over an observability sink would make logging less safe than not having it.

func Version

func Version() string

Build identity, as set by the Makefile's -ldflags. A host that wants its own stamp sets its own variables and ignores these; these are what this module's own build records.

Read as functions rather than re-exported as variables, because a var alias would let a host overwrite the value another part of the process already reported.

Types

type AnthropicCheapModel

type AnthropicCheapModel = cheapmodel.Anthropic

AnthropicCheapModel calls an Anthropic-dialect endpoint.

type Chain

type Chain = modelinfo.Chain

Chain tries several Resolvers in order, first answer wins.

type LiteLLM

type LiteLLM = litellm.LiteLLM

LiteLLM resolves against the LiteLLM community price/window map (internal/modelinfo/litellm: the one network call in this family, kept out of modelinfo itself so that package stays I/O-free).

func NewLiteLLM

func NewLiteLLM(url string, client *http.Client, ttl time.Duration) *LiteLLM

NewLiteLLM resolves model windows against a LiteLLM gateway, cached for ttl.

type OpenAICheapModel

type OpenAICheapModel = cheapmodel.OpenAI

OpenAICheapModel calls an OpenAI-dialect endpoint.

type Price

type Price = modelinfo.Price

Price is one model's token prices.

type Pricer

type Pricer = modelinfo.Pricer

Pricer answers what a model's tokens cost.

type Resolver

type Resolver = modelinfo.Resolver

Resolver resolves a model id to its context window.

type Static

type Static = modelinfo.Static

Static is the compiled-in table of known models.

func DefaultStatic

func DefaultStatic() Static

DefaultStatic is the compiled-in model table.

type Table

type Table = modelinfo.Table

Table is a table loaded from a file.

func LoadTable

func LoadTable(path string) (*Table, error)

LoadTable reads a model table from a file, so an operator can correct or extend the compiled-in one without a rebuild.

Jump to

Keyboard shortcuts

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