langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Add Other File Utilities

Open vowelparrot opened this issue 1 year ago • 7 comments

Add other File Utilities, include

  • List Directory
  • Search for file
  • Move
  • Copy
  • Remove file

Bundle as toolkit Add a notebook that connects to the Chat Agent, which somewhat supports multi-arg input tools Update original read/write files to return the original dir paths and better handle unsupported file paths. Add unit tests

Update Chat OutputParser to handle the case where the LLM outputs an action followed by a false "final answer" string - > strip the action first and run with that.

vowelparrot avatar Apr 20 '23 05:04 vowelparrot

This extremely cool!! Since you have thought so much about this already, do you think it's possible to make a tool which can edit files in a given region. Something like if the agent wants to modify a function, it shouldn't be rewriting the whole file, just the method. This way we can ask agents to do more complex things without running out of context windows.

rick2047 avatar Apr 20 '23 06:04 rick2047

This extremely cool!! Since you have thought so much about this already, do you think it's possible to make a tool which can edit files in a given region. Something like if the agent wants to modify a function, it shouldn't be rewriting the whole file, just the method. This way we can ask agents to do more complex things without running out of context windows.

That's a great question! I've hacked something to do this but am not sure the most general way at the moment. There are a number of AST parsers and codesearch tools we could use, but it needs to be validated.

vowelparrot avatar Apr 20 '23 14:04 vowelparrot

I have been looking into the AST approach. Do you think that should be a different tool? Like PythonCodeTool or something. I have some time to make this but am having trouble how to get started. Writing the functionality is simple but making a tool out of it is a bit tricky for me. Could use some guidance like how do I test this? Can't think of a minimal task.

rick2047 avatar Apr 21 '23 07:04 rick2047

Best thing I could find was the inspect module, but it only allows us to get information about code, not write it.

rick2047 avatar Apr 21 '23 18:04 rick2047

Wouldn't grep and sed work or something? Could just abstract the use of a bash script into a tool.

Ryangr0 avatar Apr 21 '23 19:04 Ryangr0

Wouldn't grep and sed work or something? Could just abstract the use of a bash script into a tool.

I was thinking about this, but I think the agent should have enough data about the file in the current system to figure out where to edit. Or am I putting too much faith in the model?

rick2047 avatar Apr 21 '23 20:04 rick2047

Yeah grep and sed are some of the next tools to implement

vowelparrot avatar Apr 22 '23 00:04 vowelparrot