Leonydis137 commited on
Commit
4e2a605
·
verified ·
1 Parent(s): 339e4ab

Upload reflection_engine.py

Browse files
Files changed (1) hide show
  1. reflection_engine.py +28 -0
reflection_engine.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from typing import List, Dict
3
+
4
+ class ReflectionEngine:
5
+ def __init__(self):
6
+ self.feedback_log = []
7
+
8
+ def reflect_on_task(self, task_outputs: List[Dict]) -> str:
9
+ reflection = []
10
+ for output in task_outputs:
11
+ if "✅" in output.get("output", ""):
12
+ reflection.append(f"Success on '{output['task']}': Task completed as expected.")
13
+ else:
14
+ reflection.append(f"Issue with '{output['task']}': Requires attention.")
15
+ summary = "\n".join(reflection)
16
+ self.feedback_log.append(summary)
17
+ return summary
18
+
19
+ def suggest_improvements(self, instruction: str) -> List[str]:
20
+ # Simulated improvement suggestions
21
+ return [
22
+ f"Break down '{instruction}' into more specific components.",
23
+ f"Seek external sources for '{instruction}'.",
24
+ f"Use existing memory to compare with similar tasks."
25
+ ]
26
+
27
+ def get_feedback_log(self) -> List[str]:
28
+ return self.feedback_log