langchain_community.tools.e2b_data_analysis.tool.add_last_line_print¶
langchain_community.tools.e2b_data_analysis.tool.add_last_line_print(code: str) → str[source]¶
Add print statement to the last line if it’s missing.
Sometimes, the LLM-generated code doesn’t have print(variable_name), instead theLLM tries to print the variable only by writing variable_name (as you would in
REPL, for example).
This methods checks the AST of the generated Python code and adds the printstatement to the last line if it’s missing.