Skip to content

Commit

Permalink
If lang conflicts with filename, go with filename extension
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudotensor committed Oct 26, 2024
1 parent 7463c29 commit 589b6fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions openai_server/autogen_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3bc2b6a8a14923f62dc7fa09ba3fc6fb044ccc05"
__version__ = "7463c2909debfb3b644bb7df27558f401779a095"

0 comments on commit 589b6fb

Please sign in to comment.