format-dialog-question-by-history.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import generateClientUniqueId from '../../utils/generate-client-unique-id';
  2. import { getIcon4Question } from './get-icon-4-dialog';
  3. /**
  4. * 格式化用户的对话历史记录的提问数据
  5. */
  6. export default function formatDialogQuestionByHistory(item, agentInfo) {
  7. const agent_icon = agentInfo?.agent?.icon || '';
  8. const icon_src = getIcon4Question(agent_icon);
  9. return {
  10. /**
  11. * 对话消息类别
  12. * 0 历史消息
  13. * 1 新消息(本次进入页面新建的消息,但是已经结束轮次)
  14. * 2 当前的消息(此刻正在进行中的消息)
  15. */
  16. client_custom_chat_type: 0,
  17. /**
  18. * 此项的类别
  19. * a 智能体的回答
  20. * q 客户端的提问
  21. */
  22. client_custom_item_type: 'q', // 回答的答案
  23. /**
  24. * 会话展示时,可以通过此值,判断该如何进行内容显示
  25. * 当值为0时,可能显示加载中动画
  26. * 当值为1时,展示消息内容,展示 停止生成按钮
  27. * 当值为2时,可能展示反馈操作按钮
  28. */
  29. client_custom_chat_status: 2, // 此轮会话的状态值 0 加载中 1 进行中 2 已结束
  30. // 图标
  31. client_custom_icon: icon_src,
  32. client_custom_unique_id: generateClientUniqueId(item.content),
  33. question: item.content,
  34. client_custom_upload_file_list: item.files
  35. };
  36. }