AgentRunFactory.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Database\Factories;
  3. use App\Models\AgentRun;
  4. use App\Models\AgentThread;
  5. use Illuminate\Database\Eloquent\Factories\Factory;
  6. use Illuminate\Support\Str;
  7. /**
  8. * @extends Factory<AgentRun>
  9. */
  10. class AgentRunFactory extends Factory
  11. {
  12. protected $model = AgentRun::class;
  13. /**
  14. * 归属字段(user_uid / device_id)跟随所属会话。
  15. *
  16. * @return array<string, mixed>
  17. */
  18. public function definition(): array
  19. {
  20. return [
  21. 'run_id' => (string) Str::uuid(),
  22. 'agent_thread_id' => AgentThread::factory(),
  23. // 账号与所属会话一致
  24. 'account_type' => fn (array $attrs) => AgentThread::find($attrs['agent_thread_id'])?->account_type,
  25. 'account_id' => fn (array $attrs) => AgentThread::find($attrs['agent_thread_id'])?->account_id,
  26. 'question' => fake()->sentence().'?',
  27. 'answer' => fake()->paragraph(),
  28. 'deep' => false,
  29. 'improve' => true,
  30. 'status' => 'ok',
  31. 'user_message_id' => (string) Str::uuid(),
  32. 'assistant_message_id' => (string) Str::uuid(),
  33. ];
  34. }
  35. }