aiconfig

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package aiconfig manages shared and user-scoped AI provider configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrInvalid

func ErrInvalid() error

ErrInvalid is the validation sentinel callers can match.

Types

type GlobalStatus

type GlobalStatus struct {
	Configured bool   `json:"configured"`
	Provider   string `json:"provider,omitempty"`
	Kind       string `json:"kind,omitempty"`
	Model      string `json:"model,omitempty"`
}

GlobalStatus is the read-only shared AI config projection.

type Input

type Input struct {
	Kind    models.AIProviderKind
	Name    string
	BaseURL string
	APIKey  string
	Models  []string
	Model   string
}

Input is a create/update request for a user provider.

type Service

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

Service is the user-provider CRUD + global-status surface.

func New

New wires the provider store, the secret vault, and the global config.

func (*Service) Create

func (s *Service) Create(ctx context.Context, ownerID string, in Input) (models.AIProviderSummary, error)

Create validates input, encrypts the key, and persists a new owned provider.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, ownerID, id string) error

Delete removes an owned provider.

func (*Service) Global

func (s *Service) Global() GlobalStatus

Global returns the read-only shared-AI status (never the key).

func (*Service) List

func (s *Service) List(ctx context.Context, ownerID string) ([]models.AIProviderSummary, error)

List returns the owner's providers as non-secret summaries.

func (*Service) Models

func (s *Service) Models(ctx context.Context, ownerID, id string) ([]string, error)

Models lists a provider's selectable models.

func (*Service) ModelsForInput

func (s *Service) ModelsForInput(ctx context.Context, in Input) ([]string, error)

ModelsForInput lists models for an unsaved provider draft.

func (*Service) ProviderModel

func (s *Service) ProviderModel(ctx context.Context, ownerID, id string) (string, error)

ProviderModel returns the configured model for an owned provider without decrypting its API key.

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, ownerID, id string) (models.AIProviderConfig, string, error)

Resolve returns an owned provider with its decrypted API key for use at chat time. The plaintext key never leaves the AI service.

func (*Service) Test

func (s *Service) Test(ctx context.Context, ownerID, id string) error

Test verifies a provider's credentials and endpoint by listing models.

func (*Service) TestInput

func (s *Service) TestInput(ctx context.Context, in Input) error

TestInput verifies an unsaved provider draft without persisting the API key.

func (*Service) Update

func (s *Service) Update(ctx context.Context, ownerID, id string, in Input) (models.AIProviderSummary, error)

Update mutates an owned provider. An empty APIKey preserves the stored key.

func (*Service) WithModels

func (s *Service) WithModels(r *modelreg.Registry) *Service

WithModels enables live model listing + provider connectivity tests.

Jump to

Keyboard shortcuts

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