Skip to content

Commit

Permalink
Protection if filename is None
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudotensor committed Oct 31, 2024
1 parent 9f75616 commit c7b8c50
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions openai_server/autogen_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "81841bb63f95617d2c8f75ea5fbb7aaf447ef3b4"
__version__ = "9f75616a2abcf6a3870e56be2e2278109da19b3d"

0 comments on commit c7b8c50

Please sign in to comment.