Tpayne101 commited on
Commit
a155411
·
verified ·
1 Parent(s): 1eadbff

Update context_graph.py

Browse files
Files changed (1) hide show
  1. context_graph.py +2 -12
context_graph.py CHANGED
@@ -25,6 +25,7 @@ class ContextGraph:
25
  # Save the updated graph
26
  with open(self.file_path, "w") as f:
27
  json.dump(graph, f, indent=2)
 
28
  os.sync() # Force Hugging Face to write to disk
29
 
30
  def query_context(self, agent_id, keyword):
@@ -38,21 +39,10 @@ class ContextGraph:
38
  if keyword.lower() in k.lower() or keyword.lower() in v.lower()
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)
58
- return graph["context_links"].get(agent_id, {}) {})
 
25
  # Save the updated graph
26
  with open(self.file_path, "w") as f:
27
  json.dump(graph, f, indent=2)
28
+
29
  os.sync() # Force Hugging Face to write to disk
30
 
31
  def query_context(self, agent_id, keyword):
 
39
  if keyword.lower() in k.lower() or keyword.lower() in v.lower()
40
  ]
41
 
 
 
 
 
 
 
 
 
 
 
 
42
  return results if results else ["No matching context found."]
43
 
44
  def get_context(self, agent_id):
45
  # Simple alias to maintain backward compatibility with AgentCore
46
  with open(self.file_path, "r") as f:
47
  graph = json.load(f)
48
+ return graph["context_links"].get(agent_id, {})