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
\EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Provider\SolutionProvider

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<EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Provider\Model\AiModel>

interface StreamedSolutionProvider
Fully qualified name
\EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Provider\StreamedSolutionProvider

Extended interface for solution providers that are able to stream solutions. Read more about a practical use case of this interface at Streamed solution.

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 \EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Solution.

param EliasHaeussler\Typo3Solver\ProblemSolving\Problem\Problem $problem

The problem to be solved

returntype

Traversable<EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Solution>

throws

EliasHaeussler\Typo3Solver\Exception\UnableToSolveException

Default providers

The extension ships with a default provider:

class OpenAISolutionProvider
Fully qualified name
\EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Provider\OpenAISolutionProvider

Default provider used to generate solutions using the configured OpenAI model. It uses the chat completion endpoint and is therefore streamable.

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
\EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Provider\CacheSolutionProvider

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.