Solution providers
The most relevant components when it comes to the actual problem solving are solution providers. Each solution provider describes a way to solve a given problem.
- interface SolutionProvider
-
- Fully qualified name
-
\Elias
Haeussler\ Typo3Solver\ Problem Solving\ Solution\ Provider\ Solution Provider
Interface for solution providers used to provide a solution for a given problem. Solution providers can be combined with \EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Provider\CacheSolutionProvider if they are cacheable.
- static create ( )
-
Create a new instance of the solution provider. This is mainly used on a low level basis where dependency injection is not available.
- returns
-
An instance of the current solution provider.
- getSolution ( $problem)
-
Provide a solution for the given problem.
- param EliasHaeussler\Typo3Solver\ProblemSolving\Problem\Problem $problem
-
The problem to be solved
- returntype
-
EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Solution
- throws
-
EliasHaeussler\Typo3Solver\Exception\UnableToSolveException
- canBeUsed ( $exception)
-
Define whether the solution provider can handle the given exception. This is especially useful to skip problem solving for some exceptions whose solution is already known or is too specific to solve.
- param Throwable $exception
-
The exception to test for compatibility
- returntype
-
bool
- isCacheable ( )
-
Define whether solutions provided by this solution provider should be cached when using the solution provider in combination with \EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Provider\CacheSolutionProvider.
- returntype
-
bool
- listModels ( $includeUnsupported = false)
-
List all AI models by the underlying AI provider. By default, only supported models are returned.
- param bool $includeUnsupported
-
Define whether to return unsupported models as well
- returntype
-
list<Elias
Haeussler\ Typo3Solver\ Problem Solving\ Solution\ Provider\ Model\ Ai Model>
- interface StreamedSolutionProvider
-
- Fully qualified name
-
\Elias
Haeussler\ Typo3Solver\ Problem Solving\ Solution\ Provider\ Streamed Solution Provider
Extended interface for solution providers that are able to stream solutions. Read more about a practical use case of this interface at Streamed solution.
Note
This interface extends the default \EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Provider\SolutionProvider.
- getStreamedSolution ( $problem)
-
Provide a solution stream for the given problem. The stream is returned as an instance of
\Traversable
, while each traversed item is an instance of\Elias
.Haeussler\ Typo3Solver\ Problem Solving\ Solution\ Solution - param EliasHaeussler\Typo3Solver\ProblemSolving\Problem\Problem $problem
-
The problem to be solved
- returntype
-
Traversable<Elias
Haeussler\ Typo3Solver\ Problem Solving\ Solution\ Solution> - throws
-
EliasHaeussler\Typo3Solver\Exception\UnableToSolveException
Default providers
The extension ships with a default provider:
- class OpenAISolutionProvider
-
- Fully qualified name
-
\Elias
Haeussler\ Typo3Solver\ Problem Solving\ Solution\ Provider\ Open AISolution Provider
Default provider used to generate solutions using the configured OpenAI model. It uses the chat completion endpoint and is therefore streamable.
Note
Streamed solutions always provide the complete solution delivered until the current solution delta for each iteration.
In addition, there's also a cached provider. It decorates a concrete solution provider with an additional cache layer. This avoids too many requests to the OpenAI endpoint.
- class CacheSolutionProvider
-
- Fully qualified name
-
\Elias
Haeussler\ Typo3Solver\ Problem Solving\ Solution\ Provider\ Cache Solution Provider
This provider decorates a concrete solution provider with an additional cache layer. The concrete solution provider must be provided in the \EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Provider\SolutionProvider::create method.
Note
Read more at Caching.
See also
View the sources on GitHub: