Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 200 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 200 Revision 1294
Zeile 104... Zeile 104...
104
 
104
 
Zeile 105... Zeile 105...
105
### Displaying solutions
105
### Displaying solutions
Zeile 106... Zeile 106...
106
 
106
 
107
In addition to displaying an exception, Ignition can display a solution as well.
-
 
Zeile 108... Zeile 107...
108
 
107
In addition to displaying an exception, Ignition can display a solution as well.
Zeile 109... Zeile 108...
109
Out of the box, Ignition will display solutions for common errors such as bad methods calls, or using undefined
108
 
110
properties.
109
Out of the box, Ignition will display solutions for common errors such as bad methods calls, or using undefined properties.
Zeile 196... Zeile 195...
196
        AnotherSolutionProvider::class,
195
        AnotherSolutionProvider::class,
197
    ])
196
    ])
198
    ->register();
197
    ->register();
199
```
198
```
Zeile -... Zeile 199...
-
 
199
 
-
 
200
### AI powered solutions
-
 
201
 
-
 
202
Ignition can send your exception to Open AI that will attempt to automatically suggest a solution. In many cases, the suggested solutions is quite useful, but keep in mind that the solution may not be 100% correct for your context.
-
 
203
 
-
 
204
To generate AI powered solutions, you must first install this optional dependency.
-
 
205
 
-
 
206
```bash
-
 
207
composer require openai-php/client
-
 
208
```
-
 
209
 
-
 
210
To start sending your errors to OpenAI, you must instanciate the `OpenAiSolutionProvider`. The constructor expects a OpenAI API key to be passed, you should generate this key [at OpenAI](https://platform.openai.com).
-
 
211
 
-
 
212
```php
-
 
213
use \Spatie\Ignition\Solutions\OpenAi\OpenAiSolutionProvider;
-
 
214
 
-
 
215
$aiSolutionProvider = new OpenAiSolutionProvider($openAiKey);
-
 
216
```
-
 
217
 
-
 
218
To use the solution provider, you should pass it to `addSolutionProviders` when registering Ignition.
-
 
219
 
-
 
220
```php
-
 
221
\Spatie\Ignition\Ignition::make()
-
 
222
    ->addSolutionProviders([
-
 
223
        $aiSolutionProvider,
-
 
224
        // other solution providers...
-
 
225
    ])
-
 
226
    ->register();
-
 
227
```
-
 
228
 
-
 
229
By default, the solution provider will send these bits of info to Open AI:
-
 
230
 
-
 
231
- the error message
-
 
232
- the error class
-
 
233
- the stack frame
-
 
234
- other small bits of info of context surrounding your error
-
 
235
 
-
 
236
It will not send the request payload or any environment variables to avoid sending sensitive data to OpenAI.
-
 
237
 
-
 
238
#### Caching requests to AI
-
 
239
 
-
 
240
By default, all errors will be sent to OpenAI. Optionally, you can add caching so similar errors will only get sent to OpenAI once. To cache errors, you can call `useCache` on `$aiSolutionProvider`. You should pass [a simple-cache-implementation](https://packagist.org/providers/psr/simple-cache-implementation). Here's the signature of the `useCache` method.
-
 
241
 
-
 
242
```php
-
 
243
public function useCache(CacheInterface $cache, int $cacheTtlInSeconds = 60 * 60)
-
 
244
```
-
 
245
 
-
 
246
#### Hinting the application type
-
 
247
 
-
 
248
To increase the quality of the suggested solutions, you can send along the application type (Symfony, Drupal, WordPress, ...) to the AI. 
-
 
249
 
-
 
250
To send the application type call `applicationType` on the solution provider.
-
 
251
 
-
 
252
```php
-
 
253
$aiSolutionProvider->applicationType('WordPress 6.2')
-
 
254
```
200
 
255
 
Zeile 201... Zeile 256...
201
### Sending exceptions to Flare
256
### Sending exceptions to Flare
202
 
257