File#
The File module provides simple file-based versions of the DBContextStorage class
such as json, pickle and shelve.
- class SerializableStorage(**data)[source]#
Bases:
BaseModelA special serializable database implementation. One element of this class will be used to store all the contexts, read and written to file on every turn.
-
main:
Dict[str,ContextMainInfo]#
-
turns:
List[Tuple[str,str,int,Optional[bytes]]]#
-
main:
- class FileContextStorage(path='', rewrite_existing=False, partial_read_config=None)[source]#
Bases:
DBContextStorage,ABCImplements
DBContextStoragewith any file-based storage format.- Parameters:
path (
str) – Target file URI.rewrite_existing (
bool) – Whether TURNS modified locally should be updated in database or not.partial_read_config (
Optional[Dict[Literal['labels','requests','responses'],Union[Literal['__all__'],int,Set[int]]]]) – Dictionary of subscripts for all possible turn items.
-
is_concurrent:
bool= False#
- async _load_main_info(ctx_id)[source]#
- Return type:
Optional[ContextMainInfo]
- class JSONContextStorage(path='', rewrite_existing=False, partial_read_config=None)[source]#
Bases:
FileContextStorageImplements
DBContextStoragewith json as the storage format.- Parameters:
path (
str) – Target file URI. Example: json://file.json.rewrite_existing (
bool) – Whether TURNS modified locally should be updated in database or not.partial_read_config (
Optional[Dict[Literal['labels','requests','responses'],Union[Literal['__all__'],int,Set[int]]]]) – Dictionary of subscripts for all possible turn items.
- class PickleContextStorage(path='', rewrite_existing=False, partial_read_config=None)[source]#
Bases:
FileContextStorageImplements
DBContextStoragewith pickle as the storage format.- Parameters:
path (
str) – Target file URI. Example: pickle://file.pkl.rewrite_existing (
bool) – Whether TURNS modified locally should be updated in database or not.partial_read_config (
Optional[Dict[Literal['labels','requests','responses'],Union[Literal['__all__'],int,Set[int]]]]) – Dictionary of subscripts for all possible turn items.
- class ShelveContextStorage(path='', rewrite_existing=False, partial_read_config=None)[source]#
Bases:
FileContextStorageImplements
DBContextStoragewith shelve as the storage format.- Parameters:
path (
str) – Target file URI. Example: shelve://file.shlv.rewrite_existing (
bool) – Whether TURNS modified locally should be updated in database or not.partial_read_config (
Optional[Dict[Literal['labels','requests','responses'],Union[Literal['__all__'],int,Set[int]]]]) – Dictionary of subscripts for all possible turn items.
- _SHELVE_ROOT = 'root'#