prompt

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPartialVariableType = errors.New("invalid partial variable type")
)

Functions

func ListTemplateFields

func ListTemplateFields(t *template.Template) []string

Types

type AIMessagetTemplate

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

func (*AIMessagetTemplate) Format

func (pt *AIMessagetTemplate) Format(values map[string]any) (*schema.AIChatMessage, error)

type ChatPromptValue

type ChatPromptValue struct{}

type ChatTemplate

type ChatTemplate struct{}

type Formatter

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

func NewFormatter

func NewFormatter(text string) (*Formatter, error)

func (*Formatter) Fields

func (pt *Formatter) Fields() []string

func (*Formatter) Render

func (pt *Formatter) Render(values map[string]any) (string, error)

type HumanMessageTemplate

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

func (*HumanMessageTemplate) Format

func (pt *HumanMessageTemplate) Format(values map[string]any) (*schema.HumanChatMessage, error)

type PartialValues

type PartialValues map[string]any

type StringPromptValue

type StringPromptValue string

func (StringPromptValue) Messages

func (v StringPromptValue) Messages() schema.ChatMessages

func (StringPromptValue) String

func (v StringPromptValue) String() string

type SystemMessageTemplate

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

func NewSystemMessageTemplate

func NewSystemMessageTemplate(prompt *Template) *SystemMessageTemplate

func (*SystemMessageTemplate) Format

func (pt *SystemMessageTemplate) Format(values map[string]any) (*schema.SystemChatMessage, error)

type Template

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

func NewTemplate

func NewTemplate(template string, optFns ...func(o *TemplateOptions)) (*Template, error)

func (*Template) Format

func (p *Template) Format(values map[string]any) (string, error)

func (*Template) FormatPrompt

func (p *Template) FormatPrompt(values map[string]any) (schema.PromptValue, error)

func (*Template) InputVariables added in v0.0.2

func (p *Template) InputVariables() []string

func (*Template) OutputParser added in v0.0.3

func (p *Template) OutputParser() (schema.OutputParser[any], bool)

func (*Template) Partial

func (p *Template) Partial(values PartialValues) (*Template, error)

type TemplateOptions

type TemplateOptions struct {
	PartialValues PartialValues
	Language      string
	OutputParser  schema.OutputParser[any]
}

Jump to

Keyboard shortcuts

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