langchain-ai / langchain

šŸ¦œšŸ”— Build context-aware reasoning applications
https://python.langchain.com
MIT License
93.05k stars 14.96k forks source link

Langchain FilemanagementToolkit incorrectly writes python code to files #20721

Closed Eklavya17 closed 2 months ago

Eklavya17 commented 5 months ago

Checked other resources

Example Code

file_management = FileManagementToolkit(

If you don't provide a root_dir, operations will default to the current working directory

root_dir=root_dir

).get_tools()

using this tool to write data to a python file writes the data as a string and the \n is interpreted as a character not as \n itself and the rest of the code is not moved to the new line

Error Message and Stack Trace (if applicable)

No response

Description

Trying to use the filemanagementtoolkit to write python code in a new line but it fails in correctly doing so as it should

System Info

windows, python -11.4

qingdengyue commented 5 months ago

python -11.4 ā“

Eklavya17 commented 5 months ago

Yeah that is the version on the venv I'm using

qingdengyue commented 5 months ago

can you provide you venv comand or provide mini reproduce repos. iā€˜ not familiar with venv,i use a conda environment locally

Eklavya17 commented 5 months ago

The venv isn't the problem the issue is that the toolkit is not correctly writing the files even without the venv

qingdengyue commented 5 months ago

just want to have a try. šŸ˜„ in linux. i find the \n is worked. open the file that is a new line.if read file using 'read_tool',yes.it is a '\n' character in the string.i think this is normal.