llmprovider

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package llmprovider constructs cogito LLM transports from nib configuration.

Native adapters (anthropic, google) self-register via llmprovider/registry in their init(). This file registers the OpenAI-compatible factory and provides the top-level New / NewWithStore constructors.

Adding a new native protocol: write the adapter package, call registry.Register in init(), and blank-import it below. No changes to NewWithTemperatureAndStore are needed.

Index

Constants

View Source
const (
	ProviderOpenAI = "openai"
	ProviderCodex  = "codex"
)

Variables

View Source
var ErrNoModelList = registry.ErrNoModelList

ErrNoModelList reports a provider whose protocol has no model listing nib can query. A UI should let the user type a model name instead.

Functions

func IsCodex

func IsCodex(config types.ModelProviderConfig) bool

func ListModelChoices added in v0.9.1

func ListModelChoices(ctx context.Context, config types.ModelProviderConfig, store *auth.Store) (ids []string, partial bool, err error)

ListModelChoices is ListModels plus whether the list is partial: a suggestion (see registry.PartialModelList) that a name outside it may still be valid for, so a UI should accept typed names instead of refusing them.

func ListModels added in v0.9.1

func ListModels(ctx context.Context, config types.ModelProviderConfig, store *auth.Store) ([]string, error)

ListModels returns the model IDs config's provider serves. OpenAI-compatible endpoints (and Ollama's /v1) are queried at /models; native protocols are asked through their adapter, with its own auth. Anything else returns ErrNoModelList.

func ModelsEndpoint added in v0.9.1

func ModelsEndpoint(config types.ModelProviderConfig, store *auth.Store) (baseURL, apiKey string, err error)

ModelsEndpoint returns the OpenAI-compatible base URL (the one /models hangs off) and key for config, resolving credentials the same way the LLM client does. Protocols without such an endpoint return ErrNoModelList.

func New

func New(config types.ModelProviderConfig) (cogito.LLM, error)

New returns an independent LLM transport. OpenAI means any OpenAI-compatible HTTP endpoint, including a local LocalAI server.

func NewWithStore added in v0.9.0

func NewWithStore(config types.ModelProviderConfig, store *auth.Store) (cogito.LLM, error)

NewWithStore is like New but resolves credentials from store for providers that support /login (anthropic, google, openai-direct).

func NewWithTemperature

func NewWithTemperature(config types.ModelProviderConfig, temperature float32) (cogito.LLM, error)

NewWithTemperature applies agent-specific sampling to OpenAI-compatible providers. Codex app-server owns its reasoning configuration and ignores the compatibility hint.

func NewWithTemperatureAndStore added in v0.9.0

func NewWithTemperatureAndStore(config types.ModelProviderConfig, temperature float32, store *auth.Store) (cogito.LLM, error)

NewWithTemperatureAndStore is the full constructor: temperature for OpenAI-compatible providers, credential store for providers with /login. A nil store is valid — the resolver falls through to config/env.

Codex is the only special case (it uses a subprocess, not HTTP). Every other provider goes through the registry: the provider Definition is looked up, and the registered adapter Factory for its Protocol is called.

Types

type ModelLister added in v0.9.1

type ModelLister interface {
	ListModels(ctx context.Context) ([]string, error)
}

ModelLister is implemented by native adapters that can say which models they serve, by asking their API or from a built-in list (see registry.PartialModelList).

Directories

Path Synopsis
Package anthropic adapts the Anthropic Messages API to cogito.LLM.
Package anthropic adapts the Anthropic Messages API to cogito.LLM.
Package azureresponses adapts the Azure OpenAI Responses API to cogito.LLM.
Package azureresponses adapts the Azure OpenAI Responses API to cogito.LLM.
Package bedrock adapts the Amazon Bedrock Converse Stream API to cogito.LLM.
Package bedrock adapts the Amazon Bedrock Converse Stream API to cogito.LLM.
Package catalog queries OpenAI-compatible API endpoints to discover per-model output token limits at runtime.
Package catalog queries OpenAI-compatible API endpoints to discover per-model output token limits at runtime.
Package codex adapts the OpenAI Codex Responses API (ChatGPT backend) to cogito.LLM.
Package codex adapts the OpenAI Codex Responses API (ChatGPT backend) to cogito.LLM.
Package copilot implements the GitHub Copilot multi-protocol adapter.
Package copilot implements the GitHub Copilot multi-protocol adapter.
Package geminicli adapts the Google Cloud Code Assist API (used by Gemini CLI) to cogito.LLM.
Package geminicli adapts the Google Cloud Code Assist API (used by Gemini CLI) to cogito.LLM.
Package google adapts the Google Generative AI API to cogito.LLM.
Package google adapts the Google Generative AI API to cogito.LLM.
Package googlevertex adapts the Google Vertex AI API to cogito.LLM.
Package googlevertex adapts the Google Vertex AI API to cogito.LLM.
Package ollama adapts the Ollama native chat API (/api/chat) to cogito.LLM.
Package ollama adapts the Ollama native chat API (/api/chat) to cogito.LLM.
Package openairesponses adapts the OpenAI Responses API to cogito.LLM.
Package openairesponses adapts the OpenAI Responses API to cogito.LLM.
Package registry maps wire protocols to adapter factories.
Package registry maps wire protocols to adapter factories.

Jump to

Keyboard shortcuts

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