feat(AI): add ai manager admin and create powerpoint with ai
This commit is contained in:
31
app/Models/AiProvider.php
Normal file
31
app/Models/AiProvider.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\AiProviderDriver;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable(['name', 'driver', 'model', 'base_url', 'api_key', 'is_active', 'is_default'])]
|
||||
#[Hidden(['api_key'])]
|
||||
class AiProvider extends Model
|
||||
{
|
||||
public function resolvedBaseUrl(): string
|
||||
{
|
||||
return $this->base_url ?: $this->driver->defaultBaseUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'driver' => AiProviderDriver::class,
|
||||
'api_key' => 'encrypted',
|
||||
'is_active' => 'boolean',
|
||||
'is_default' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Enums\TemplateKeyType;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
@@ -27,6 +28,17 @@ class TemplateKey extends Model
|
||||
return $this->belongsTo(Template::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip any literal curly braces the admin may have copied from the pptx placeholder
|
||||
* (e.g. "{Main Title}" -> "Main Title"), since braces are added automatically at match time.
|
||||
*/
|
||||
protected function key(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
set: fn (string $value) => trim($value, "{} \t\n\r\0\x0B"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user