diff --git a/core/agent/agent.go b/core/agent/agent.go index a614bb1..582dcfd 100644 --- a/core/agent/agent.go +++ b/core/agent/agent.go @@ -617,7 +617,7 @@ func (a *Agent) consumeJob(job *types.Job, role string, retries int) { conv = a.processUserInputs(job, role, conv) // RAG - a.knowledgeBaseLookup(conv) + conv = a.knowledgeBaseLookup(conv) var pickTemplate string var reEvaluationTemplate string diff --git a/core/agent/knowledgebase.go b/core/agent/knowledgebase.go index 4ba9ba4..de49950 100644 --- a/core/agent/knowledgebase.go +++ b/core/agent/knowledgebase.go @@ -10,11 +10,11 @@ import ( "github.com/sashabaranov/go-openai" ) -func (a *Agent) knowledgeBaseLookup(conv Messages) { +func (a *Agent) knowledgeBaseLookup(conv Messages) Messages { if (!a.options.enableKB && !a.options.enableLongTermMemory && !a.options.enableSummaryMemory) || len(conv) <= 0 { xlog.Debug("[Knowledge Base Lookup] Disabled, skipping", "agent", a.Character.Name) - return + return conv } // Walk conversation from bottom to top, and find the first message of the user @@ -25,7 +25,7 @@ func (a *Agent) knowledgeBaseLookup(conv Messages) { if userMessage == "" { xlog.Info("[Knowledge Base Lookup] No user message found in conversation", "agent", a.Character.Name) - return + return conv } results, err := a.options.ragdb.Search(userMessage, a.options.kbResults) @@ -35,7 +35,7 @@ func (a *Agent) knowledgeBaseLookup(conv Messages) { if len(results) == 0 { xlog.Info("[Knowledge Base Lookup] No similar strings found in KB", "agent", a.Character.Name) - return + return conv } formatResults := "" @@ -55,6 +55,8 @@ func (a *Agent) knowledgeBaseLookup(conv Messages) { Role: "system", Content: fmt.Sprintf("Given the user input you have the following in memory:\n%s", formatResults), }}, conv...) + + return conv } func (a *Agent) saveConversation(m Messages, prefix string) error {