style updates
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\AI\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
final class AIExecution extends Model
|
||||
{
|
||||
protected $fillable=['execution_id','ai_provider_id','ai_prompt_id','user_id','model','purpose','input','output','context','usage','status','error','duration_ms','completed_at'];
|
||||
protected $casts=['context'=>'array','usage'=>'array','completed_at'=>'datetime'];
|
||||
protected $fillable = ['execution_id', 'ai_provider_id', 'ai_prompt_id', 'user_id', 'model', 'purpose', 'input', 'output', 'context', 'usage', 'status', 'error', 'duration_ms', 'completed_at'];
|
||||
|
||||
protected $casts = ['context' => 'array', 'usage' => 'array', 'completed_at' => 'datetime'];
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\AI\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
final class AIKnowledgeChunk extends Model
|
||||
{
|
||||
protected $fillable=['ai_knowledge_source_id','position','content','metadata'];
|
||||
protected $casts=['metadata'=>'array'];
|
||||
protected $fillable = ['ai_knowledge_source_id', 'position', 'content', 'metadata'];
|
||||
|
||||
protected $casts = ['metadata' => 'array'];
|
||||
}
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\AI\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
final class AIKnowledgeSource extends Model
|
||||
{
|
||||
protected $fillable=['name','source_kind','source_type','source_id','content','checksum','metadata','status','chunk_count','indexed_at'];
|
||||
protected $casts=['metadata'=>'array','indexed_at'=>'datetime'];
|
||||
public function source(): MorphTo { return $this->morphTo(); }
|
||||
public function chunks(): HasMany { return $this->hasMany(AIKnowledgeChunk::class); }
|
||||
protected $fillable = ['name', 'source_kind', 'source_type', 'source_id', 'content', 'checksum', 'metadata', 'status', 'chunk_count', 'indexed_at'];
|
||||
|
||||
protected $casts = ['metadata' => 'array', 'indexed_at' => 'datetime'];
|
||||
|
||||
public function source(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function chunks(): HasMany
|
||||
{
|
||||
return $this->hasMany(AIKnowledgeChunk::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\AI\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
final class AIPrompt extends Model
|
||||
{
|
||||
protected $fillable=['name','slug','purpose','system_prompt','user_template','variables','version','is_active','created_by'];
|
||||
protected $casts=['variables'=>'array','is_active'=>'boolean'];
|
||||
protected $fillable = ['name', 'slug', 'purpose', 'system_prompt', 'user_template', 'variables', 'version', 'is_active', 'created_by'];
|
||||
|
||||
protected $casts = ['variables' => 'array', 'is_active' => 'boolean'];
|
||||
|
||||
public function render(array $variables): string
|
||||
{
|
||||
return preg_replace_callback('/\{\{\s*([\w.]+)\s*\}\}/', fn($m)=>(string)data_get($variables,$m[1],''), $this->user_template) ?? $this->user_template;
|
||||
return preg_replace_callback('/\{\{\s*([\w.]+)\s*\}\}/', fn ($m) => (string) data_get($variables, $m[1], ''), $this->user_template) ?? $this->user_template;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\AI\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
final class AIProvider extends Model
|
||||
{
|
||||
protected $fillable=['name','driver','base_url','api_key','default_model','models','options','is_active','is_default','last_tested_at','last_test_status','last_test_message'];
|
||||
protected $casts=['api_key'=>'encrypted','models'=>'array','options'=>'array','is_active'=>'boolean','is_default'=>'boolean','last_tested_at'=>'datetime'];
|
||||
protected $hidden=['api_key'];
|
||||
protected $fillable = ['name', 'driver', 'base_url', 'api_key', 'default_model', 'models', 'options', 'is_active', 'is_default', 'last_tested_at', 'last_test_status', 'last_test_message'];
|
||||
|
||||
protected $casts = ['api_key' => 'encrypted', 'models' => 'array', 'options' => 'array', 'is_active' => 'boolean', 'is_default' => 'boolean', 'last_tested_at' => 'datetime'];
|
||||
|
||||
protected $hidden = ['api_key'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user