ianarawjo / ChainForge

An open-source visual programming environment for battle-testing prompts to LLMs.
https://chainforge.ai/docs
MIT License
2.23k stars 173 forks source link

Constrain flows to be DAGs? #279

Open benwhalley opened 4 months ago

benwhalley commented 4 months ago

Should the UI constrain nodes to be within a DAG? At present feedback is permitted in the UI, and generates multiple new inputs/outputs.

If flows were DAGs it would be possible to allow to user to automatically rerun the entire flow on making a change in a parent node.

(This project is great BTW. I found it by searching for front end libraries for graph editing because I wanted to make something very similar).

ianarawjo commented 4 months ago

Thank you! Yes I have wanted a "rerun flow" top-level button but it is not so easy with how the code is structured. Constraining to DAG would require some validation mechanism that walks the node graph. Feel free to code one up! If it was coded, the feature would enable a high-level "Rerun flow" button.

benwhalley commented 4 months ago

I actually have a prototype of something similar to chainforge running in python, and I used networkx to build and traverse a DAG, which makes it all really simple.

I actually wondered how tied you were to having all the API-calling stuff be triggered from the javascript? I wasn't sure on the way you wanted to architect things because you obviously have the python server running, but that doesn't really do much other than serve the html and do some of the custom provider calling — but that would be easy to port to js. Have you got a sense of whether you will move towards a server-side system more generally? For me it would be really helpful to be do it that way for a bunch of reasons:

Hypothetically, would you be interested in using the python backend to keep track of the graph being built in the UI and where you could offload more of the graph traversal and LLM calling logic to the server?