prompts

package
v0.0.171 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAllPromptFiles added in v0.0.171

func FindAllPromptFiles(dir string) []string

FindAllPromptFiles finds all YAML files in the prompts directory

func FindSDKGeneratedDir

func FindSDKGeneratedDir(logger logger.Logger, projectDir string) (string, error)

FindSDKGeneratedDir finds the SDK's generated directory in node_modules

func ProcessPrompts

func ProcessPrompts(logger logger.Logger, projectDir string) error

ProcessPrompts finds, parses, and generates prompt files into the SDK

Types

type CodeGenerator

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

CodeGenerator handles generating JavaScript and TypeScript code from prompts

func NewCodeGenerator

func NewCodeGenerator(prompts []Prompt) *CodeGenerator

NewCodeGenerator creates a new code generator

func (*CodeGenerator) GenerateJavaScript

func (cg *CodeGenerator) GenerateJavaScript() string

GenerateJavaScript generates the main JavaScript file

func (*CodeGenerator) GenerateTypeScriptTypes

func (cg *CodeGenerator) GenerateTypeScriptTypes() string

GenerateTypeScriptTypes generates the TypeScript definitions file

type Prompt

type Prompt struct {
	Name        string   `yaml:"name"`
	Slug        string   `yaml:"slug"`
	Description string   `yaml:"description"`
	System      string   `yaml:"system"`
	Prompt      string   `yaml:"prompt"`
	Evals       []string `yaml:"evals,omitempty"`

	// Parsed template information
	SystemTemplate Template `json:"system_template,omitempty"`
	PromptTemplate Template `json:"prompt_template,omitempty"`
}

Prompt represents a single prompt definition from YAML

func ParsePromptsYAML

func ParsePromptsYAML(data []byte) ([]Prompt, error)

ParsePromptsYAML parses YAML bytes and returns the prompt definitions

type PromptsYAML

type PromptsYAML struct {
	Prompts []Prompt `yaml:"prompts"`
}

PromptsYAML represents the structure of prompts.yaml for unmarshaling

type Template

type Template struct {
	OriginalTemplate string     `json:"original_template"`
	Variables        []Variable `json:"variables"`
}

Template represents a parsed template with its variables

func ParseTemplate

func ParseTemplate(template string) Template

ParseTemplate parses a template string and returns structured information about all variables Supports {{variable}}, {{!required}}, {variable:default}, {!variable:default} syntax

func (Template) OptionalVariableNames

func (t Template) OptionalVariableNames() []string

OptionalVariableNames returns just the names of optional variables

func (Template) OptionalVariables

func (t Template) OptionalVariables() []Variable

OptionalVariables returns all optional variables

func (Template) RequiredVariableNames

func (t Template) RequiredVariableNames() []string

RequiredVariableNames returns just the names of required variables

func (Template) RequiredVariables

func (t Template) RequiredVariables() []Variable

RequiredVariables returns all required variables

func (Template) VariableNames

func (t Template) VariableNames() []string

VariableNames returns just the names of all variables

func (Template) VariablesWithDefaults

func (t Template) VariablesWithDefaults() []Variable

VariablesWithDefaults returns all variables that have default values

func (Template) VariablesWithoutDefaults

func (t Template) VariablesWithoutDefaults() []Variable

VariablesWithoutDefaults returns all variables that don't have default values

type Variable

type Variable struct {
	Name           string `json:"name"`
	IsRequired     bool   `json:"is_required"`
	HasDefault     bool   `json:"has_default"`
	DefaultValue   string `json:"default_value,omitempty"`
	OriginalSyntax string `json:"original_syntax"`
}

Variable represents a single variable found in a template

Jump to

Keyboard shortcuts

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