Refactor entire system to be more contextual so that conversation flow can be more easily managed

This commit is contained in:
2025-03-16 22:38:58 -04:00
parent 0d909edd44
commit 7f5e34e437
9 changed files with 377 additions and 61 deletions

View File

@@ -1,7 +1,6 @@
package go_llm
import (
"context"
"errors"
"fmt"
"github.com/sashabaranov/go-openai"
@@ -64,7 +63,7 @@ var (
ErrFunctionNotFound = errors.New("function not found")
)
func (t *ToolBox) ExecuteFunction(ctx context.Context, functionName string, params string) (string, error) {
func (t *ToolBox) executeFunction(ctx *Context, functionName string, params string) (string, error) {
f, ok := t.names[functionName]
if !ok {
@@ -74,6 +73,6 @@ func (t *ToolBox) ExecuteFunction(ctx context.Context, functionName string, para
return f.Execute(ctx, params)
}
func (t *ToolBox) Execute(ctx context.Context, toolCall ToolCall) (string, error) {
return t.ExecuteFunction(ctx, toolCall.FunctionCall.Name, toolCall.FunctionCall.Arguments)
func (t *ToolBox) Execute(ctx *Context, toolCall ToolCall) (string, error) {
return t.executeFunction(ctx.WithToolCall(&toolCall), toolCall.FunctionCall.Name, toolCall.FunctionCall.Arguments)
}