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
- func Info() api.KindInfo
- type Adapter
- func (a *Adapter) AnswerQuestions(ctx context.Context, req api.ScreenRequest) (api.ScreenResult, error)
- func (a *Adapter) AnswerReference(ctx context.Context, req api.ReferenceRequest) (api.ReferenceAnswer, error)
- func (a *Adapter) Capabilities(_ context.Context) (api.AICapabilities, error)
- func (a *Adapter) Category() api.Category
- func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error
- func (a *Adapter) DraftAccess(ctx context.Context, req api.AccessRequest) (api.AccessDraft, error)
- func (a *Adapter) DraftPolicy(ctx context.Context, req api.PolicyRequest) (api.PolicyDraft, error)
- func (a *Adapter) HealthCheck(ctx context.Context) error
- func (a *Adapter) Kind() string
- func (a *Adapter) RepairPlan(ctx context.Context, req api.ScreenRequest) (api.ScreenResult, error)
- func (a *Adapter) RevisePlan(ctx context.Context, req api.ScreenRequest) (api.ScreenResult, error)
- func (a *Adapter) SearchAudit(ctx context.Context, req api.AuditSearchRequest) (api.AuditSearch, error)
- func (a *Adapter) SummarizeAudit(ctx context.Context, req api.AuditSummaryRequest) (api.AuditSummary, error)
- type Config
- type Credentials
Constants ¶
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.
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).
const Kind = "openai"
Kind is what adapter_configs stores.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is the OpenAI 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 ¶
Capabilities reports what this adapter does, as data (R-254, R-259).
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 ¶
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) 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 ¶
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).