Versions in this module Expand all Collapse all v0 v0.1.1 Mar 2, 2024 v0.1.0 Feb 29, 2024 Changes in this version + var ErrExamplesAndExampleSelectorProvided = errors.New(...) + var ErrInputVariableReserved = errors.New("conflict with reserved variable name") + var ErrInvalidPartialVariableType = errors.New("invalid partial variable type") + var ErrInvalidTemplateFormat = errors.New("invalid template format") + var ErrNeedChatMessageList = errors.New("variable should be a list of chat messages") + var ErrNoExample = errors.New("no example is provided") + func CheckValidTemplate(template string, templateFormat TemplateFormat, inputVariables []string) error + func RenderTemplate(tmpl string, tmplFormat TemplateFormat, values map[string]any) (string, error) + type AIMessagePromptTemplate struct + Prompt PromptTemplate + func NewAIMessagePromptTemplate(template string, inputVariables []string) AIMessagePromptTemplate + func (p AIMessagePromptTemplate) FormatMessages(values map[string]any) ([]schema.ChatMessage, error) + func (p AIMessagePromptTemplate) GetInputVariables() []string + type ChatPromptTemplate struct + Messages []MessageFormatter + PartialVariables map[string]any + func NewChatPromptTemplate(messages []MessageFormatter) ChatPromptTemplate + func (p ChatPromptTemplate) Format(values map[string]any) (string, error) + func (p ChatPromptTemplate) FormatMessages(values map[string]any) ([]schema.ChatMessage, error) + func (p ChatPromptTemplate) FormatPrompt(values map[string]any) (schema.PromptValue, error) + func (p ChatPromptTemplate) GetInputVariables() []string + type ChatPromptValue []schema.ChatMessage + func (v ChatPromptValue) Messages() []schema.ChatMessage + func (v ChatPromptValue) String() string + type ExampleSelector interface + AddExample func(example map[string]string) string + SelectExamples func(inputVariables map[string]string) []map[string]string + type FewShotPrompt struct + ExamplePrompt PromptTemplate + ExampleSelector ExampleSelector + ExampleSeparator string + Examples []map[string]string + InputVariables []string + PartialVariables map[string]any + Prefix string + Suffix string + TemplateFormat TemplateFormat + ValidateTemplate bool + func NewFewShotPrompt(examplePrompt PromptTemplate, examples []map[string]string, ...) (*FewShotPrompt, error) + func (p *FewShotPrompt) AssemblePieces(exampleStrings []string) string + func (p *FewShotPrompt) Format(values map[string]interface{}) (string, error) + func (p *FewShotPrompt) FormatPrompt(values map[string]any) (schema.PromptValue, error) + func (p *FewShotPrompt) GetInputVariables() []string + type FormatPrompter interface + FormatPrompt func(values map[string]any) (schema.PromptValue, error) + GetInputVariables func() []string + type Formatter interface + Format func(values map[string]any) (string, error) + type GenericMessagePromptTemplate struct + Prompt PromptTemplate + Role string + func NewGenericMessagePromptTemplate(role, template string, inputVariables []string) GenericMessagePromptTemplate + func (p GenericMessagePromptTemplate) FormatMessages(values map[string]any) ([]schema.ChatMessage, error) + func (p GenericMessagePromptTemplate) GetInputVariables() []string + type HumanMessagePromptTemplate struct + Prompt PromptTemplate + func NewHumanMessagePromptTemplate(template string, inputVariables []string) HumanMessagePromptTemplate + func (p HumanMessagePromptTemplate) FormatMessages(values map[string]any) ([]schema.ChatMessage, error) + func (p HumanMessagePromptTemplate) GetInputVariables() []string + type MessageFormatter interface + FormatMessages func(values map[string]any) ([]schema.ChatMessage, error) + GetInputVariables func() []string + type MessagesPlaceholder struct + VariableName string + func (p MessagesPlaceholder) FormatMessages(values map[string]any) ([]schema.ChatMessage, error) + func (p MessagesPlaceholder) GetInputVariables() []string + type PromptTemplate struct + InputVariables []string + OutputParser schema.OutputParser[any] + PartialVariables map[string]any + Template string + TemplateFormat TemplateFormat + func NewPromptTemplate(template string, inputVars []string) PromptTemplate + func (p PromptTemplate) Format(values map[string]any) (string, error) + func (p PromptTemplate) FormatPrompt(values map[string]any) (schema.PromptValue, error) + func (p PromptTemplate) GetInputVariables() []string + type StringPromptValue string + func (v StringPromptValue) Messages() []schema.ChatMessage + func (v StringPromptValue) String() string + type SystemMessagePromptTemplate struct + Prompt PromptTemplate + func NewSystemMessagePromptTemplate(template string, inputVariables []string) SystemMessagePromptTemplate + func (p SystemMessagePromptTemplate) FormatMessages(values map[string]any) ([]schema.ChatMessage, error) + func (p SystemMessagePromptTemplate) GetInputVariables() []string + type TemplateFormat string + const TemplateFormatFString + const TemplateFormatGoTemplate + const TemplateFormatJinja2