From 1447b73dfbf780c75757230f4f52f4ac057fafe8 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Sat, 12 Apr 2025 02:30:01 -0400 Subject: [PATCH] Refactor function registration in knowledgeworker to use WithFunctions method --- pkg/agents/shared/knowledgeworker.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/agents/shared/knowledgeworker.go b/pkg/agents/shared/knowledgeworker.go index 4ed85d9..ae5c194 100644 --- a/pkg/agents/shared/knowledgeworker.go +++ b/pkg/agents/shared/knowledgeworker.go @@ -3,9 +3,10 @@ package shared import ( "context" "fmt" - "gitea.stevedudenhoeffer.com/steve/answer/pkg/agents" "strings" + "gitea.stevedudenhoeffer.com/steve/answer/pkg/agents" + gollm "gitea.stevedudenhoeffer.com/steve/go-llm" ) @@ -72,8 +73,8 @@ func (w KnowledgeWorker) Answer(context context.Context, knowledge *agents.Knowl Text: lastMsg, }) - req.Toolbox = w.ToolBox. - WithFunction(*gollm.NewFunction( + req.Toolbox = w.ToolBox.WithFunctions( + gollm.NewFunction( "notes_to_self", "leave future executions of the LLM a note or two, can be called many times", func(ctx *gollm.Context, args struct { @@ -82,8 +83,8 @@ func (w KnowledgeWorker) Answer(context context.Context, knowledge *agents.Knowl return agents.Knowledge{ NotesToSelf: args.NotesToSelf, }, nil - })). - WithFunction(*gollm.NewFunction( + }), + gollm.NewFunction( "new_objectives", "Set new objectives for the LLM to work on, can be called many times. If no new objectives are set, the LLM will continue to work on the current objectives.", func(ctx *gollm.Context, args struct { @@ -92,8 +93,8 @@ func (w KnowledgeWorker) Answer(context context.Context, knowledge *agents.Knowl return agents.Knowledge{ CurrentObjectives: args.Objectives, }, nil - })). - WithFunction(*gollm.NewFunction( + }), + gollm.NewFunction( "learn", `Use learn to pass some relevant information to the model. The model will use this information to answer the question. Use it to learn relevant information from the text. Keep these concise and relevant to the question. Can be called many times.`, func(ctx *gollm.Context, args struct {