Documentation ¶
Index ¶
- Variables
- func NewDefaultSemanticFunctionCall(promptTemplate *template.Template, generator llm.Generator) (skillFunc func(input llm.Content) (response llm.Content, err error))
- func ParseSemanticFunctionsFromFS(fsys fs.FS, generators map[string]llm.Generator, ...) (functions map[string]*Function, err error)
- func WithCustomCall(...) (option parseSemanticFunctionFromFSOption)
- func WithCustomCallForFunc(funcName string, ...) (option createSemanticFunctionsOption)
- type Function
- type Parameter
- type SemanticKernel
- func (sk *SemanticKernel) AddSkills(skills ...*Skill) (err error)
- func (sk *SemanticKernel) Call(skillName string, skillFunction string, input llm.Content) (response llm.Content, err error)
- func (sk *SemanticKernel) ChainCall(context llm.Content, functions ...*Function) (response llm.Content, err error)
- func (sk *SemanticKernel) FindFunction(skillName string, skillFunction string) (function *Function, ok bool)
- func (sk *SemanticKernel) FindFunctions(functionPaths ...string) (functions []*Function, err error)
- func (sk *SemanticKernel) FindSkill(skillName string) (skill *Skill, ok bool)
- func (sk *SemanticKernel) RegisterGeneratorFactories(factories ...llm.GeneratorFactory)
- func (sk *SemanticKernel) RegisterSkills(skillFactories ...SkillFactoryFunc) (err error)
- type Skill
- type SkillFactoryFunc
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingParameter is returned when a required parameter is missing ErrMissingParameter = errors.New("missing parameter") )
Functions ¶
func NewDefaultSemanticFunctionCall ¶ added in v0.1.0
func NewDefaultSemanticFunctionCall(promptTemplate *template.Template, generator llm.Generator) (skillFunc func(input llm.Content) (response llm.Content, err error))
NewDefaultSemanticFunctionCall creates a new semantic skill function with a prompt template and a generator
func ParseSemanticFunctionsFromFS ¶ added in v0.1.0
func WithCustomCall ¶ added in v0.1.0
func WithCustomCall(createSemanticFunctionCall func(promptTemplate *template.Template, generator llm.Generator) (skillFunc func(input llm.Content) (response llm.Content, err error))) (option parseSemanticFunctionFromFSOption)
WithCustomCall allows to create a custom semantic function call while parsing a semantic function with ParseSemanticFunctionFromFS
func WithCustomCallForFunc ¶ added in v0.1.0
func WithCustomCallForFunc(funcName string, createSemanticFunctionCall func(promptTemplate *template.Template, generator llm.Generator) (skillFunc func(input llm.Content) (response llm.Content, err error))) (option createSemanticFunctionsOption)
WithCustomCallForFunc allows to create selectively custom semantic function calls while parsing multiple semantic functions with ParseSemanticFunctionsFromFS
Types ¶
type Function ¶
type Function struct { // Name of the SkillFunction Name string `json:"name,omitempty"` // Description what the SkillFunction is doing Description string `json:"description"` // Plannable indicates whether the skill function can be planned by the semantic kernel Plannable bool `json:"plannable,omitempty"` // InputProperties map whose keys are the input property names and whose values are the input property definitions InputProperties map[string]*Parameter `json:"inputProperties"` // call holds the function that is executed when the skill function is called Call func(input llm.Content) (output llm.Content, err error) `json:"-"` }
Function defines and describes a skill's function with its input properties and its actual function call
func ParseSemanticFunctionFromFS ¶
func ParseSemanticFunctionFromFS(fsys fs.FS, generators map[string]llm.Generator, options ...parseSemanticFunctionFromFSOption) (function *Function, err error)
ParseFunctionFromFS finds "config.json" with function comfiguration. Prompt templates will be created from "*.tmpl" files with at least "skprompt.tmpl" is needed
type Parameter ¶
type Parameter struct { Name string `json:"name,omitempty"` Description string `json:"description"` Type Type `json:"type,omitempty"` Enum []string `json:"enum,omitempty"` Required bool `json:"required,omitempty"` Default interface{} `json:"default,omitempty"` }
Parameter defines a function's parameter with its name, description and type
type SemanticKernel ¶
type SemanticKernel struct {
// contains filtered or unexported fields
}
SemanticKernel
func NewKernel ¶
func NewKernel(opts ...newKernelOption) *SemanticKernel
NewKernel creates new kernel and tries to retrieve the OpenAI key from "OPENAI_API_KEY" environment variable or .env file in current working directory
func (*SemanticKernel) AddSkills ¶
func (sk *SemanticKernel) AddSkills(skills ...*Skill) (err error)
AddSkills adds already initialized skills to the kernel with their individual names
func (*SemanticKernel) Call ¶
func (sk *SemanticKernel) Call(skillName string, skillFunction string, input llm.Content) (response llm.Content, err error)
Call a skill function with given name and input. Returns the response and/or an error The kernel also links the input as predecessor to the response
func (*SemanticKernel) ChainCall ¶
func (sk *SemanticKernel) ChainCall(context llm.Content, functions ...*Function) (response llm.Content, err error)
ChainCall to call multiple functions in a row context is passed to all functions and context["data"] is updated with the response of each function
func (*SemanticKernel) FindFunction ¶
func (sk *SemanticKernel) FindFunction(skillName string, skillFunction string) (function *Function, ok bool)
FindFunction finds a function in a skill by name and returns it or an error if not found
func (*SemanticKernel) FindFunctions ¶
func (sk *SemanticKernel) FindFunctions(functionPaths ...string) (functions []*Function, err error)
FindFunctions finds functions with path notation (`skillName.functionName`) and returns them or an error if any function is not found
func (*SemanticKernel) FindSkill ¶
func (sk *SemanticKernel) FindSkill(skillName string) (skill *Skill, ok bool)
FindSkill finds a skill by name and returns it or an error if not found
func (*SemanticKernel) RegisterGeneratorFactories ¶ added in v0.1.0
func (sk *SemanticKernel) RegisterGeneratorFactories(factories ...llm.GeneratorFactory)
func (*SemanticKernel) RegisterSkills ¶ added in v0.1.0
func (sk *SemanticKernel) RegisterSkills(skillFactories ...SkillFactoryFunc) (err error)
RegisterSkills creates new skills with their factories and adds them to the kernel with their individual names
type Skill ¶
type Skill struct { // Name of the skill Name string `json:"name,omitempty"` // Description of the skill should indicate and give an idea about the functions that are included Description string `json:"description"` // Plannable indicates whether the skill can be planned by the semantic kernel Plannable bool `json:"plannable,omitempty"` // Functions that the skill provides Functions map[string]*Function `json:"functions"` // Generators that might be initialized while parsing a skill from a configuration Generators map[string]llm.Generator `json:"-"` }
Skill defines and holds a collection of Skill Functions that can be planned and called by the semantic kernel
func ParseSemanticSkillFromFS ¶
func ParseSemanticSkillFromFS(fsys fs.FS, generatorFactories llm.GeneratorFactoryMap, options ...createSemanticFunctionsOption) (skill *Skill, err error)
ParseSemanticSkillFromFS parses a skill from fsys file system (see assets/skills for examples). Given generatorFactories are used to create and return generators that are configured for this skill.
type SkillFactoryFunc ¶ added in v0.1.0
type SkillFactoryFunc func(generatorFactories llm.GeneratorFactoryMap) (skill *Skill, err error)
SkillFactoryFunc to create a semantic skill with the help of given generators