Skip to content

Commit

Permalink
Fixed newline SyntaxError (#136)
Browse files Browse the repository at this point in the history
* Update session.py

Resolves SyntaxError: unterminated string literal issue 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.

* Fixed newline SyntaxError

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 18, 2023
1 parent c3c91b4 commit 5d3b827
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions codeinterpreterapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def _tools(self, additional_tools: list[BaseTool]) -> list[BaseTool]:
description="Input a string of code to a ipython interpreter. "
"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 5d3b827

Please sign in to comment.