From 589b6fb0cf588cb018f39cf697a073f8843c1b74 Mon Sep 17 00:00:00 2001 From: "Jonathan C. McKinney" Date: Fri, 25 Oct 2024 17:25:04 -0700 Subject: [PATCH] If lang conflicts with filename, go with filename extension --- openai_server/autogen_utils.py | 5 +++++ src/version.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openai_server/autogen_utils.py b/openai_server/autogen_utils.py index a418ed2b2..534ae456d 100644 --- a/openai_server/autogen_utils.py +++ b/openai_server/autogen_utils.py @@ -294,6 +294,11 @@ def __execute_code_dont_check_setup(self, code_blocks: List[CodeBlock]) -> Comma try: # Check if there is a filename comment filename = self._get_file_name_from_content(code, self._work_dir) + # override lang if filename is detected, less error-prone than using code block lang + if filename.endswith('.sh'): + lang = 'shell' + elif filename.endswith('.py'): + lang = 'python' except ValueError: return CommandLineCodeResult(exit_code=1, output="Filename is not in the workspace") diff --git a/src/version.py b/src/version.py index 541ed3cee..4f0f57838 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -__version__ = "3bc2b6a8a14923f62dc7fa09ba3fc6fb044ccc05" +__version__ = "7463c2909debfb3b644bb7df27558f401779a095"