fix(core): Add prompt generated from KB to conv (#156)
Signed-off-by: Richard Palethorpe <io@richiejp.com>
This commit is contained in:
committed by
GitHub
parent
a288ea9a36
commit
112cb1f955
@@ -617,7 +617,7 @@ func (a *Agent) consumeJob(job *types.Job, role string, retries int) {
|
|||||||
conv = a.processUserInputs(job, role, conv)
|
conv = a.processUserInputs(job, role, conv)
|
||||||
|
|
||||||
// RAG
|
// RAG
|
||||||
a.knowledgeBaseLookup(conv)
|
conv = a.knowledgeBaseLookup(conv)
|
||||||
|
|
||||||
var pickTemplate string
|
var pickTemplate string
|
||||||
var reEvaluationTemplate string
|
var reEvaluationTemplate string
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import (
|
|||||||
"github.com/sashabaranov/go-openai"
|
"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) ||
|
if (!a.options.enableKB && !a.options.enableLongTermMemory && !a.options.enableSummaryMemory) ||
|
||||||
len(conv) <= 0 {
|
len(conv) <= 0 {
|
||||||
xlog.Debug("[Knowledge Base Lookup] Disabled, skipping", "agent", a.Character.Name)
|
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
|
// 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 == "" {
|
if userMessage == "" {
|
||||||
xlog.Info("[Knowledge Base Lookup] No user message found in conversation", "agent", a.Character.Name)
|
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)
|
results, err := a.options.ragdb.Search(userMessage, a.options.kbResults)
|
||||||
@@ -35,7 +35,7 @@ func (a *Agent) knowledgeBaseLookup(conv Messages) {
|
|||||||
|
|
||||||
if len(results) == 0 {
|
if len(results) == 0 {
|
||||||
xlog.Info("[Knowledge Base Lookup] No similar strings found in KB", "agent", a.Character.Name)
|
xlog.Info("[Knowledge Base Lookup] No similar strings found in KB", "agent", a.Character.Name)
|
||||||
return
|
return conv
|
||||||
}
|
}
|
||||||
|
|
||||||
formatResults := ""
|
formatResults := ""
|
||||||
@@ -55,6 +55,8 @@ func (a *Agent) knowledgeBaseLookup(conv Messages) {
|
|||||||
Role: "system",
|
Role: "system",
|
||||||
Content: fmt.Sprintf("Given the user input you have the following in memory:\n%s", formatResults),
|
Content: fmt.Sprintf("Given the user input you have the following in memory:\n%s", formatResults),
|
||||||
}}, conv...)
|
}}, conv...)
|
||||||
|
|
||||||
|
return conv
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Agent) saveConversation(m Messages, prefix string) error {
|
func (a *Agent) saveConversation(m Messages, prefix string) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user