Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyTemplateToContent(template *template.Template, content Content) error
- func ExecuteTemplate(template *template.Template, data interface{}) (string, error)
- func TemplateFromFS(fsys fs.FS, patterns ...string) (*template.Template, error)
- func TemplateFromText(text string) (*template.Template, error)
- type Content
- type ContentProperty
- type ContentRole
- type Generator
- type GeneratorConfig
- type GeneratorConfigData
- type GeneratorFactory
- type GeneratorFactoryMap
Constants ¶
const ( // TypeUser indicates that the message is user or human generated TypeUser string = "user" // TypeSystem indicates that the message is a system instruction to the model TypeSystem string = "system" // TypeNativeFunctionResponse indicates that the message contains a native function response TypeNativeFunctionResponse string = "functionResponse" )
Variables ¶
var (
ErrUnknownGeneratorType = errors.New("unknown generator type")
)
Functions ¶
func ApplyTemplateToContent ¶ added in v0.1.0
func ExecuteTemplate ¶ added in v0.1.0
func TemplateFromFS ¶ added in v0.1.0
Types ¶
type Content ¶
type Content interface { ContentProperty // With sets a property at given path and is a shortcut for Property(path).Set(value) With(path string, value interface{}) Content // Prop returns the content's property at given path, nil if not available Property(path string) ContentProperty // Properties returns all properties of the content and its predecessors Properties() map[string]ContentProperty // Input is an alias for Content's Value() Input() ContentProperty // SetRole sets Content's optionl role SetRole(ContentRole) Content // Role returns Content's role, RoleEmpty if not set Role() ContentRole // SetName set Content's optional name SetName(string) Content // Name() return Content's name, "" if not set Name() string // WithPredecessor adds (or overwrites) `predecessor` option WithPredecessor(content Content) Content // Predecessor returns predecessor if "predecessor" option is available. Otherwise nil is returned Predecessor() Content }
func NewContent ¶
func NewContent(value ...interface{}) Content
NewContent to create new Content with given content value
type ContentProperty ¶
type ContentRole ¶
type ContentRole string
Content can be * User Message -> Message.Role="user", Message.Content * System Message -> Message.Role="system", Message.Content * Assistant Message -> Message.Role="assistant", Message.Content * Function Call -> Message.Role="assistant", Message.FunctionCall.Name, Message.FunctionCall.Arguments * Function Response -> Message.Role="function", Massage.Content=<function response> * []Content with any above
const ( RoleEmpty ContentRole = "" RoleUser ContentRole = "user" RoleSystem ContentRole = "system" RoleAssistant ContentRole = "assistant" RoleFunctionCall ContentRole = "funcCall" RoleFunctionResponse ContentRole = "funcResponse" )
type Generator ¶
type Generator interface { // GenerateResponse to get response from the model behind the generator Generate(input Content) (response Content, err error) }
Generator as a generic interface for large langage model response generators
type GeneratorConfig ¶
type GeneratorConfig struct { TypeID string `json:"typeID"` ConfigProperties GeneratorConfigData `json:"config,omitempty"` }
GeneratorConfig to configure a specific generator's (defined by ID) response generator
type GeneratorConfigData ¶ added in v0.1.0
type GeneratorConfigData map[string]interface{}
func (*GeneratorConfigData) Convert ¶ added in v0.1.0
func (gcd *GeneratorConfigData) Convert(to interface{}) (err error)
Convert config data into given object
type GeneratorFactory ¶ added in v0.1.0
type GeneratorFactory interface { TypeID() string New(config GeneratorConfigData) (Generator, error) }
GeneratorFactory allows to create response generators
type GeneratorFactoryMap ¶ added in v0.1.0
type GeneratorFactoryMap map[string]GeneratorFactory
GeneratorFactoryMap is a map of generator factories of different types
func (GeneratorFactoryMap) CreateGenerator ¶ added in v0.1.0
func (gm GeneratorFactoryMap) CreateGenerator(typeID string, config map[string]interface{}) (Generator, error)
func (GeneratorFactoryMap) CreateGenerators ¶ added in v0.1.0
func (gm GeneratorFactoryMap) CreateGenerators(generatorConfigs map[string]GeneratorConfig) (generators map[string]Generator, err error)
CreateResponseGenerators creates response generators map from a given config map. Their keys are the names of the response generators.