-
Notifications
You must be signed in to change notification settings - Fork 16k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved query, print & exception handling in REPL Tool #3215
Conversation
The following improvements are made to the Python REPL Tool: 1) Improved the sanitization of query (using regex), by removing python command (since gpt-3.5-turbo sometimes assumes python console as a terminal, and runs python command first which causes error). Also sometimes 1 line python codes contain single backticks. (i) Eg of python in query: > Entering new LLMMathChain chain... 1291.25 * 6 ```python print(1291.25 * 6) ``` (ii) Eg of 1 line query with single backtick: Thought:I have the number of unique Account IDs, but I need to count the number of active accounts Action: python_repl_ast Action Input: `len(df[df['Status'] == 'Active'])` 2) Improved the capturing of print by redirecting stdout to output of Python REPL Tool (without cluttering the actual stdout). 3) Made sure the exception format type is returned in all cases, when the exec() function throws an exception.
Updated formatting by running the "poetry run black ." command.
I corrected the lint formatting by running the "poetry run black ." command and created a new commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be great to add some test cases
@hwchase17 I have added 7 new test cases as you asked. I have also rerun the lining commands one by one and fixed the formatting issues. This is my first time adding test cases, so it took a while. If any linting issues persist (none were detected when run locally by me), I request you to fix it if possible. |
@hwchase17, is there anything blocking this merge? |
Update to pull request #3215 Summary: 1) Improved the sanitization of query (using regex), by removing python command (since gpt-3.5-turbo sometimes assumes python console as a terminal, and runs python command first which causes error). Also sometimes 1 line python codes contain single backticks. 2) Added 7 new test cases. For more details, view the previous pull request. --------- Co-authored-by: Deepak S V <svdeepak99@users.noreply.github.com>
Reopened this PR & merged in #4997 |
The following improvements are made to the Python REPL Tool:
(i) Eg of python in query:
(ii) Eg of 1 line query with single backtick:
Thought: I have the number of unique Account IDs, but I need to count the number of active accounts Action: python_repl_ast
Action Input:
`len(df[df['Status'] == 'Active'])`
Improved the capturing of print by redirecting stdout to output of Python REPL Tool (without cluttering the actual stdout). Also when the return of eval() function is None, then returning stdout (in case code contains a print or info statement).
Made sure the exception format type is returned in all cases, when the exec() function throws an exception.