ai-graphic / Graphic-so

Graphic.so is a Multi Modal Ai Playground ​to build your AI apps and automations 10x faster with Natural Language interface
https://graphic.so
GNU General Public License v3.0
32 stars 9 forks source link

Request for PR: run nodes in parallel #2

Open seshubonam opened 1 month ago

seshubonam commented 1 month ago

right now, execution of nodes happens in sequence.

example: in reactflow, need to find a way to run two nodes using the previous node has finished generation of output.

here is some guidance on custom nodes in reactflow:

https://reactflow.dev/learn/customization/custom-nodes

Aarize29 commented 1 month ago

right now, execution of nodes happens in sequence.

example: in reactflow, need to find a way to run two nodes using the previous node has finished generation of output.

here is some guidance on custom nodes in reactflow:

https://reactflow.dev/learn/customization/custom-nodes

I have worked on this type of issue in one of my project, where earlier all nodes are running sequentially, I wanted to make them run in parallel, So basically I wrote an algorithm ( just a dfs πŸ˜‚ ) , in this algo what I did was, first i created one map which indicates which node is connected to which node, then I created a list in which all sequences (all paths ) from source to desination are mentioned ( I did this using Graph concept , first created an adjacency list and used dfs to map all the paths), for example [ { 0->1->2->4}, {0->1->3->4}] , here 2 and 3 are conneceted with 1 , here my source is 0 and destination is 4.

After getting the list [ { 0->1->2->4}, {0->1->3->4}], I used promise.all to execute both the path in parallel, it made my program very fast and reduced the time of execution from 17 seconds to 4 seconds

fyi :- . 4 seconds seems slow but it takes this much time because it is calling a lot of functions in the backend( quite complex project πŸ˜‰).

seshubonam commented 1 month ago

just commenting this if its useful for parallel run of nodes:

https://x.com/ryanchenkie/status/1130842992980430853?s=19

and this:

https://x.com/farzad_yz/status/1079486371230875653?t=vsegiB2C5syarIFj_NMXEg&s=19

the actual fix planned internally would be to rewrite the architecture to separate frontend and backend instead of doing it all in next js