1. Go to this page and download the library: Download opscale/fields 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/ */
opscale / fields example snippets
use Opscale\Fields\AI;
public function fields(NovaRequest $request): array
{
return [
Text::make('Name'),
Textarea::make('Description'),
BelongsTo::make('Category', 'category'),
AI::make('Assistant')
->fields(['name', 'description', 'category'])
->agent(ProductCopilot::class)
->context(fn (NovaRequest $r) => ['tenant_id' => $r->user()->tenant_id])
->onlyOnForms(),
];
}
use Opscale\Fields\AI\Agents\FieldAgent;
final class ProductCopilot extends FieldAgent
{
protected function persona(): string
{
return 'You are a product catalog copilot... derive name, description, '
.'price, SKU, stock and category from a short merchant description.';
}
protected function lookupTools(): iterable
{
yield new SearchCategories; // returns real category IDs from the DB
}
}