66 lines
1.5 KiB
PHP
66 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Services\AiEditing;
|
|
|
|
use App\Models\AiEditingSetting;
|
|
|
|
class AiEditingRuntimeConfig
|
|
{
|
|
public function settings(): AiEditingSetting
|
|
{
|
|
return AiEditingSetting::current();
|
|
}
|
|
|
|
public function isEnabled(): bool
|
|
{
|
|
return (bool) $this->settings()->is_enabled;
|
|
}
|
|
|
|
public function defaultProvider(): string
|
|
{
|
|
return (string) ($this->settings()->default_provider ?: 'runware');
|
|
}
|
|
|
|
public function queueAutoDispatch(): bool
|
|
{
|
|
return (bool) $this->settings()->queue_auto_dispatch;
|
|
}
|
|
|
|
public function queueName(): string
|
|
{
|
|
$queueName = trim((string) ($this->settings()->queue_name ?: ''));
|
|
|
|
return $queueName !== '' ? $queueName : 'default';
|
|
}
|
|
|
|
public function maxPolls(): int
|
|
{
|
|
return max(1, (int) $this->settings()->queue_max_polls);
|
|
}
|
|
|
|
public function runwareMode(): string
|
|
{
|
|
$mode = trim((string) ($this->settings()->runware_mode ?: ''));
|
|
|
|
return $mode !== '' ? $mode : 'live';
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public function blockedTerms(): array
|
|
{
|
|
return array_values(array_filter(array_map(
|
|
static fn (mixed $term): string => trim((string) $term),
|
|
(array) $this->settings()->blocked_terms
|
|
)));
|
|
}
|
|
|
|
public function statusMessage(): ?string
|
|
{
|
|
$message = trim((string) ($this->settings()->status_message ?? ''));
|
|
|
|
return $message !== '' ? $message : null;
|
|
}
|
|
}
|