Error page screenshot

Error page screenshot

TYPO3 extension solver

Coverage Maintainability Tests CGL Release License
Version Downloads Supported TYPO3 versions Extension stability Slack

📦 Packagist | 🐥 TYPO3 extension repository | 💾 Repository | 🐛 Issue tracker

An extension for TYPO3 CMS to solve exceptions with AI generated solutions. It uses the OpenAI PHP client to send a prompt to a configured model and uses the responded completion as solution. Several completion attributes (model, tokens, temperature, number of completions) are configurable. It also provides a console command to solve problems from command line.

🚀 Features

  • Extended exception handler with AI generated solutions

  • Configurable AI completion attributes (model, tokens, temperature, number of completions)

  • Caching integration for solved problems

  • Command to solve problems from command line

  • Customizable solution providers and prompts

  • Compatible with TYPO3 11.5 LTS and 12.2

🔥 Installation

Via Composer:

composer require eliashaeussler/typo3-solver

Or download the zip file from TYPO3 extension repository (TER).

📂 Configuration

API key

You need an API key to perform requests at OpenAI. Once generated, the key must be configured in the extension configuration.

Extension configuration

The following extension configuration is available:

Configu ration

Description

Default value

provi der

FQCN of the solution provider

`EliasHaeussler\Typ o3Solver\Solution\Pro vider\OpenAISolutionP rovider <Classes/Pr oblemSolving/Solution /Provider/OpenAISolut ionProvider.php>`__

promp t

FQCN of the prompt generator

`EliasHaeussler\Typ o3Solver\Prompt\Defau ltPrompt <Classes/P roblemSolving/Solutio n/Prompt/DefaultPromp t.php>`__

``ignor edCodes ``

Comma-separated list of exception codes to ignore

api.k ey

API key for OpenAI requests

attri butes.m odel

OpenAI model to use (see List available models _ to show a list of available models)

text-davinci-003

attri butes.m axToken s

Maximum number of tokens to use per request

300

attri butes.t emperat ure

Temperature to use for completion requests (must be a value between 0 and 1)

0.5

attri butes.n umberOf Complet ions

`Number of completions <https://platform.ope nai.com/docs/api-reference/comple tions/create#completions/create-n >`__ to generate for each prompt

1

cache .lifeti me

Lifetime in seconds of the solutions cache (use 0 to disable caching)

86400 (1 day)

⚡ Usage

Exception handler

The extension provides a modified debug exception handler in `Error/AiSolverExceptionHandler <Classes/Error/AiSolverExceptionHandler.php>`__. It can be activated in the system configuration (aka LocalConfiguration.php):

# config/system/settings.php

return [
    'SYS' => [
        'debugExceptionHandler' => 'EliasHaeussler\\Typo3Solver\\Error\\AiSolverExceptionHandler',
    ],
];

Once configured, the exception handler tries to provide a solution for the current exception and shows it on the exception page.

Solve a problem on the command line

Next to the exception handler integration, one can also explicitly solve problems using the provided console command solver:solve.

vendor/bin/typo3 solver:solve <problem> [--code=CODE] [--file=FILE] [--line=LINE] [--refresh] [--json]

The following input parameters are available:

Parameter

Description

``problem` `

The exception message to solve

--code , -c

Optional exception code

--file , -f

Optional file where the exception occurs

--line , -l

Optional line number within the given file

--refres h, -r

Refresh a cached solution (requests a new solution and ignores the cached solution)

--json , -j

Print solution as JSON

List available models

The command solver:list-models can be used to list all available models for the configured OpenAI API key.

vendor/bin/typo3 solver:list-models

💡 All available models are listed in the OpenAI documentation.

Flush solution cache

Every solution is cached to reduce the amount of requests sent by the OpenAI client. In order to flush the solution cache or remove single cache entries, the command solver:cache:flush cam be used.

vendor/bin/typo3 solver:cache:flush [<identifier>]

The following input parameters are available:

Parameter

Description

identifier

Optional cache identifier to remove a single cache entry

💎 Credits

The extension icon (“lightbulb-on”) is a modified version of the original `actions-lightbulb-on <https://typo3.github.io/TYPO3.Icons/icons/actions/actions-lightbulb-on.html>`__ icon from TYPO3 core. In addition, the icons `actions-calendar <https://typo3.github.io/TYPO3.Icons/icons/actions/actions-calendar.html>`__, `actions-cpu <https://typo3.github.io/TYPO3.Icons/icons/actions/actions-cpu.html>`__, `actions-debug <https://typo3.github.io/TYPO3.Icons/icons/actions/actions-debug.html>`__ and `actions-exclamation-triangle-alt <https://typo3.github.io/TYPO3.Icons/icons/actions/actions-exclamation-triangle-alt.html>`__ from TYPO3 core are used. All icons are originally licensed under MIT License.

This project is highly inspired by the article `Fix your Laravel exceptions with AI <https://beyondco.de/blog/ai-powered-error-solutions-for-laravel>`__ by Marcel Pociot.

In addition, I’d like to thank Nuno Maduro and all contributors of the `openai-php/client <https://github.com/openai-php/client>`__ library for this beautiful piece of code.

⭐ License

This project is licensed under GNU General Public License 2.0 (or later).