Autonomous-AI / reasoning_agent.py
Leonydis137's picture
Upload reasoning_agent.py
0bce98a verified
raw
history blame
785 Bytes
from datetime import datetime
class ReasoningAgent:
def __init__(self):
self.logs = []
def think(self, context: str, goal: str) -> str:
thought = f"[{datetime.now()}] Reasoning: Based on context '{context}', the goal is '{goal}'."
plan = f"To achieve this, the AI should break down the task and search memory/tools for support."
self.logs.append(thought + "\n" + plan)
return plan
def reflect(self, result: str) -> str:
reflection = f"[{datetime.now()}] Reflection: After execution, result was: '{result}'"
feedback = "Was the outcome successful? What can be improved next time?"
self.logs.append(reflection + "\n" + feedback)
return feedback
def get_log(self):
return self.logs[-5:]