State
A State is the shared data dictionary that flows through your Pipeline. A State is currently defined as a TypedDict, so keys and value types are explicit. Each step reads from and writes to the State as it executes.
Default State: RAGState
RAGStateBy default, a Pipeline in our SDK is equipped with RAGState as it state, which is defined in gllm_pipeline.pipeline.states. The state keys are based on the keys that you might find in an Retrieval-Augmented Generation (RAG) pipeline. It is also equipped with a special state key for an EventEmitter for streaming purposes.
class RAGState(TypedDict):
user_query: str
queries: list[str]
retrieval_params: dict[str, Any]
chunks: list
history: str
context: str
response: str
references: str | list[str]
event_emitter: EventEmitterDuring Pipeline definition, you must ensure that your output state belongs to one of the pre-defined state keys.
Defining a custom State
The default RAGState may not be suitable for your purposes. For example, when defining a Subgraph, you may not need all of the keys. In contrast, there may be some additional state keys that you require. In these cases, you can define your own state structure.
To do so:
Using a Pydantic BaseModel as a State
Coming Soon!
Last updated