PYAE1994 commited on
Commit
43bd2be
·
verified ·
1 Parent(s): 3f3918a

Update app/agent/agent.py

Browse files
Files changed (1) hide show
  1. app/agent/agent.py +10 -9
app/agent/agent.py CHANGED
@@ -11,7 +11,7 @@ class Agent:
11
 
12
  def __init__(self):
13
  self.history = []
14
- self.executor = Executor()
15
 
16
  # ========================
17
  # LLM CALL LAYER
@@ -33,14 +33,12 @@ class Agent:
33
  return res.json()
34
 
35
  # ========================
36
- # STEP MODE (AUTONOMOUS GOAL EXECUTION)
37
  # ========================
38
  def run_goal(self, goal: str):
39
 
40
- # STEP 1: PLAN
41
  plan = create_plan(goal)
42
 
43
- # STEP 2: EXECUTE PLAN
44
  results = self.executor.run_plan(plan)
45
 
46
  return {
@@ -51,7 +49,7 @@ class Agent:
51
  }
52
 
53
  # ========================
54
- # TOOL MODE (DIRECT AGENT CALL)
55
  # ========================
56
  def run(self, user_input):
57
 
@@ -119,6 +117,12 @@ RULE:
119
 
120
  result = execute_tool_call(tool_call)
121
 
 
 
 
 
 
 
122
  self.history.append({
123
  "input": user_input,
124
  "tool_call": tool_call,
@@ -143,13 +147,10 @@ RULE:
143
 
144
 
145
  # ========================
146
- # DEBUG RUN
147
  # ========================
148
  if __name__ == "__main__":
149
  agent = Agent()
150
 
151
- # Example 1: normal tool call
152
  print(agent.run("List files in current directory"))
153
-
154
- # Example 2: autonomous goal mode
155
  print(agent.run_goal("Create a simple python web server"))
 
11
 
12
  def __init__(self):
13
  self.history = []
14
+ self.executor = Executor(llm=self.call_llm)
15
 
16
  # ========================
17
  # LLM CALL LAYER
 
33
  return res.json()
34
 
35
  # ========================
36
+ # GOAL MODE (AUTONOMOUS)
37
  # ========================
38
  def run_goal(self, goal: str):
39
 
 
40
  plan = create_plan(goal)
41
 
 
42
  results = self.executor.run_plan(plan)
43
 
44
  return {
 
49
  }
50
 
51
  # ========================
52
+ # TOOL MODE (DIRECT)
53
  # ========================
54
  def run(self, user_input):
55
 
 
117
 
118
  result = execute_tool_call(tool_call)
119
 
120
+ # self-healing (direct mode)
121
+ fix = self.executor.healer.heal(user_input, result)
122
+
123
+ if fix:
124
+ result = execute_tool_call(fix)
125
+
126
  self.history.append({
127
  "input": user_input,
128
  "tool_call": tool_call,
 
147
 
148
 
149
  # ========================
150
+ # DEBUG
151
  # ========================
152
  if __name__ == "__main__":
153
  agent = Agent()
154
 
 
155
  print(agent.run("List files in current directory"))
 
 
156
  print(agent.run_goal("Create a simple python web server"))