InternalError
Display existing form in action modal
public static function form(Form $form): Form
{
return $form
->schema([
...ModuleResource::form($form)->getComponents(),
Repeater::make('agents')
->relationship('agents')
->columnSpanFull()
->schema([
Forms\Components\Textarea::make('instructions')
->required()
->label('Instructions')
->helperText('Guidelines that the agent follows to generate responses')
->placeholder('e.g. You are a helpful university tutor providing aid for students tasked with programming ...'),
Forms\Components\Select::make('openai_language_model')
->required()
->options(fn () => collect(OpenAI::models())->pluck('name', 'name'))
->helperText(fn () => new HtmlString(collect(OpenAI::models())
->map(fn ($model) => "<strong>{$model->name}</strong> - Input: \${$model->input} / 1M tokens, Output: \${$model->output} / 1M tokens")
->join('<br>')))
->label('OpenAI Language Model'),
])
->extraItemActions([
Forms\Components\Actions\Action::make('viewAgentForm')
->icon('heroicon-o-cube')
->label('View Advanced Agent Form')
->modalHeading('Agent Form')
->modalDescription('Edit the advanced details for the agent.')
->modalWidth('lg')
->url(fn ($record) => AgentResource::getUrl('edit', [$record]), true),
]
)
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
...ModuleResource::form($form)->getComponents(),
Repeater::make('agents')
->relationship('agents')
->columnSpanFull()
->schema([
Forms\Components\Textarea::make('instructions')
->required()
->label('Instructions')
->helperText('Guidelines that the agent follows to generate responses')
->placeholder('e.g. You are a helpful university tutor providing aid for students tasked with programming ...'),
Forms\Components\Select::make('openai_language_model')
->required()
->options(fn () => collect(OpenAI::models())->pluck('name', 'name'))
->helperText(fn () => new HtmlString(collect(OpenAI::models())
->map(fn ($model) => "<strong>{$model->name}</strong> - Input: \${$model->input} / 1M tokens, Output: \${$model->output} / 1M tokens")
->join('<br>')))
->label('OpenAI Language Model'),
])
->extraItemActions([
Forms\Components\Actions\Action::make('viewAgentForm')
->icon('heroicon-o-cube')
->label('View Advanced Agent Form')
->modalHeading('Agent Form')
->modalDescription('Edit the advanced details for the agent.')
->modalWidth('lg')
->url(fn ($record) => AgentResource::getUrl('edit', [$record]), true),
]
)
]);
}
6 replies