A programming framework for agentic AI
Move executor diag print to conversable_agent (#1867)
Jack Gerrits09a491892151
diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.pyindex 19f2a4c2a..aa2af05c6 100644--- a/autogen/agentchat/conversable_agent.py+++ b/autogen/agentchat/conversable_agent.py@@ -1271,6 +1271,25 @@ class ConversableAgent(LLMAgent):code_blocks = self._code_executor.code_extractor.extract_code_blocks(message["content"])if len(code_blocks) == 0:continue++ num_code_blocks = len(code_blocks)+ if num_code_blocks > 1:+ print(+ colored(+ f"\n>>>>>>>> EXECUTING CODE BLOCK (inferred language is {code_blocks[0].language})...",+ "red",+ ),+ flush=True,+ )+ else:+ print(+ colored(+ f"\n>>>>>>>> EXECUTING {num_code_blocks} CODE BLOCKS (inferred languages are [{', '.join([x.language for x in code_blocks])}])...",+ "red",+ ),+ flush=True,+ )+# found code blocks, execute code.code_result = self._code_executor.execute_code_blocks(code_blocks)exitcode2str = "execution succeeded" if code_result.exit_code == 0 else "execution failed"diff --git a/autogen/coding/local_commandline_code_executor.py b/autogen/coding/local_commandline_code_executor.pyindex 0ed4ce1ae..e63a4ed75 100644--- a/autogen/coding/local_commandline_code_executor.py+++ b/autogen/coding/local_commandline_code_executor.py@@ -5,13 +5,11 @@ import warningsfrom typing import Any, ClassVar, List, Optionalfrom pydantic import BaseModel, Field, field_validator-from autogen.agentchat.conversable_agent import coloredfrom ..agentchat.agent import LLMAgentfrom ..code_utils import execute_codefrom .base import CodeBlock, CodeExtractor, CodeResultfrom .markdown_code_extractor import MarkdownCodeExtractor-__all__ = ("LocalCommandlineCodeExecutor","CommandlineCodeResult",@@ -139,14 +137,6 @@ If you want the user to save the code in a file before executing it, put # filenlang, code = code_block.language, code_block.codeLocalCommandlineCodeExecutor.sanitize_command(lang, code)-- print(- colored(- f"\n>>>>>>>> EXECUTING CODE BLOCK {i} (inferred language is {lang})...",- "red",- ),- flush=True,- )filename_uuid = uuid.uuid4().hexfilename = Noneif lang in ["bash", "shell", "sh", "pwsh", "powershell", "ps1"]: