Ordinath / tool_juggler

MIT License
42 stars 0 forks source link

JSON file writer tool - problems #40

Open adamengberg opened 1 year ago

adamengberg commented 1 year ago

Hi, Im trying to create a JSON file writer tool. When loading the tool i get this error in the terminal: "POST /conversations/f6f31c5c-c789-4f0d-998b-8dc662095801/get_ai_completion HTTP/1.1" 500.

And I need to restart the whole thing to get things running again. I tried enabling Debug mode by changing the app.py but does not seem to successfully put it in debug mode to get more error messages.

I´ve made several other tools but they all lead to the same error, is there anything obvious I´ve missed here? Im a novice at programming so excuse any stupid mistakes!

These are my files:

requirements.txt json

manifest.json { "name": "json_writer", "version": "0.1", "tool_type": "common", "tool_definition": "json_writer.py", "requirements": "requirements.txt", "vectorstore_init": null, "prep_script": null, "env_vars": [] }

json_writer.py ` import json from langchain.agents import Tool

def write_to_json(data, file_path='output.json'): with open(file_path, 'w') as f: json.dump(data, f)

def get_tool(app): return Tool( name="JSONWriter", func=write_to_json, description="This tool writes data to a JSON file.", args={ "data": "The data to be written to the JSON file.", "file_path": "The path of the JSON file to write the data to. Defaults to 'output.json'." } )

`

Ordinath commented 1 year ago

Hello @adamengberg! This is an interesting use case and we can look closer into this to get this included in the tool_examples afterward! In the meantime here is an issue in langchain library that might help you.