messageformatters

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AI

type AI struct {
	Template llm.Template
}

AI is a message formatter that returns an AI message.

func NewAI

func NewAI(content string, variables []string) AI

NewAI creates a new AI message prompt formatter.

func (AI) FormatMessages

func (a AI) FormatMessages(values map[string]any) ([]llm.ChatMessage, error)

FormatMessages formats the message with the values given.

func (AI) InputVariables

func (a AI) InputVariables() []string

InputVariables returns the input variables the prompt expects.

type Generic

type Generic struct {
	Role     string
	Template llm.Template
}

Generic is a message formatter that returns message with the specified speaker.

func NewGeneric

func NewGeneric(role, content string, variables []string) Generic

NewGeneric creates a new generic message prompt formatter.

func (Generic) FormatMessages

func (g Generic) FormatMessages(values map[string]any) ([]llm.ChatMessage, error)

FormatMessages formats the message with the values given.

func (Generic) InputVariables

func (g Generic) InputVariables() []string

InputVariables returns the input variables the prompt expects.

type Human

type Human struct {
	Template llm.Template
}

Human is a message formatter that returns a human message.

func NewHuman

func NewHuman(content string, variables []string) Human

NewHuman creates a new human message prompt formatter.

func (Human) FormatMessages

func (h Human) FormatMessages(values map[string]any) ([]llm.ChatMessage, error)

FormatMessages formats the message with the values given.

func (Human) InputVariables

func (h Human) InputVariables() []string

InputVariables returns the input variables the prompt expects.

type Placeholder

type Placeholder struct {
	Variable string
}

Placeholder is a message formatter that returns a placeholder message.

func NewPlaceholder

func NewPlaceholder(variable string) Placeholder

NewPlaceholder creates a new placeholder message prompt formatter.

func (Placeholder) FormatMessages

func (p Placeholder) FormatMessages(values map[string]any) ([]llm.ChatMessage, error)

FormatMessages formats the messages from the values by variable name.

func (Placeholder) InputVariables

func (p Placeholder) InputVariables() []string

InputVariables returns the input variables the prompt expect.

type System

type System struct {
	Template llm.Template
}

System is a message formatter that returns a system message.

func NewSystem

func NewSystem(content string, inputVariables []string) System

NewSystem creates a new system message prompt formatter.

func (System) FormatMessages

func (s System) FormatMessages(values map[string]any) ([]llm.ChatMessage, error)

FormatMessages formats the message with the values given.

func (System) InputVariables

func (s System) InputVariables() []string

InputVariables returns the input variables the prompt expects.

Jump to

Keyboard shortcuts

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