lokalisierung vervollständigt, api provider testconnection, runware modellsuche aktiviert und style preview generation integriert
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Api\Plugins\ApiPluginInterface;
|
||||
use App\Api\Plugins\PluginLoader;
|
||||
use App\Models\AiModel;
|
||||
use App\Models\ApiProvider;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
@@ -27,7 +28,7 @@ class AiModelResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AiModel::class;
|
||||
|
||||
// protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-cpu-chip';
|
||||
|
||||
protected static ?int $navigationSort = -100;
|
||||
|
||||
@@ -36,30 +37,71 @@ class AiModelResource extends Resource
|
||||
return __('filament.navigation.groups.ai_models');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('filament.navigation.ai_models');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('Hinweise zu Model-Parametern')
|
||||
->description('Parameter werden je nach Plugin unterschiedlich verwendet: Runware/ComfyUI als JSON für Workflow/Model-Settings, Leonardo v2 akzeptiert z. B. width/height/style_ids/prompt_enhance. Prüfe die Plugin-Doku; Felder, die nicht zum Plugin passen, werden ignoriert.')
|
||||
Section::make(__('filament.resource.ai_model.parameters_help_title'))
|
||||
->description(__('filament.resource.ai_model.parameters_help_text'))
|
||||
->columns(1)
|
||||
->collapsible()
|
||||
->schema([]),
|
||||
TextInput::make('name')
|
||||
->label(__('filament.resource.ai_model.form.name'))
|
||||
->required(),
|
||||
TextInput::make('model_id')
|
||||
->required(),
|
||||
Select::make('model_id')
|
||||
->label(__('filament.resource.ai_model.form.model_id'))
|
||||
->searchable()
|
||||
->required()
|
||||
->getSearchResultsUsing(function (string $search, callable $get): array {
|
||||
$providerId = $get('api_provider_id');
|
||||
if (! $providerId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$provider = ApiProvider::find($providerId);
|
||||
if (! $provider || ! $provider->plugin) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$plugin = PluginLoader::getPlugin($provider->plugin, $provider);
|
||||
if (! method_exists($plugin, 'searchModels')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$results = $plugin->searchModels($search);
|
||||
|
||||
$options = [];
|
||||
foreach ($results as $result) {
|
||||
$id = $result['id'] ?? null;
|
||||
$name = $result['name'] ?? $id;
|
||||
if ($id) {
|
||||
$options[$id] = $name ? $name.' ('.$id.')' : $id;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
})
|
||||
->getOptionLabelUsing(fn ($value): ?string => $value),
|
||||
TextInput::make('model_type')
|
||||
->label(__('filament.resource.ai_model.form.model_type'))
|
||||
->nullable(),
|
||||
Select::make('api_provider_id')
|
||||
->label('API Provider')
|
||||
->label(__('filament.resource.ai_model.form.api_provider'))
|
||||
->relationship('primaryApiProvider', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Toggle::make('enabled')
|
||||
->label(__('filament.resource.ai_model.form.enabled'))
|
||||
->default(true),
|
||||
Textarea::make('parameters')
|
||||
->label(__('filament.resource.ai_model.form.parameters'))
|
||||
->nullable()
|
||||
->rows(15),
|
||||
]);
|
||||
@@ -143,7 +185,7 @@ class AiModelResource extends Resource
|
||||
->actions([
|
||||
EditAction::make(),
|
||||
Action::make('duplicate')
|
||||
->label('Duplicate')
|
||||
->label(__('filament.resource.ai_model.action.duplicate'))
|
||||
->icon('heroicon-o-document-duplicate')
|
||||
->action(function (Model $record, $livewire) {
|
||||
$livewire->redirect(static::getUrl('create', ['sourceRecord' => $record->id]));
|
||||
|
||||
Reference in New Issue
Block a user