Help us shape the future of Go! Take the 2026 Go Developer Survey

openai

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package openai performs Pando's AI functions with OpenAI's models, through the Responses API.

The second AI adapter. The prompts, tools, budgeted reader and answer shapes are aikit's, shared with every AI adapter; what is here is how a conversation is held with OpenAI. It returns amendments and drafts core validates again, because an adapter proposes and core decides (R-027).

Nothing here writes. The repository is read through a SourceView, which has no write method, and the tools a model is given are a listing and a read.

Index

Constants

View Source
const (
	DefaultMaxFiles = 40
	DefaultMaxBytes = 256 << 10
)

Budget ceilings this adapter will not exceed regardless of what it is asked for. Core lowers them further; neither side raises the other's.

View Source
const DefaultModel = "gpt-5.5"

DefaultModel is what an install gets without choosing. [P] OpenAI's newest general model when this was written; an install sets its own, and each function may run on another (R-259).

View Source
const Kind = "openai"

Kind is what adapter_configs stores.

Variables

This section is empty.

Functions

func Info

func Info() api.KindInfo

Info describes this kind of adapter for the forms that configure one (api.KindInfo, R-261).

Types

type Adapter

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

Adapter is the OpenAI adapter.

func New

func New() *Adapter

New returns an unconfigured adapter.

func (*Adapter) AnswerQuestions

func (a *Adapter) AnswerQuestions(ctx context.Context, req api.ScreenRequest) (api.ScreenResult, error)

AnswerQuestions answers detection's outstanding questions (R-338).

func (*Adapter) AnswerReference

func (a *Adapter) AnswerReference(ctx context.Context, req api.ReferenceRequest) (api.ReferenceAnswer, error)

AnswerReference answers from the generated reference (R-346).

func (*Adapter) Capabilities

func (a *Adapter) Capabilities(_ context.Context) (api.AICapabilities, error)

Capabilities reports what this adapter does, as data (R-254, R-259).

func (*Adapter) Category

func (a *Adapter) Category() api.Category

func (*Adapter) Configure

func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error

Configure reads the adapter's configuration.

func (*Adapter) DraftAccess

func (a *Adapter) DraftAccess(ctx context.Context, req api.AccessRequest) (api.AccessDraft, error)

DraftAccess drafts a role and, optionally, a group (R-343).

func (*Adapter) DraftPolicy

func (a *Adapter) DraftPolicy(ctx context.Context, req api.PolicyRequest) (api.PolicyDraft, error)

DraftPolicy proposes changes to host policy (R-344).

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(ctx context.Context) error

HealthCheck asks the API whether the configured model exists: a key that does not work and a model nobody serves both answer here as they would to a real call, and the lookup costs nothing.

func (*Adapter) Kind

func (a *Adapter) Kind() string

func (*Adapter) RepairPlan

func (a *Adapter) RepairPlan(ctx context.Context, req api.ScreenRequest) (api.ScreenResult, error)

RepairPlan reads a failed proposal and proposes amendments (R-106, R-336).

func (*Adapter) RevisePlan

func (a *Adapter) RevisePlan(ctx context.Context, req api.ScreenRequest) (api.ScreenResult, error)

RevisePlan acts on what a person reviewing the plan asked for (R-336).

func (*Adapter) SearchAudit

func (a *Adapter) SearchAudit(ctx context.Context, req api.AuditSearchRequest) (api.AuditSearch, error)

SearchAudit turns a question into one audit filter (R-345).

func (*Adapter) SummarizeAudit

func (a *Adapter) SummarizeAudit(ctx context.Context, req api.AuditSummaryRequest) (api.AuditSummary, error)

SummarizeAudit summarizes the records core found (R-345).

type Config

type Config struct {
	// Credentials are supplied by core, decrypted from adapter_credentials at
	// startup (O-20). Never part of the stored configuration: the database
	// refuses a `credentials` key in adapter_configs.config.
	Credentials Credentials `json:"credentials,omitzero"`

	// APIKeyEnv names an environment variable holding the key. When neither
	// this nor a stored credential is set, OPENAI_API_KEY is read — the SDK's
	// own convention.
	APIKeyEnv string `json:"api_key_env,omitempty"`

	Model string `json:"model,omitempty"`

	// BaseURL points at a gateway or a proxy. Empty is the OpenAI API.
	BaseURL string `json:"base_url,omitempty"`

	// ScreenPlans defaults to true (R-336). False turns off repairing plans,
	// answering questions and revising plans, for an install that wants the
	// adapter for the administrative functions only.
	ScreenPlans *bool `json:"screen_plans,omitempty"`

	MaxFiles int   `json:"max_files,omitempty"`
	MaxBytes int64 `json:"max_bytes,omitempty"`

	TimeoutSeconds int `json:"timeout_seconds,omitempty"`
}

Config is the adapter's own configuration.

type Credentials

type Credentials struct {
	APIKey secret.Value `json:"api_key,omitzero"`
}

Credentials is what this adapter needs kept secret. A secret.Value, so it renders [redacted] in every marshaler and cannot reach a log line (R-194).

Jump to

Keyboard shortcuts

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