From c7b8c50019bfb0d9e67ea8ff663e2bf2a367391f Mon Sep 17 00:00:00 2001 From: "Jonathan C. McKinney" Date: Thu, 31 Oct 2024 08:32:58 -0700 Subject: [PATCH] Protection if filename is None --- openai_server/autogen_utils.py | 7 ++++--- src/version.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openai_server/autogen_utils.py b/openai_server/autogen_utils.py index bb17d4741..9d8776cb5 100644 --- a/openai_server/autogen_utils.py +++ b/openai_server/autogen_utils.py @@ -286,7 +286,8 @@ def __execute_code_dont_check_setup(self, code_blocks: List[CodeBlock]) -> Comma filename = self._get_file_name_from_content(code, self._work_dir) # override filename and lang if tool use is detected cwd = os.path.abspath(os.getcwd()) - if code_block.execute and \ + if filename and \ + code_block.execute and \ f'python {cwd}/openai_server/agent_tools/' in code and \ filename.endswith('.py'): # switch back to shell if was wrongly .py extension @@ -295,9 +296,9 @@ def __execute_code_dont_check_setup(self, code_blocks: List[CodeBlock]) -> Comma shutil.move(filename, new_filename) filename = new_filename # override lang if filename is detected, less error-prone than using code block lang - elif filename.endswith('.sh'): + elif filename and filename.endswith('.sh'): code_block.language = lang = 'shell' - elif filename.endswith('.py'): + elif filename and filename.endswith('.py'): code_block.language = 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 08364988b..9225ab060 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -__version__ = "81841bb63f95617d2c8f75ea5fbb7aaf447ef3b4" +__version__ = "9f75616a2abcf6a3870e56be2e2278109da19b3d"