diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.py index 204e57ab6890..454cedfe49e7 100644 --- a/autogen/agentchat/conversable_agent.py +++ b/autogen/agentchat/conversable_agent.py @@ -18,6 +18,7 @@ from ..cache.cache import AbstractCache from ..code_utils import ( UNKNOWN, + PYTHON_VARIANTS, check_can_use_docker_or_throw, content_str, decide_use_docker, @@ -2079,7 +2080,7 @@ def execute_code_blocks(self, code_blocks): ) if lang in ["bash", "shell", "sh"]: exitcode, logs, image = self.run_code(code, lang=lang, **self._code_execution_config) - elif lang in ["python", "Python", "py"]: + elif lang in PYTHON_VARIANTS: if code.startswith("# filename: "): filename = code[11 : code.find("\n")].strip() else: diff --git a/autogen/code_utils.py b/autogen/code_utils.py index 71b91d2165a6..f1f0dbd247a2 100644 --- a/autogen/code_utils.py +++ b/autogen/code_utils.py @@ -35,6 +35,7 @@ DEFAULT_TIMEOUT = 600 WIN32 = sys.platform == "win32" PATH_SEPARATOR = WIN32 and "\\" or "/" +PYTHON_VARIANTS = ["python", "Python", "py"] logger = logging.getLogger(__name__)