Formatters¶
Formatters are used to make a generated solution visible to the user.
- interface EliasHaeussler\Typo3Solver\Formatter\Formatter¶
Interface for formatters that convert a given problem and its solution into a readable format.
- format($problem, $solution)¶
Format given problem and solution to string.
- Parameters
$problem (
EliasHaeussler\Typo3Solver\ProblemSolving\Problem\Problem
) -- The problem to be formatted$solution (
EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Solution
) -- The solution to be formatted
- Return type
string
Default formatters¶
Since exceptions are handled in various places, the extension already ships with some default formatters:
- class EliasHaeussler\Typo3Solver\Formatter\CliFormatter¶
Formatter used on the command line. It displays all provided solutions. On verbose output, the original prompt is also displayed. In addition, if a solution comes from the solutions cache, the original date and cache identifier are displayed as well.
- class EliasHaeussler\Typo3Solver\Formatter\JsonFormatter¶
This formatter is used within the solver:solve command if the solver-solve-json option is given. It displays the solution as JSON string, allowing further processing, especially in CI.
- class EliasHaeussler\Typo3Solver\Formatter\WebFormatter¶
This formatter is used for the modified debug exception handler. It adds an additional section to the error page which displays all solutions. In addition, the used model, generated prompt and cache metadata are shown.
Note
If solution streaming is possible, the
EliasHaeussler\Typo3Solver\Formatter\WebStreamFormatter
is used instead on the error page.
- class EliasHaeussler\Typo3Solver\Formatter\WebStreamFormatter¶
On solution streaming, this formatter is used to only print the list of solutions, streaming it to the error page where it replaces the current solution list.
See also
View the sources on GitHub: