Refactor Knowledge struct into shared package

Moved the Knowledge struct and related types to the shared package, updating all references across the codebase. This improves modularity and enables better reuse of the Knowledge type across different components.
This commit is contained in:
2025-05-03 22:09:02 -04:00
parent d2b9eb350e
commit 1c3ea7d1f1
11 changed files with 63 additions and 51 deletions

View File

@@ -4,12 +4,14 @@ import (
"context"
gollm "gitea.stevedudenhoeffer.com/steve/go-llm"
"gitea.stevedudenhoeffer.com/steve/answer/pkg/agents/shared"
)
// KnowledgeIntegrate will ask the LLM to combine the gained knowledge with the current knowledge, and return the new representation of overall.
// If source is not empty, then any new Knowledge will an empty source will be given the source.
// This will override objectives, notes, and remaining questions.
func (a Agent) KnowledgeIntegrate(ctx context.Context, base Knowledge, in ...Knowledge) (Knowledge, error) {
func (a Agent) KnowledgeIntegrate(ctx context.Context, base shared.Knowledge, in ...shared.Knowledge) (shared.Knowledge, error) {
// if there are no changes we can just return the knowledge
if len(in) == 0 {
return base, nil
@@ -29,7 +31,7 @@ func (a Agent) KnowledgeIntegrate(ctx context.Context, base Knowledge, in ...Kno
}
}
var incoming Knowledge
var incoming shared.Knowledge
for _, k := range in {
incoming.NotesToSelf = append(incoming.NotesToSelf, k.NotesToSelf...)
@@ -43,7 +45,7 @@ func (a Agent) KnowledgeIntegrate(ctx context.Context, base Knowledge, in ...Kno
baseMsg.Text = "The original knowledge is as follows: " + baseMsg.Text
incomingMsg.Text = "The new knowledge is as follows: " + incomingMsg.Text
var result = Knowledge{
var result = shared.Knowledge{
OriginalQuestions: base.OriginalQuestions,
Knowledge: append(base.Knowledge, incoming.Knowledge...),
}