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 the

LLM 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 print

statement to the last line if it’s missing.