FlowiseAI / Flowise

Drag & drop UI to build your customized LLM flow
https://flowiseai.com
Apache License 2.0
31.44k stars 16.36k forks source link

[FEATURE] Export to Python? #275

Open Microwave-WYB opened 1 year ago

Microwave-WYB commented 1 year ago

Describe the feature you'd like Is it possible to add the function to export to python code?

amandesai01 commented 1 year ago

Ideally it should be possible but not with this version. This is because Flowise doesn't generate source code under the hood. We can however freeze the state and create some kind of code generator. Not a simple/days task.

[EDIT] it is already freezing state as you can see it has marketplaces features. It is closely tied to UI however.

Microwave-WYB commented 1 year ago

Ideally it should be possible but not with this version. This is because Flowise doesn't generate source code under the hood. We can however freeze the state and create some kind of code generator. Not a simple/days task.

[EDIT] it is already freezing state as you can see it has marketplaces features. It is closely tied to UI however.

A bold idea (I don't even know how realistic it is), we can process the exported json somehow, remove the redundant information, only keep the component name, input, and output, create a vectorstore for langchain documentations, and let AI write the python code lol.

HenryHengZJ commented 1 year ago

we have some prototype - https://github.com/FlowiseAI/Flowise/blob/feature/Export-Code/packages/components/nodes/embeddings/OpenAIEmbedding/OpenAIEmbedding.ts

but exporting code will means that for each node in Flowise, we have to write the exported code and this adds another dependency to the project. Definitely we love to have that feature when we have more resources to do so

amandesai01 commented 1 year ago

We can write a standalone package that does it. I think it will be a bad idea to write template literals directly into class of component. We can basically have a "codegen" package which extends class of every node with code generation capabitlites. This will enable code generation in python as well as javascript.

HenryHengZJ commented 1 year ago

yea I agree code-gen package like graphql-codegen is the way to go for long term, not sure how easy/hard it is to implement that.

writing template literals was the shortcut that get us there quickly, but not viable as we have more integrations especially from other libraries

KuphJr commented 1 year ago

I have a use case which requires allowing users to build flows via the Flowise UI, then export the resulting flow to JavaScript code such that it can be executed without the UI locally on the user's machine (or in their browser so they don't even have to install Node.js).

I am willing to assist with adding a feature like this, but could use some guidance with where to start. Please reach out!

amandesai01 commented 1 year ago

I think this can be very very easily implemented as far as you just want to execute code. Because server does exactly same thing, gets exported graph, traverses and executes.

See: https://github.com/FlowiseAI/Flowise/blob/c881a109a79fb9fff86dfb7c3bad7eacd33d69e8/packages/server/src/index.ts#L768

KuphJr commented 1 year ago

@amandesai01 I'll take a look! I just found this project a couple days ago, so I haven't had much time to dive into the code, but if I create a useful feature I will be sure to open a PR!

fire17 commented 1 year ago

Very interested in exporting directly to python. It will be be lovely to build the chains using floweise, and exporting out a ready to deploy langchain python code

Any updates @HenryHengZJ Thanks a lot and all the best !

AngryAnt commented 1 year ago

Very interested in exporting directly to python. It will be be lovely to build the chains using floweise, and exporting out a ready to deploy langchain python code

Any updates @HenryHengZJ Thanks a lot and all the best !

This use case was honestly our primary reason for trying out Flowise - specifically going by the language that langchainJS and langchainPY have "uses the same serialisation format" as a called out feature.

It seemed a reasonable leap at the time that Flowise would be able to save a serialised flow which langchainPY could then load and run.

fire17 commented 1 year ago

@AngryAnt that would be really cool, maybe even ideal - a serialized chain that can just run on any langchain enabled environment.

But honestly even an exported build instructions for the chain will suffice. I see FlowWise as a really nice almost Declarative way to build chains. From the graph I could see -> export graph -> chain build instructions And this graph file should be either loadable from langchainPY as a declarative chain config. Or do a "build" step and convert/scaffold to imperitive python code, which will be allow classic manual editting (for those who wish to go beyond the No-Code solution)

nthomsencph commented 3 months ago

Hi, any progress on this? We have 10+ projects where this would be ideal. Is it possible to put a bounty on this feature to move it forward? @HenryHengZJ

alew3 commented 2 months ago

this would be a very useful feature, to be able to export to JS or Python.

xAlpharax commented 2 months ago

I second this, it would be really cool and reliable.

Zia-Ch commented 3 weeks ago

Any progress on this? This will take the no code AI development to a whole new level.

xAlpharax commented 3 weeks ago

Any progress on this? This will take the no code AI development to a whole new level.

It s just weird to get right, however I'm going to look into it as well.