Страницы · Laravilt
Resource Agents
Configure the AI agent of a panel resource.
A panel resource gets AI capabilities when it overrides ai(). The agent passed in is already prepared by Resource::makeAIAgent(): its name is the resource slug, its model is the resource model, and it has a default description.
php
php artisan laravilt:resource can generate this for you. With the AI option it creates Resources/{Model}/Ai/{Model}Ai.php with a configure(AIAgent $ai) method, and the resource's ai() returns {Model}Ai::configure($ai).
Permissions
canCreate, canUpdate, canDelete and canQuery all default to true.
php
Provider and model
php
Custom tools
php
See Custom tools.
Methods
| Method | Description |
|---|---|
name(string) | Agent name |
description(string) | Agent description |
systemPrompt(string) | System instructions |
model(string) | Eloquent model class |
searchable(array) | Searchable columns |
columns(array) / addColumn(AIColumn) | AI column definitions |
tools(array) / addTool(Tool) | Custom tools |
metadata(array) | Extra data |
canCreate(), canUpdate(), canDelete(), canQuery() | Permissions (default true) |
provider(string) | Provider name |
aiModel(string|BackedEnum) | Model name or enum |
handler(Closure) | Custom handler |
toResourceAgent() | Convert to an executable ResourceAgent |
toArray() | Export for the frontend |