Spaces:
Sleeping
Sleeping
Update context_graph.py
Browse files- context_graph.py +13 -1
context_graph.py
CHANGED
|
@@ -39,7 +39,19 @@ class ContextGraph:
|
|
| 39 |
]
|
| 40 |
|
| 41 |
return results if results else ["No matching context found."]
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# Simple alias to maintain backward compatibility with AgentCore
|
| 44 |
with open(self.file_path, "r") as f:
|
| 45 |
graph = json.load(f)
|
|
|
|
| 39 |
]
|
| 40 |
|
| 41 |
return results if results else ["No matching context found."]
|
| 42 |
+
def query_context(self, agent_id, keyword):
|
| 43 |
+
# Search for any stored memory entries that contain the keyword
|
| 44 |
+
with open(self.file_path, "r") as f:
|
| 45 |
+
graph = json.load(f)
|
| 46 |
+
|
| 47 |
+
agent_data = graph["context_links"].get(agent_id, {})
|
| 48 |
+
results = [
|
| 49 |
+
f"{k}: {v}" for k, v in agent_data.items()
|
| 50 |
+
if keyword.lower() in k.lower() or keyword.lower() in v.lower()
|
| 51 |
+
]
|
| 52 |
+
return results if results else ["No matching context found."]
|
| 53 |
+
|
| 54 |
+
def get_context(self, agent_id):
|
| 55 |
# Simple alias to maintain backward compatibility with AgentCore
|
| 56 |
with open(self.file_path, "r") as f:
|
| 57 |
graph = json.load(f)
|