AdminAgentFeedbackResource.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Http\Resources\V3;
  3. use Illuminate\Http\Request;
  4. /**
  5. * 管理员审阅的一条评价,带对应提问的摘要(提问还没入库时 run_id 等为空)。
  6. * 不给账号身份,只给账号类型。
  7. */
  8. class AdminAgentFeedbackResource extends BaseResource
  9. {
  10. /**
  11. * @param Request $request
  12. * @return array{
  13. * message_id: string,
  14. * rating: int,
  15. * tags: array<int, string>,
  16. * comment: string|null,
  17. * asked: bool,
  18. * client: string|null,
  19. * account_type: string,
  20. * updated_at: string,
  21. * run_id: string|null,
  22. * question: string|null,
  23. * route: 'question'|'term'|'passage'|'chat'|null,
  24. * status: string|null,
  25. * deep: bool|null,
  26. * latency_ms: int|null
  27. * }
  28. */
  29. public function toArray($request): array
  30. {
  31. $r = $this->resource;
  32. return [
  33. 'message_id' => $r->message_id,
  34. 'rating' => (int) $r->rating,
  35. 'tags' => $r->tags,
  36. 'comment' => $r->comment,
  37. 'asked' => (bool) $r->asked,
  38. 'client' => $r->client,
  39. 'account_type' => $r->account_type,
  40. 'updated_at' => $r->updated_at,
  41. 'run_id' => $r->run_id,
  42. 'question' => $r->question,
  43. 'route' => $r->route,
  44. 'status' => $r->status,
  45. 'deep' => $r->deep === null ? null : (bool) $r->deep,
  46. 'latency_ms' => $r->latency_ms === null ? null : (int) $r->latency_ms,
  47. ];
  48. }
  49. }