brain

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(logger *slog.Logger) error

Init initializes the global Brain from environmental variables. It detects the provider and sets the Global Brain instance.

func SetGlobal

func SetGlobal(b Brain)

SetGlobal sets the global Brain instance.

Types

type Brain

type Brain interface {
	// Chat generates a plain text response for a given prompt.
	// Best used for simple questions, greetings, or summarization.
	Chat(ctx context.Context, prompt string) (string, error)

	// Analyze performs structured analysis and returns the result in the target struct.
	// The target must be a pointer to a struct that can be unmarshaled from JSON.
	// Useful for intent routing, safety checks, and complex data extraction.
	Analyze(ctx context.Context, prompt string, target any) error
}

Brain represents the core "System 1" intelligence for HotPlex. It provides fast, structured, and low-cost reasoning capabilities.

func Global

func Global() Brain

Global returns the globally configured Brain instance. If no brain is configured, it returns nil.

type Config

type Config struct {
	// Enabled is automatically determined based on APIKey presence.
	Enabled bool
	// Provider supports "openai" (default), "anthropic", "gemini".
	Provider string
	// APIKey is the secret for accessing the provider API.
	APIKey string
	// Endpoint is the optional base URL for the API (e.g. for DeepSeek/Groq).
	Endpoint string
	// Model is the specific model to use (default: gpt-4o-mini).
	Model string
	// Timeout is the maximum duration for a brain request.
	// Defaults to 10 seconds for standard requests.
	TimeoutS int
}

Config holds the configuration for the Global Brain.

func LoadConfigFromEnv

func LoadConfigFromEnv() Config

LoadConfigFromEnv loads the brain configuration from environment variables.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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