Skip to content

Commit

Permalink
Fixed newline SyntaxError
Browse files Browse the repository at this point in the history
Added some prompting to the python tool to resolve SyntaxError: unterminated string literal where multi-line code strings are not processed correctly if they're not formatted in compliance with Python's string literal rules. Specifically, the interpreter fails when the code string starts with a newline right after the opening quote or doesn't use triple quotes for multi-line code snippets. This leads to an unended string literal error because the interpreter expects a complete string format as per Python syntax rules.
  • Loading branch information
erickfm authored Oct 17, 2023
1 parent fd92b0c commit 1c01adc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions codeinterpreterapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def _tools(self, additional_tools: list[BaseTool]) -> list[BaseTool]:
"Write the entire code in a single string. This string can "
"be really long, so you can use the `;` character to split lines. "
"Start your code on the same line as the opening quote. "
"Do not start your code with a line break. "
"For example, do 'import numpy', not '\\nimport numpy'."
"Variables are preserved between runs. "
+ (
(
Expand Down

0 comments on commit 1c01adc

Please sign in to comment.