Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Export to Python? #275

Open
Microwave-WYB opened this issue Jun 9, 2023 · 16 comments
Open

[FEATURE] Export to Python? #275

Microwave-WYB opened this issue Jun 9, 2023 · 16 comments
Labels
enhancement New feature or request

Comments

@Microwave-WYB
Copy link

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

@amandesai01
Copy link

amandesai01 commented Jun 9, 2023

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
Copy link
Author

Microwave-WYB commented Jun 9, 2023

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
Copy link
Contributor

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
Copy link

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
Copy link
Contributor

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

@HenryHengZJ HenryHengZJ added the enhancement New feature or request label Jun 10, 2023
@KuphJr
Copy link

KuphJr commented Aug 6, 2023

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
Copy link

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:

async startChildProcess(chatflow: ChatFlow, chatId: string, incomingInput: IncomingInput, endingNodeData?: INodeData) {

@KuphJr
Copy link

KuphJr commented Aug 7, 2023

@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
Copy link

fire17 commented Aug 7, 2023

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
Copy link

AngryAnt commented Aug 8, 2023

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
Copy link

fire17 commented Aug 13, 2023

@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)

JohnBQuinn pushed a commit to JohnBQuinn/Flowise that referenced this issue Jun 7, 2024
@nthomsencph
Copy link

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
Copy link

alew3 commented Sep 5, 2024

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

@xAlpharax
Copy link

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

@Zia-Ch
Copy link

Zia-Ch commented Oct 22, 2024

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

@xAlpharax
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants