fix : was showing code after execution

This commit is contained in:
martin legrand 2025-04-25 21:54:36 +02:00
parent f09cb8a7b5
commit 45700d77ab
3 changed files with 13 additions and 5 deletions

View File

@ -213,6 +213,14 @@ class Agent():
post_lines.append(f"block:{block_idx}") post_lines.append(f"block:{block_idx}")
block_idx += 1 block_idx += 1
return "\n".join(post_lines) return "\n".join(post_lines)
def show_block(self, block: str) -> None:
"""
Show the block in a pretty way.
"""
pretty_print(''*64, color="status")
pretty_print(block, color="code")
pretty_print(''*64, color="status")
def execute_modules(self, answer: str) -> Tuple[bool, str]: def execute_modules(self, answer: str) -> Tuple[bool, str]:
""" """
@ -231,6 +239,7 @@ class Agent():
if blocks != None: if blocks != None:
for block in blocks: for block in blocks:
self.show_block(block)
output = tool.execute([block]) output = tool.execute([block])
feedback = tool.interpreter_feedback(output) # tool interpreter feedback feedback = tool.interpreter_feedback(output) # tool interpreter feedback
success = not tool.execution_failure_check(output) success = not tool.execution_failure_check(output)

View File

@ -56,6 +56,7 @@ class CoderAgent(Agent):
self.last_answer = answer self.last_answer = answer
await asyncio.sleep(0) await asyncio.sleep(0)
break break
self.show_answer()
animate_thinking("Executing code...", color="status") animate_thinking("Executing code...", color="status")
self.status_message = "Executing code..." self.status_message = "Executing code..."
exec_success, _ = self.execute_modules(answer) exec_success, _ = self.execute_modules(answer)
@ -67,7 +68,6 @@ class CoderAgent(Agent):
pretty_print("Execution failure", color="failure") pretty_print("Execution failure", color="failure")
pretty_print("Correcting code...", color="status") pretty_print("Correcting code...", color="status")
self.status_message = "Correcting code..." self.status_message = "Correcting code..."
self.show_answer()
attempt += 1 attempt += 1
self.status_message = "Ready" self.status_message = "Ready"
if attempt == max_attempts: if attempt == max_attempts:

View File

@ -68,9 +68,8 @@ class executorResult:
"success": self.success, "success": self.success,
"tool_type": self.tool_type "tool_type": self.tool_type
} }
def show(self): def show(self):
pretty_print(''*64, color="status") pretty_print(''*64, color="status")
pretty_print(self.block, color="code" if self.success else "failure") pretty_print(self.feedback, color="success" if self.success else "failure")
pretty_print(''*64, color="status") pretty_print(''*64, color="status")
pretty_print(self.feedback, color="success" if self.success else "failure")