Perfect version.

This commit is contained in:
2025-11-04 07:52:36 +01:00
parent 685766ef86
commit 2b701cb5cd
14 changed files with 1956 additions and 7 deletions
+9
View File
@@ -5,6 +5,7 @@ from typing import Dict, List, Any, Optional, Callable
from dataclasses import dataclass, field
from .agent_roles import AgentRole, get_agent_role
from .agent_communication import AgentMessage, AgentCommunicationBus, MessageType
from ..memory.knowledge_store import KnowledgeStore
@dataclass
class AgentInstance:
@@ -36,6 +37,7 @@ class AgentManager:
self.db_path = db_path
self.api_caller = api_caller
self.communication_bus = AgentCommunicationBus(db_path)
self.knowledge_store = KnowledgeStore(db_path)
self.active_agents: Dict[str, AgentInstance] = {}
self.session_id = str(uuid.uuid4())[:16]
@@ -70,9 +72,16 @@ class AgentManager:
agent.context.update(context)
agent.add_message('user', task)
knowledge_matches = self.knowledge_store.search_entries(task, top_k=3)
agent.task_count += 1
messages = agent.get_messages_for_api()
if knowledge_matches:
knowledge_content = "Knowledge base matches based on your query:\\n"
for i, entry in enumerate(knowledge_matches, 1):
shortened_content = entry.content[:2000]
knowledge_content += f"{i}. {shortened_content}\\n\\n"
messages.insert(-1, {'role': 'user', 'content': knowledge_content})
try:
response = self.api_caller(