fabricatio_actions.actions.output

Dump the finalized output to a file.

Classes

DumpFinalizedOutput

Dump the finalized output to a file.

RenderedDump

Render the data to a file.

PersistentAll

Persist all the data to a directory.

RetrieveFromPersistent

Retrieve the object from the persistent file.

RetrieveFromLatest

Retrieve the object from the latest persistent file in the dir at load_path.

GatherAsList

Gather the objects from the context as a list.

Forward

Forward the object from the context to the output.

Module Contents

class fabricatio_actions.actions.output.DumpFinalizedOutput(/, **data: Any)

Bases: fabricatio_core.models.action.Action, fabricatio_core.capabilities.usages.UseLLM

Dump the finalized output to a file.

output_key: str = 'dump_path'

The key used to store this action’s output in the context dictionary.

dump_path: str | None = None
class fabricatio_actions.actions.output.RenderedDump(/, **data: Any)

Bases: fabricatio_core.models.action.Action, fabricatio_core.capabilities.usages.UseLLM

Render the data to a file.

output_key: str = 'dump_path'

The key used to store this action’s output in the context dictionary.

dump_path: str | None = None
template_name: str

The template name to render the data.

class fabricatio_actions.actions.output.PersistentAll(/, **data: Any)

Bases: fabricatio_core.models.action.Action, fabricatio_core.capabilities.usages.UseLLM

Persist all the data to a directory.

This action takes all PersistentAble objects from the execution context and persists them to individual subdirectories within a specified directory. It can handle both individual objects and collections of objects.

Returns:

The number of objects that were successfully persisted.

Return type:

int

Notes

  • Only objects implementing PersistentAble interface will be persisted

  • Each object gets its own subdirectory named after the context key

  • Collections of PersistentAble objects are persisted together in one subdirectory

  • Non-PersistentAble objects in the context are ignored

  • If override is True, existing persist_dir will be removed before persisting

output_key: str = 'persistent_count'

The number of objects persisted.

persist_dir: str | None = None

The directory to persist the data.

override: bool = False

Whether to remove the existing dir before dumping.

class fabricatio_actions.actions.output.RetrieveFromPersistent[T: fabricatio_capabilities.models.generic.PersistentAble](/, **data: Any)

Bases: fabricatio_core.models.action.Action

Retrieve the object from the persistent file.

output_key: str = 'retrieved_obj'

Retrieve the object from the persistent file.

load_path: str

The path of the persistent file or directory contains multiple file.

retrieve_cls: Type[T]

The class of the object to retrieve.

class fabricatio_actions.actions.output.RetrieveFromLatest[T: fabricatio_capabilities.models.generic.PersistentAble](/, **data: Any)

Bases: RetrieveFromPersistent[T], fabricatio_actions.models.generic.FromMapping[str | pathlib.Path, RetrieveFromLatest[T]]

Retrieve the object from the latest persistent file in the dir at load_path.

classmethod from_mapping(mapping: Mapping[str, str | pathlib.Path], /, retrieve_cls: Type[T] | None = None, **kwargs) List[RetrieveFromLatest[T]]

Create a list of RetrieveFromLatest from the mapping.

class fabricatio_actions.actions.output.GatherAsList(/, **data: Any)

Bases: fabricatio_core.models.action.Action

Gather the objects from the context as a list.

Notes

If both gather_suffix and gather_prefix are specified, only the objects with the suffix will be gathered.

output_key: str = 'gathered'

Gather the objects from the context as a list.

gather_suffix: str | None = None

Gather the objects from the context as a list.

gather_prefix: str | None = None

Gather the objects from the context as a list.

class fabricatio_actions.actions.output.Forward[V: str](/, **data: Any)

Bases: fabricatio_core.models.action.Action, fabricatio_actions.models.generic.FromMapping, fabricatio_actions.models.generic.FromSequence[V]

Forward the object from the context to the output.

output_key: str = 'forwarded'

Gather the objects from the context as a list.

original: str
classmethod from_sequence(sequence: Sequence[V], /, original: str | None = None, **kwargs: Any) List[Self]

Create a list of Forward from the sequence.

classmethod from_mapping(mapping: Mapping[str, str | Sequence[str]], **kwargs: Any) List[Self]

Create a list of Forward from the mapping.