Spaces:
Sleeping
Sleeping
Commit ·
3a6cdfe
1
Parent(s): e4bef7f
fix: move ConversationAgent after BaseAgent definition
Browse filesCo-authored-by: aider (openai/editor-model) <aider@aider.chat>
app.py
CHANGED
|
@@ -2565,7 +2565,7 @@ class AgentReputationEngine:
|
|
| 2565 |
return rep
|
| 2566 |
|
| 2567 |
|
| 2568 |
-
# --- V2 PHASE 4
|
| 2569 |
class NotificationEngine:
|
| 2570 |
"""Central notification center managing persisted system alerts and WS events."""
|
| 2571 |
|
|
@@ -2580,34 +2580,6 @@ class NotificationEngine:
|
|
| 2580 |
return notif
|
| 2581 |
|
| 2582 |
|
| 2583 |
-
class ConversationAgent(BaseAgent):
|
| 2584 |
-
"""Dedicated Conversation Agent for human interaction, clarification, failure reporting, and approvals."""
|
| 2585 |
-
|
| 2586 |
-
def __init__(self, db: DatabaseManager, message_bus: MessageBus, event_bus: EventBus, model_manager: ModelManager):
|
| 2587 |
-
super().__init__("agent-conversation-01", "Mnemosyne Chat", "Human Interface & Conversation Specialist", db, message_bus, event_bus)
|
| 2588 |
-
self.model_manager = model_manager
|
| 2589 |
-
|
| 2590 |
-
async def process_user_message(self, user_message: str, user_id: str = "human-operator") -> str:
|
| 2591 |
-
# Record user message in conversation history
|
| 2592 |
-
user_log = ConversationMessageModel(user_id=user_id, sender="Human Operator", message=user_message)
|
| 2593 |
-
await self.db.save_conversation_log(user_log)
|
| 2594 |
-
|
| 2595 |
-
# Context lookup from memory vault
|
| 2596 |
-
memories = await self.db.search_memories(user_message)
|
| 2597 |
-
ctx_str = "\n".join([m["content"] for m in memories[:3]]) if memories else "No direct memory match."
|
| 2598 |
-
|
| 2599 |
-
prompt = f"User said: '{user_message}'\nRelevant Memory Context:\n{ctx_str}\nProvide a helpful, polite, and strategic response as Spark Colony OS Operator Assistant."
|
| 2600 |
-
resp = await self.model_manager.generate_response(LogicalModel.MDL_FST, prompt)
|
| 2601 |
-
reply_text = resp["content"]
|
| 2602 |
-
|
| 2603 |
-
# Record agent reply
|
| 2604 |
-
agent_log = ConversationMessageModel(user_id=user_id, sender=self.name, message=reply_text)
|
| 2605 |
-
await self.db.save_conversation_log(agent_log)
|
| 2606 |
-
await self.record_memory("system", f"Human Chat Interaction: {user_message} -> {reply_text}", ["conversation", "human_interaction"])
|
| 2607 |
-
|
| 2608 |
-
return reply_text
|
| 2609 |
-
|
| 2610 |
-
|
| 2611 |
# --- CONFIDENCE ENGINE & COST TRACKER ---
|
| 2612 |
class ConfidenceEngine:
|
| 2613 |
"""Calculates objective confidence metrics based on evidence attributes."""
|
|
@@ -3078,6 +3050,34 @@ class DynamicWorkerAgent(BaseAgent):
|
|
| 3078 |
return res
|
| 3079 |
|
| 3080 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3081 |
# --- SPECIALIZED COLONY AGENTS ---
|
| 3082 |
class CommanderAgent(BaseAgent):
|
| 3083 |
"""Commander Agent: Manages workflow, assigns tasks, measures confidence. NEVER searches, browses, or writes reports."""
|
|
|
|
| 2565 |
return rep
|
| 2566 |
|
| 2567 |
|
| 2568 |
+
# --- V2 PHASE 4 NOTIFICATION ENGINE ---
|
| 2569 |
class NotificationEngine:
|
| 2570 |
"""Central notification center managing persisted system alerts and WS events."""
|
| 2571 |
|
|
|
|
| 2580 |
return notif
|
| 2581 |
|
| 2582 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2583 |
# --- CONFIDENCE ENGINE & COST TRACKER ---
|
| 2584 |
class ConfidenceEngine:
|
| 2585 |
"""Calculates objective confidence metrics based on evidence attributes."""
|
|
|
|
| 3050 |
return res
|
| 3051 |
|
| 3052 |
|
| 3053 |
+
class ConversationAgent(BaseAgent):
|
| 3054 |
+
"""Dedicated Conversation Agent for human interaction, clarification, failure reporting, and approvals."""
|
| 3055 |
+
|
| 3056 |
+
def __init__(self, db: DatabaseManager, message_bus: MessageBus, event_bus: EventBus, model_manager: ModelManager):
|
| 3057 |
+
super().__init__("agent-conversation-01", "Mnemosyne Chat", "Human Interface & Conversation Specialist", db, message_bus, event_bus)
|
| 3058 |
+
self.model_manager = model_manager
|
| 3059 |
+
|
| 3060 |
+
async def process_user_message(self, user_message: str, user_id: str = "human-operator") -> str:
|
| 3061 |
+
# Record user message in conversation history
|
| 3062 |
+
user_log = ConversationMessageModel(user_id=user_id, sender="Human Operator", message=user_message)
|
| 3063 |
+
await self.db.save_conversation_log(user_log)
|
| 3064 |
+
|
| 3065 |
+
# Context lookup from memory vault
|
| 3066 |
+
memories = await self.db.search_memories(user_message)
|
| 3067 |
+
ctx_str = "\n".join([m["content"] for m in memories[:3]]) if memories else "No direct memory match."
|
| 3068 |
+
|
| 3069 |
+
prompt = f"User said: '{user_message}'\nRelevant Memory Context:\n{ctx_str}\nProvide a helpful, polite, and strategic response as Spark Colony OS Operator Assistant."
|
| 3070 |
+
resp = await self.model_manager.generate_response(LogicalModel.MDL_FST, prompt)
|
| 3071 |
+
reply_text = resp["content"]
|
| 3072 |
+
|
| 3073 |
+
# Record agent reply
|
| 3074 |
+
agent_log = ConversationMessageModel(user_id=user_id, sender=self.name, message=reply_text)
|
| 3075 |
+
await self.db.save_conversation_log(agent_log)
|
| 3076 |
+
await self.record_memory("system", f"Human Chat Interaction: {user_message} -> {reply_text}", ["conversation", "human_interaction"])
|
| 3077 |
+
|
| 3078 |
+
return reply_text
|
| 3079 |
+
|
| 3080 |
+
|
| 3081 |
# --- SPECIALIZED COLONY AGENTS ---
|
| 3082 |
class CommanderAgent(BaseAgent):
|
| 3083 |
"""Commander Agent: Manages workflow, assigns tasks, measures confidence. NEVER searches, browses, or writes reports."""
|