init project
This commit is contained in:
37
app/Models/EmbeddingEntry.php
Normal file
37
app/Models/EmbeddingEntry.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\EmbeddingEntryFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'source_text',
|
||||
'content_hash',
|
||||
'embedding',
|
||||
'embedding_dimensions',
|
||||
'provider',
|
||||
'model',
|
||||
'tokens',
|
||||
])]
|
||||
class EmbeddingEntry extends Model
|
||||
{
|
||||
/** @use HasFactory<EmbeddingEntryFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'embedding' => 'array',
|
||||
'embedding_dimensions' => 'integer',
|
||||
'tokens' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
46
app/Models/EmbeddingUsageEvent.php
Normal file
46
app/Models/EmbeddingUsageEvent.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\EmbeddingUsageEventFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable([
|
||||
'user_id',
|
||||
'tool',
|
||||
'provider',
|
||||
'model',
|
||||
'embedding_dimensions',
|
||||
'input_count',
|
||||
'result_count',
|
||||
'tokens',
|
||||
])]
|
||||
class EmbeddingUsageEvent extends Model
|
||||
{
|
||||
/** @use HasFactory<EmbeddingUsageEventFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'embedding_dimensions' => 'integer',
|
||||
'input_count' => 'integer',
|
||||
'result_count' => 'integer',
|
||||
'tokens' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -43,4 +44,12 @@ class User extends Authenticatable
|
||||
->map(fn ($word) => Str::substr($word, 0, 1))
|
||||
->implode('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<EmbeddingUsageEvent, $this>
|
||||
*/
|
||||
public function embeddingUsageEvents(): HasMany
|
||||
{
|
||||
return $this->hasMany(EmbeddingUsageEvent::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user