Spaces:
Sleeping
Sleeping
Update agentos_core.py
Browse files- agentos_core.py +36 -21
agentos_core.py
CHANGED
|
@@ -1,28 +1,43 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
try:
|
| 6 |
-
# Create a dummy response for now
|
| 7 |
-
response = f"Agent {self.agent_id} processed: {prompt}"
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
response = f"You told me earlier: {val}"
|
| 19 |
-
break
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json, os, time
|
| 2 |
+
from memory_core import MemoryManager
|
| 3 |
+
from context_graph import ContextGraph
|
| 4 |
+
from telemetry import Telemetry
|
| 5 |
+
from identity_core import create_agent_identity
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
class AgentCore:
|
| 9 |
+
def __init__(self, model="gpt-4o-mini"):
|
| 10 |
+
self.agent_id = create_agent_identity()
|
| 11 |
+
self.memory = MemoryManager(self.agent_id)
|
| 12 |
+
self.context = ContextGraph()
|
| 13 |
+
self.telemetry = Telemetry(self.agent_id)
|
| 14 |
+
self.model = model
|
| 15 |
|
| 16 |
+
def run(self, prompt):
|
| 17 |
+
# Log start
|
| 18 |
+
self.telemetry.log("run_start", "in_progress", {"prompt": prompt})
|
| 19 |
|
| 20 |
+
try:
|
| 21 |
+
# Create a dummy response for now
|
| 22 |
+
response = f"Agent {self.agent_id} processed: {prompt}"
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
# Save to memory
|
| 25 |
+
self.memory.save({"prompt": prompt, "response": response})
|
| 26 |
|
| 27 |
+
# Retrieve past context for this agent
|
| 28 |
+
previous_context = self.context.get_context(self.agent_id)
|
| 29 |
|
| 30 |
+
# Check for matches in past context
|
| 31 |
+
for key, val in previous_context.items():
|
| 32 |
+
if key.lower() in prompt.lower():
|
| 33 |
+
response = f"You told me earlier: {val}"
|
| 34 |
+
break
|
| 35 |
+
|
| 36 |
+
# Log completion
|
| 37 |
+
self.telemetry.log("run_complete", "success", {"response": response})
|
| 38 |
+
|
| 39 |
+
return response
|
| 40 |
+
|
| 41 |
+
except Exception as e:
|
| 42 |
+
self.telemetry.log("run_failed", "error", {"error": str(e)})
|
| 43 |
+
raise e
|