Consolidated a bunch of reused code to agents

This commit is contained in:
2025-03-26 00:21:19 -04:00
parent 5407c1a7cc
commit 5d2c350acf
33 changed files with 2866 additions and 803 deletions

29
pkg/agents/steps.go Normal file
View File

@@ -0,0 +1,29 @@
package agents
import (
"context"
gollm "gitea.stevedudenhoeffer.com/steve/go-llm"
)
// Steps is a utility function that will ask the LLM to split a goal into smaller steps.
// It is a utility function and as such it does not use the agent's set system prompts, it will however use any
// contextual information that it has.
func (a Agent) Steps(ctx context.Context, goal string) ([]string, error) {
var res []string
fnSteps := gollm.NewFunction(
"steps",
"split the provided goal by the user into sub-steps",
func(ctx *gollm.Context, args struct {
Steps []string `description:"The steps that should be taken to achieve the goal"`
}) (any, error) {
res = append(res, args.Steps...)
return "", nil
})
_, err := a.WithSystemPrompt(`The user is going to mention a goal to you, and you are to respond using only one call of the "steps" function. You should provide the "steps" function with steps that should be taken to achieve the goal the user requests.`).
WithSystemPromptSuffix(``).
WithToolbox(gollm.NewToolBox(fnSteps)).
CallAndExecute(ctx, goal)
return res, err
}