| | |
| | | import { AnswerType, MultiChatType, RoleEnum, StepEnum } from '../model/types'; |
| | | import { GetHistoryAnswer } from '/@/api/ai/chat'; |
| | | import moment from 'moment'; |
| | | |
| | | import type { Attach } from '../components/playBar/hook/useAttach'; |
| | | import { |
| | | getFileGroupType, |
| | | getFileSuffix, |
| | | getIconByGroupType, |
| | | getIconClassByGroupType, |
| | | } from '../components/playBar/hook/useUploadFile'; |
| | | export const useLoadData = () => { |
| | | const parseExtraContent = (res) => { |
| | | if (!res) return {}; |
| | |
| | | history_id: historyId, |
| | | }); |
| | | }; |
| | | |
| | | const convertAttach = (userValues: any): Attach[] => { |
| | | const attachList: Attach[] = []; |
| | | if (userValues?.attach_tables) { |
| | | userValues.attach_tables.forEach((item: any) => { |
| | | attachList.push({ |
| | | title: item.title, |
| | | type: 'table', |
| | | model: item, |
| | | icon: 'biaoge', |
| | | iconClass: 'ywicon-biaoge text-[#c5e0ff]', |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | if (userValues?.attach_files) { |
| | | userValues.attach_files.forEach((item: any) => { |
| | | const suffix = getFileSuffix(item.file_name); |
| | | const groupType = getFileGroupType(suffix); |
| | | attachList.push({ |
| | | title: item.file_name, |
| | | type: 'file', |
| | | model: item, |
| | | icon: getIconByGroupType(groupType), |
| | | iconClass: getIconClassByGroupType(groupType), |
| | | }); |
| | | }); |
| | | } |
| | | return attachList; |
| | | }; |
| | | /** |
| | | * 获取用户回复数据,并插入到对话当中去 |
| | | */ |
| | |
| | | const insertIndex = index + 1 + i; |
| | | const currentUserMsg = tmpMessageList[insertIndex - 1]; |
| | | currentUserMsg.content.values = item?.answer?.question ?? currentUserMsg.content.values; |
| | | |
| | | const attachList = convertAttach(item?.answer); |
| | | currentUserMsg.attachList = attachList; |
| | | const mapUser = userItemIdMap.get(index); |
| | | const historyId = mapUser?.history_id; |
| | | |
| | |
| | | convertProcessToStep, |
| | | convertProcessItem, |
| | | formatShowTimeYear, |
| | | getStepGroupList |
| | | getStepGroupList, |
| | | convertAttach, |
| | | }; |
| | | }; |