Spaces:
Sleeping
Sleeping
Update agentos_core.py
Browse files- agentos_core.py +16 -32
agentos_core.py
CHANGED
|
@@ -18,38 +18,22 @@ class AgentCore:
|
|
| 18 |
print(f"[INIT] Agent {self.agent_id} initialized with model {self.model}")
|
| 19 |
|
| 20 |
def run(self, prompt):
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
# Avoid duplicates
|
| 38 |
-
if text and text not in seen:
|
| 39 |
-
seen.add(text)
|
| 40 |
-
cleaned.append(text)
|
| 41 |
-
|
| 42 |
-
recall_text = " and ".join(cleaned)
|
| 43 |
-
response = f"You told me {recall_text}."
|
| 44 |
-
else:
|
| 45 |
-
response = f"Agent {self.agent_id} processed: {prompt}"
|
| 46 |
-
|
| 47 |
-
self.memory.save({"prompt": prompt, "response": response})
|
| 48 |
-
self.context.link_context(self.agent_id, prompt, response)
|
| 49 |
-
|
| 50 |
-
self.telemetry.log("run_complete", "success", {"response": response})
|
| 51 |
-
print(f"[RUN] {response}")
|
| 52 |
-
return response
|
| 53 |
|
| 54 |
except Exception as e:
|
| 55 |
self.telemetry.log("run_failed", "error", {"error": str(e)})
|
|
|
|
| 18 |
print(f"[INIT] Agent {self.agent_id} initialized with model {self.model}")
|
| 19 |
|
| 20 |
def run(self, prompt):
|
| 21 |
+
self.telemetry.log("run_start", "in_progress", {"prompt": prompt})
|
| 22 |
+
|
| 23 |
+
# 🔹 Summarization Trigger
|
| 24 |
+
if "summarize" in prompt.lower() or "what do you know" in prompt.lower() or "who am i" in prompt.lower():
|
| 25 |
+
summary = self.summarizer.summarize()
|
| 26 |
+
self.telemetry.log("run_complete", "success", {"response": summary})
|
| 27 |
+
print(f"[RUN] {summary}")
|
| 28 |
+
return summary
|
| 29 |
+
|
| 30 |
+
# 🔹 Normal processing flow
|
| 31 |
+
response = f"Agent {self.agent_id} processed: {prompt}"
|
| 32 |
+
self.memory.save({"prompt": prompt, "response": response})
|
| 33 |
+
self.context.link_context(self.agent_id, prompt, response)
|
| 34 |
+
self.telemetry.log("run_complete", "success", {"response": response})
|
| 35 |
+
print(f"[RUN] {response}")
|
| 36 |
+
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
except Exception as e:
|
| 39 |
self.telemetry.log("run_failed", "error", {"error": str(e)})
|