Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FewShotPromptPair ¶
FewShotPromptPair represents a pair of user prompt and the corresponding response.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore represents a file-based storage system for handling prompt files.
func NewFileStore ¶
NewFileStore creates a new FileStore instance using the default file path ("prompts").
func NewFileStoreFromPath ¶
NewFileStoreFromPath creates a new FileStore instance from the specified directory path.
func (*FileStore) Load ¶
func (f *FileStore) Load() ([]PromptFile, error)
Load retrieves all prompt files from the specified file path and returns a slice of PromptFile objects or an error.
type FileStoreError ¶
FileStoreError represents an error encountered in file store operations. It contains a message describing the error and an optional underlying error.
func (FileStoreError) Error ¶
func (e FileStoreError) Error() string
Error returns the error message contained in the FileStoreError.
type InputSchema ¶
type InputSchema struct { Parameters map[string]string `yaml:"parameters"` Default map[string]interface{} `yaml:"default"` }
InputSchema represents the schema for input parameters and their default values.
type Loader ¶
type Loader interface { // Load loads prompt files and returns a slice of PromptFile and an error. Load() ([]PromptFile, error) }
Loader defines an interface for loading prompt files.
type Manager ¶
type Manager struct {
PromptFiles map[string]PromptFile
}
Manager is responsible for managing and storing prompt files, with mapping from their names to PromptFile instances.
func NewManager ¶
NewManager creates a new Manager by loading prompt files from the default file store. Returns a pointer to the Manager instance or an error if the loading process fails.
func NewManagerFromLoader ¶
NewManagerFromLoader initializes and returns a Manager instance by loading prompt files using the provided Loader. It returns a pointer to the Manager and an error if the loading process fails.
func (*Manager) GetPromptFile ¶
func (m *Manager) GetPromptFile(name string) (PromptFile, error)
GetPromptFile retrieves the prompt file with the specified name from the manager's stored prompt files. Returns the PromptFile and a boolean indicating success of the retrieval.
func (*Manager) ListPromptFileNames ¶
ListPromptFileNames returns a list of all prompt file names managed by the Manager.
type OutputFormat ¶
type OutputFormat int
OutputFormat represents the format of output, such as text or JSON.
const ( // Text represents the plain text output format. Text OutputFormat = iota // Json represents the JSON output format. Json )
func (*OutputFormat) UnmarshalYAML ¶
func (of *OutputFormat) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML unmarshals a YAML node into an OutputFormat value, supporting "text" and "json". Returns an error if format is invalid.
type PromptConfig ¶
type PromptConfig struct { Temperature *float32 `yaml:"temperature"` MaxTokens *int `yaml:"maxTokens"` OutputFormat OutputFormat `yaml:"outputFormat"` Input InputSchema `yaml:"input"` }
PromptConfig represents the configuration options for a prompt, including temperature, max tokens, output format, and input schema.
type PromptError ¶
type PromptError struct {
Message string
}
PromptError represents an error related to prompt processing.
func (PromptError) Error ¶
func (e PromptError) Error() string
Error returns the error message associated with the PromptError.
type PromptFile ¶
type PromptFile struct { Name string `yaml:"name"` Config PromptConfig `yaml:"config"` Prompts Prompts `yaml:"prompts"` FewShots []FewShotPromptPair `yaml:"fewShots"` }
PromptFile represents the structure of a file containing a prompt configuration and multiple associated prompts.
func NewPromptFile ¶
func NewPromptFile(name string, data []byte) (*PromptFile, error)
NewPromptFile creates a new PromptFile from the provided name and prompt data. It validates the input, configures the prompt file, and returns an error if any issues are encountered.
func NewPromptFileFromFile ¶
func NewPromptFileFromFile(path string) (*PromptFile, error)
NewPromptFileFromFile reads a file from the specified path, processes its content, and returns a PromptFile structure or an error.
func (*PromptFile) GetSystemPrompt ¶
func (pf *PromptFile) GetSystemPrompt(values map[string]interface{}) (string, error)
GetSystemPrompt generates the system prompt string using the provided template values, appending JSON format instructions if required.
func (*PromptFile) GetUserPrompt ¶
func (pf *PromptFile) GetUserPrompt(values map[string]interface{}) (string, error)
GetUserPrompt generates a user prompt string based on a provided template and a set of values. It utilizes the 'Prompts.User' template within the PromptFile and replaces template placeholders with corresponding values from the input map.