Hello, how can I pass json data to a python file from an n8n node? In order to run Langchain over it and deliver the finished output back to the n8n node.
The implemented agents look great in animations, but unfortunately in practice they are still very buggy. For example, the known and unfixed bug with the outparser error. Or missing options to adjust vector dimensions in Qdrant Retriever. Also that stream=true cannot be used… This is all just a waste of time and that’s why I would like to just run langchain in python. But how do I get a connection to n8n?
No imports from … are allowed in the Python code node. As n8n does use Pyodide underneath the hood, which does not support the request module. You can’t load a Python function and pass Json data directly to it.
Actually, the only way left is to use the command line with the node execute command:
Welcome to the community @eyeffect
Thanks for all your feedback around how we can improve our Langchain integration and code node functionalities. Could you maybe add links to relevant feature requests and forum posts, it would be helpful for us to know which issues you’re referring to.
Regarding your question on how to pass json data in your execute command node, you can use the stringify method like so:
{{ JSON.stringify($json.data) }}`
I tested out the following workflow with a simple python script that prints out the first argument in the shell command which seems to work for me.