templates

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MergedTemplateLocator

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

MergedTemplateLocator is a TemplateLocator that merges templates from multiple locators making the last applied locator the one that takes precedence in case of name conflicts.

func NewMergedTemplateLocator

func NewMergedTemplateLocator(locators ...TemplateLocator) *MergedTemplateLocator

NewMergedTemplateLocator creates a new MergedTemplateLocator.

func (*MergedTemplateLocator) GetTemplate

func (c *MergedTemplateLocator) GetTemplate(name string) (*Template, error)

GetTemplate returns a template by name.

func (*MergedTemplateLocator) ListTemplates

func (c *MergedTemplateLocator) ListTemplates() ([]Template, error)

ListTemplates returns a list of available templates.

type Template

type Template struct {
	// Name is the name of the template
	Name string `yaml:"name"`

	// Description is a short description of the template
	Description string `yaml:"description"`

	// DefaultPrompt is the prompt that is used if no prompt is provided
	DefaultPrompt string `yaml:"defaultPrompt,omitempty"`

	// SystemMessage is the message that primes the conversation
	SystemMessage string `yaml:"systemMessage"`

	// Variables is a list of input variables for the template
	Variables []TemplateVariable `yaml:"variables"`
}

type TemplateLocator

type TemplateLocator interface {
	// ListTemplates returns a list of available templates
	ListTemplates() ([]Template, error)

	// GetTemplate returns a template by name
	GetTemplate(name string) (*Template, error)
}

type TemplateVariable

type TemplateVariable struct {
	// Name is the name of the input variable
	Name string `yaml:"name"`

	// Description is a short description of the input variable
	Description string `yaml:"description"`

	// DefaultValue is the value used if no override is provided
	DefaultValue string `yaml:"defaultValue,omitempty"`
}

type YamlFileTemplateLocator

type YamlFileTemplateLocator struct {
	// Path is the path to the directory containing the templates
	Path string
}

func NewYamlFileTemplateLocator

func NewYamlFileTemplateLocator(path string) *YamlFileTemplateLocator

func (*YamlFileTemplateLocator) GetTemplate

func (y *YamlFileTemplateLocator) GetTemplate(name string) (*Template, error)

func (*YamlFileTemplateLocator) ListTemplates

func (y *YamlFileTemplateLocator) ListTemplates() ([]Template, error)

Jump to

Keyboard shortcuts

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