PHP code example of mateffy / llm-magic-ui
1. Go to this page and download the library: Download mateffy/llm-magic-ui library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mateffy / llm-magic-ui example snippets
use Mateffy\Magic\Chat\HasChat;
use Mateffy\Magic\Chat\InteractsWithChat;
use Mateffy\Magic\Chat\Tool;
class MyChatComponent extends Component implements HasChat
{
use InteractsWithChat;
protected static function getTools() : array
{
return [
Tool::make('search')
->callback(function (string $query) {
return Article::where('title', 'like', "%$query%")
->limit(5)
->get();
})
->widget(ViewToolWidget::view('components.search-results')),
];
}
}