run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
35.77k stars 5.06k forks source link

[Feature Request]: Make workflows context serializable #16233

Open logan-markewich opened 2 days ago

logan-markewich commented 2 days ago

Feature Description

We should provide a way for the context to be serializable. This is especially useful for use cases where you need to pause a workflow and resume it later, stepwise execution, etc.

Imagine an async stateless server like next.js. You might want to run your workflows stepwise, and store them in redis between requests. A similar use-case comes up for llama-deploy

To support this, we should serialize everything we can on the context. This means

If something in the globals dict is not serializable (i.e. json.dumps()), then we should try to pickle it. If we can't pickle, we raise an error, and the user can address how they are (ab)using the context.

Reason

Enable more stateless runs of a workflow

Value of Feature

Supporting more serving and deployment options

zzhsaga commented 1 day ago

I'm really interested in your idea! I'm currently working on developing an agentic workflow, and I definitely think serialization could make it much more manageable and modular.

Do you have any approaches in mind so far? For example, do you have a preferred format for storing the objects?