JSON#
The JSON module provides a json-based version of the DBContextStorage
class.
This class is used to store and retrieve context data in a JSON. It allows Chatsky to easily
store and retrieve context data.
- class JSONContextStorage(path)[source]#
Bases:
DBContextStorage
Implements
DBContextStorage
with json as the storage format.- Parameters:
path (
str
) – Target file URI. Example: json://file.json.
- len_async()[source]#
Asynchronous method for retrieving number of stored Contexts.
- Return type:
int
- Returns:
The number of stored Contexts.
- set_item_async(key, value)[source]#
Asynchronous method for storing Context.
- Parameters:
key (
Hashable
) – Hashable key used to store Context instance.value (
Context
) – Context to store.
- get_item_async(key)[source]#
Asynchronous method for accessing stored Context.
- Parameters:
key (
Hashable
) – Hashable key used to store Context instance.- Return type:
- Returns:
The stored context, associated with the given key.
- del_item_async(key)[source]#
Asynchronous method for removing stored Context.
- Parameters:
key (
Hashable
) – Hashable key used to identify Context instance for deletion.
- contains_async(key)[source]#
Asynchronous method for finding whether any Context is stored with given key.
- Parameters:
key (
Hashable
) – Hashable key used to check if Context instance is stored.- Return type:
bool
- Returns:
True if there is Context accessible by given key, False otherwise.