init project

This commit is contained in:
2026-05-10 13:21:24 +03:30
parent 5f210c6c73
commit dc36701c9d
26 changed files with 2149 additions and 69 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Actions\Embeddings;
use App\Models\EmbeddingUsageEvent;
use App\Models\User;
use App\Services\EmbeddingWorkbench;
use Illuminate\Contracts\Auth\Authenticatable;
class RecordEmbeddingUsageEvent
{
public function handle(
?Authenticatable $user,
EmbeddingWorkbench $workbench,
?string $selectedModel,
string $tool,
int $inputCount,
int $resultCount,
?int $tokens = null,
): ?EmbeddingUsageEvent {
if (! $user instanceof User) {
return null;
}
$model = $workbench->modelName($selectedModel);
return EmbeddingUsageEvent::query()->create([
'user_id' => $user->id,
'tool' => $tool,
'provider' => $workbench->providerName(),
'model' => $model,
'embedding_dimensions' => $workbench->dimensions($model),
'input_count' => max(0, $inputCount),
'result_count' => max(0, $resultCount),
'tokens' => $tokens,
]);
}
}