fabricatio_tool.models.collector
Module for the ResultCollector class, which is used to collect, submit, revoke, and retrieve results in a container.
Classes
Error raised during tool code execution, surfaced via ResultCollector. |
|
Used for collecting results as the task requests. |
Module Contents
- class fabricatio_tool.models.collector.ApplicationError
Error raised during tool code execution, surfaced via ResultCollector.
- class fabricatio_tool.models.collector.ResultCollector
Used for collecting results as the task requests.
use .submit(key: str, val: Any) submit a result value val with the to the key slot. use .revoke(key: str) revoke a result from the container by its source key.
- submit(key: str, val: Any) Self
Submit a result to the container with the specified key.
- Parameters:
key (str) – The key to store the result under.
val (Any) – The result to store in the container.
- Returns:
The current instance for method chaining.
- Return type:
Self
- take[T](key: str, desired: Type[T] | None = None) T | None
- take(key: List[str], desired: Type[T] | None = None) List[T | None]
Retrieve value(s) from the container by key(s) with optional type checking.
This method retrieves a single value or multiple values from the container based on the provided key(s). It supports optional type checking to ensure the retrieved value matches the expected type.
- Parameters:
- Returns:
- If key is a string, returns the value of type T or None.
If key is a list, returns a list of values of type T or None for each key.
- Return type:
T | None | List[T | None]
- error() ApplicationError | None
Return the ApplicationError if one was stored during execution.