36 lines
1.0 KiB
PHP
36 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\EmbeddingUsageEvent;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<EmbeddingUsageEvent>
|
|
*/
|
|
class EmbeddingUsageEventFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$tool = fake()->randomElement(['embed', 'search', 'compare']);
|
|
$inputCount = fake()->numberBetween(1, 8);
|
|
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'tool' => $tool,
|
|
'provider' => 'ollama',
|
|
'model' => config('ai.providers.ollama.models.embeddings.default', 'nomic-embed-text'),
|
|
'embedding_dimensions' => (int) config('ai.providers.ollama.models.embeddings.dimensions', 768),
|
|
'input_count' => $inputCount,
|
|
'result_count' => $tool === 'search' ? fake()->numberBetween(0, 10) : $inputCount,
|
|
'tokens' => fake()->optional()->numberBetween(5, 500),
|
|
];
|
|
}
|
|
}
|