ai

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package ai manages AI prompts and integrates with LLM providers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAPIKey = errors.New("invalid API Key")
	ErrApiKeyNotSet  = errors.New("api Key not set")
)

Functions

This section is empty.

Types

type Manager

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

func New

func New(opts Opts) (*Manager, error)

New creates and returns a new instance of the Manager.

func (*Manager) Completion

func (m *Manager) Completion(k string, prompt string) (string, error)

Completion sends a prompt to the default provider and returns the response.

func (*Manager) GetPrompts

func (m *Manager) GetPrompts() ([]models.Prompt, error)

GetPrompts returns a list of prompts from the database.

func (*Manager) UpdateProvider

func (m *Manager) UpdateProvider(provider, apiKey string) error

UpdateProvider updates a provider.

type OpenAIClient

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

func NewOpenAIClient

func NewOpenAIClient(apiKey string, lo *logf.Logger) *OpenAIClient

func (*OpenAIClient) SendPrompt

func (o *OpenAIClient) SendPrompt(payload PromptPayload) (string, error)

SendPrompt sends a prompt to the OpenAI API and returns the response text.

type Opts

type Opts struct {
	DB            *sqlx.DB
	I18n          *i18n.I18n
	Lo            *logf.Logger
	EncryptionKey string
}

Opts contains options for initializing the Manager.

type PromptPayload

type PromptPayload struct {
	SystemPrompt string `json:"system_prompt"`
	UserPrompt   string `json:"user_prompt"`
}

PromptPayload represents the structured input for an LLM provider.

type ProviderClient

type ProviderClient interface {
	SendPrompt(payload PromptPayload) (string, error)
}

ProviderClient is the interface all providers should implement.

type ProviderType

type ProviderType string

ProviderType is an enum-like type for different providers.

const (
	ProviderOpenAI ProviderType = "openai"
	ProviderClaude ProviderType = "claude"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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