prompts

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStore

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

FileStore implements TemplateStore using the local file system

func NewFileStore

func NewFileStore(basePath string) (*FileStore, error)

NewFileStore creates a new file store

func (*FileStore) Delete

func (s *FileStore) Delete(ctx context.Context, id string, version string) error

Delete removes a template

func (*FileStore) Get

func (s *FileStore) Get(ctx context.Context, id string, version string) (*Template, error)

Get retrieves a template by ID and version

func (*FileStore) List

func (s *FileStore) List(ctx context.Context, filter map[string]interface{}) ([]*Template, error)

List returns all templates matching the given filter

func (*FileStore) Save

func (s *FileStore) Save(ctx context.Context, tmpl *Template) error

Save stores a template

type Manager

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

Manager manages prompt templates

func NewManager

func NewManager(store TemplateStore) *Manager

NewManager creates a new template manager

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, id string, version string) error

Delete removes a template

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, id string, version string) (*Template, error)

Get retrieves a template by ID and version

func (*Manager) GetLatest

func (m *Manager) GetLatest(ctx context.Context, id string) (*Template, error)

GetLatest retrieves the latest version of a template by ID

func (*Manager) List

func (m *Manager) List(ctx context.Context, filter map[string]interface{}) ([]*Template, error)

List returns all templates matching the given filter

func (*Manager) Render

func (m *Manager) Render(ctx context.Context, id string, version string, data map[string]interface{}) (string, error)

Render renders a template with the given data

func (*Manager) RenderLatest

func (m *Manager) RenderLatest(ctx context.Context, id string, data map[string]interface{}) (string, error)

RenderLatest renders the latest version of a template with the given data

func (*Manager) Save

func (m *Manager) Save(ctx context.Context, tmpl *Template) error

Save stores a template

type Template

type Template struct {
	ID          string
	Name        string
	Description string
	Content     string
	Version     string
	Format      TemplateFormat
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Tags        []string
	Metadata    map[string]interface{}
	// contains filtered or unexported fields
}

Template represents a prompt template

func New

func New(id string, name string, content string, options ...TemplateOption) *Template

New creates a new template

func (*Template) Render

func (t *Template) Render(data map[string]interface{}) (string, error)

Render renders the template with the given data

type TemplateFormat

type TemplateFormat string

TemplateFormat represents the format of a template

const (
	// GoTemplate uses Go's text/template package
	GoTemplate TemplateFormat = "go_template"

	// HandlebarsTemplate uses handlebars-style templates
	HandlebarsTemplate TemplateFormat = "handlebars"
)

type TemplateOption

type TemplateOption func(*Template)

TemplateOption is a function that configures a template

func WithDescription

func WithDescription(description string) TemplateOption

WithDescription sets the template description

func WithFormat

func WithFormat(format TemplateFormat) TemplateOption

WithFormat sets the template format

func WithMetadata

func WithMetadata(metadata map[string]interface{}) TemplateOption

WithMetadata sets the template metadata

func WithTags

func WithTags(tags ...string) TemplateOption

WithTags sets the template tags

func WithVersion

func WithVersion(version string) TemplateOption

WithVersion sets the template version

type TemplateStore

type TemplateStore interface {
	// Get retrieves a template by ID and version
	Get(ctx context.Context, id string, version string) (*Template, error)

	// List returns all templates matching the given filter
	List(ctx context.Context, filter map[string]interface{}) ([]*Template, error)

	// Save stores a template
	Save(ctx context.Context, tmpl *Template) error

	// Delete removes a template
	Delete(ctx context.Context, id string, version string) error
}

TemplateStore is an interface for storing and retrieving templates

Jump to

Keyboard shortcuts

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