templates

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package templates provides template loading and rendering for conversations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureTemplatesDir

func EnsureTemplatesDir() (string, error)

EnsureTemplatesDir creates the templates directory if it doesn't exist

func GetTemplatesDir

func GetTemplatesDir() (string, error)

GetTemplatesDir returns the default templates directory path

func LoadTemplates

func LoadTemplates(dir string) (map[string]*Template, error)

LoadTemplates loads all templates from a directory

Types

type Message

type Message struct {
	Role    string `yaml:"role"`    // "user", "assistant", or "system"
	Content string `yaml:"content"` // Message text
}

Message represents a template message

type Template

type Template struct {
	Name            string    `yaml:"name"`                       // Template name
	Description     string    `yaml:"description"`                // Human-readable description
	SystemPrompt    string    `yaml:"system_prompt,omitempty"`    // System prompt to use
	InitialMessages []Message `yaml:"initial_messages,omitempty"` // Pre-populated messages
	ToolsEnabled    []string  `yaml:"tools_enabled,omitempty"`    // Tools to enable (empty = all)
	Model           string    `yaml:"model,omitempty"`            // Preferred model
	MaxTokens       int       `yaml:"max_tokens,omitempty"`       // Max tokens for responses
	CreatedAt       time.Time `yaml:"-"`                          // When template was created (not in YAML)
}

Template represents a session template loaded from YAML

func LoadTemplate

func LoadTemplate(path string) (*Template, error)

LoadTemplate loads a single template from a file path

func (*Template) Validate

func (t *Template) Validate() error

Validate checks if a template is valid

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a template validation error

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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