Spaces:
Sleeping
Sleeping
Update agentos_core.py
Browse files- agentos_core.py +13 -7
agentos_core.py
CHANGED
|
@@ -18,26 +18,32 @@ class AgentCore:
|
|
| 18 |
self.telemetry.log("run_start", "in_progress", {"prompt": prompt})
|
| 19 |
|
| 20 |
try:
|
| 21 |
-
# 1️⃣ Search for all stored 'favorite' context
|
| 22 |
recall_items = self.context.query_context(self.agent_id, "favorite")
|
| 23 |
|
| 24 |
-
# 2️⃣ Decide response type
|
| 25 |
if recall_items and not prompt.lower().startswith("my "):
|
| 26 |
-
# Clean and humanize recall
|
| 27 |
cleaned = []
|
|
|
|
| 28 |
for item in recall_items:
|
| 29 |
-
text =
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
recall_text = " and ".join(cleaned)
|
| 32 |
response = f"You told me {recall_text}."
|
| 33 |
else:
|
| 34 |
response = f"Agent {self.agent_id} processed: {prompt}"
|
| 35 |
|
| 36 |
-
# 3️⃣ Save new info to memory + link to graph
|
| 37 |
self.memory.save({"prompt": prompt, "response": response})
|
| 38 |
self.context.link_context(self.agent_id, prompt, response)
|
| 39 |
|
| 40 |
-
# 4️⃣ Log complete
|
| 41 |
self.telemetry.log("run_complete", "success", {"response": response})
|
| 42 |
print(f"[RUN] {response}")
|
| 43 |
return response
|
|
|
|
| 18 |
self.telemetry.log("run_start", "in_progress", {"prompt": prompt})
|
| 19 |
|
| 20 |
try:
|
|
|
|
| 21 |
recall_items = self.context.query_context(self.agent_id, "favorite")
|
| 22 |
|
|
|
|
| 23 |
if recall_items and not prompt.lower().startswith("my "):
|
|
|
|
| 24 |
cleaned = []
|
| 25 |
+
seen = set()
|
| 26 |
for item in recall_items:
|
| 27 |
+
text = (
|
| 28 |
+
item.replace("Agent", "")
|
| 29 |
+
.replace("processed:", "")
|
| 30 |
+
.replace(self.agent_id, "")
|
| 31 |
+
.replace(".", "")
|
| 32 |
+
.strip()
|
| 33 |
+
)
|
| 34 |
+
# Avoid duplicates
|
| 35 |
+
if text and text not in seen:
|
| 36 |
+
seen.add(text)
|
| 37 |
+
cleaned.append(text)
|
| 38 |
+
|
| 39 |
recall_text = " and ".join(cleaned)
|
| 40 |
response = f"You told me {recall_text}."
|
| 41 |
else:
|
| 42 |
response = f"Agent {self.agent_id} processed: {prompt}"
|
| 43 |
|
|
|
|
| 44 |
self.memory.save({"prompt": prompt, "response": response})
|
| 45 |
self.context.link_context(self.agent_id, prompt, response)
|
| 46 |
|
|
|
|
| 47 |
self.telemetry.log("run_complete", "success", {"response": response})
|
| 48 |
print(f"[RUN] {response}")
|
| 49 |
return response
|