Export Python code rather than json file

#21
by RobertoDonPedro - opened

Is it possible the generate a full python app from the instantiated components on the canvas, rather than just exporting a json file?

Langflow org

Yep. Use the top right code button.
image.png

No, that's not the python code you would write with native python and langchain...

IS there any solution for convering to native langchain python code from lanflow json?

Here is more info on this topic. This is largely taken from the langflow read.md

From langflow you build out a flow then, once you're done, you can export your flow as a JSON file to use with LangChain. To do so, click the "Export" button in the top right corner of the canvas, then in Python, you can load the flow with:

from langflow import load_flow_from_json

flow = load_flow_from_json("path/to/flow.json")
flow("Hey, have you heard of LangFlow?")

It looks like langchain treats the entire flow as a single chain

It would be very slick if langflow implemented a raw text python script output option. I can see many advantages when starting with langflow to quickly build out an overall app structure and then generalizing from there.
In the UI one fairly simple add on could be to add completed projects/flows to the chain selection menu. That way you could use a chain in later flows

Any updates on this?

I was also looking for how to export Python code from the flow, I didn't find an option to export everything together, but if you select each component there is a "code" option at the top left where you can see the code for the component:

image.png

image.png

But it seems to be mostly implemented using the langflow package, not only langchain.

Sign up or log in to comment