Documentation
¶
Overview ¶
Package prompt defines callback payloads for prompt components.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetImplSpecificOptions ¶
GetImplSpecificOptions extracts the implementation specific options from Option list, optionally providing a base options with default values.
Types ¶
type CallbackInput ¶
type CallbackInput struct {
// Variables is the variables for the callback.
Variables map[string]any
// Templates is the templates for the callback.
Templates []schema.MessagesTemplate
// Extra is the extra information for the callback.
Extra map[string]any
}
CallbackInput is the input for the callback.
func ConvCallbackInput ¶
func ConvCallbackInput(src callbacks.CallbackInput) *CallbackInput
ConvCallbackInput converts the callback input to the prompt callback input.
type CallbackOutput ¶
type CallbackOutput struct {
// Result is the result for the callback.
Result []*schema.Message
// Templates is the templates for the callback.
Templates []schema.MessagesTemplate
// Extra is the extra information for the callback.
Extra map[string]any
}
CallbackOutput is the output for the callback.
func ConvCallbackOutput ¶
func ConvCallbackOutput(src callbacks.CallbackOutput) *CallbackOutput
ConvCallbackOutput converts the callback output to the prompt callback output.
type ChatTemplate ¶
type ChatTemplate interface {
Format(ctx context.Context, vs map[string]any, opts ...Option) ([]*schema.Message, error)
}
ChatTemplate formats variables into a list of messages according to a prompt schema.
type DefaultChatTemplate ¶
type DefaultChatTemplate struct {
// contains filtered or unexported fields
}
DefaultChatTemplate is the default chat template implementation.
func FromMessages ¶
func FromMessages(formatType schema.FormatType, templates ...schema.MessagesTemplate) *DefaultChatTemplate
FromMessages creates a new DefaultChatTemplate from the given templates and format type. eg.
template := prompt.FromMessages(schema.FString, &schema.Message{Content: "Hello, {name}!"}, &schema.Message{Content: "how are you?"})
// in chain, or graph
chain := compose.NewChain[map[string]any, []*schema.Message]()
chain.AppendChatTemplate(template)
func (*DefaultChatTemplate) Format ¶
func (t *DefaultChatTemplate) Format(ctx context.Context, vs map[string]any, _ ...Option) (result []*schema.Message, err error)
Format formats the chat template with the given context and variables.
func (*DefaultChatTemplate) GetType ¶
func (t *DefaultChatTemplate) GetType() string
GetType returns the type of the chat template (Default).
func (*DefaultChatTemplate) IsCallbacksEnabled ¶
func (t *DefaultChatTemplate) IsCallbacksEnabled() bool
IsCallbacksEnabled checks if the callbacks are enabled for the chat template.