Spaces:
Sleeping

Tpayne101 commited on
Commit
0860d2c
·
verified ·
1 Parent(s): a7f973b

Update context_graph.py

Browse files
Files changed (1) hide show
  1. 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
- def get_context(self, agent_id):
 
 
 
 
 
 
 
 
 
 
 
 
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)