Skip to main content

ContextVariables

Stores and manages context variables for agentic workflows.
Utilises a dictionary-like interface for setting, getting, and removing variables.
Initialize with data dictionary as an optional positional parameter.
Parameters:

Class Attributes

data



model_config



Static Methods

from_dict

Create a new ContextVariables instance from a dictionary.
E.g.:
my_context = {“user_id”: “12345”, “settings”: {“theme”: “dark”}} context = ContextVariables.from_dict(my_context)
Parameters: Returns:

Instance Methods

clear

Clear all keys and values from the context.

contains

Check if a key exists in the context.
Parameters: Returns:

get

Get a value from the context by key.
Parameters: Returns:

items

Get all key-value pairs in the context.
Returns:
An iterable of all key-value pairs
Returns:

keys

Get all keys in the context.
Returns:
An iterable of all keys
Returns:

remove

Remove a key from the context.
Parameters: Returns:

set

Set a value in the context by key.
Parameters:

to_dict

Convert context variables to a dictionary.
Returns:
Dictionary representation of all context variables
Returns:

update

Update context with key-value pairs from another dictionary.
Parameters:

values

Get all values in the context.
Returns:
An iterable of all values
Returns: