PHP code example of janschuri / eloquent-ai-tools
1. Go to this page and download the library: Download janschuri/eloquent-ai-tools 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/ */
janschuri / eloquent-ai-tools example snippets
use EloquentAiTools\Concerns\HasToolModel;
use EloquentAiTools\Decision;
use EloquentAiTools\ToolBuilder;
use Illuminate\Database\Eloquent\Model;
use Laravel\Ai\Tools\Request;
class Article extends Model
{
use HasToolModel;
public static function toolConfig()
{
return static::newToolConfig([
'title' => 'Article headline',
'status' => 'Publication status',
'views' => 'View count',
'published_at' => 'Publish date',
])
->label('Articles')
->modelDescription('Articles from the CMS.')
->allowRead()
->maxLimit(50)
->whereMaxDepth(3)
->whereMaxConditionsPerGroup(10)
->scopes([
'published' => 'Only published articles.',
])
->reading(function (Request $request, array $appliers) {
return Decision::accept(); // or Decision::deny(...) / Decision::approve(...) / a bool
});
}
}
$tools = ToolBuilder::make()
->add(Article::toolConfig())
->build();
->toolKey('cms')