wujingjing
2025-04-09 2b8b2cac4fe3f05474459a034bc4034f2d7aa0cb
src/components/chat/model/types.ts
@@ -1,15 +1,26 @@
import RecordSetCom from '../chatComponents/recordSetCom/RecordSetCom.vue';
import NormalTextCom from '../chatComponents/normalTextCom/NormalTextCom.vue';
import knowledgeCom from '../chatComponents/knowledgeCom/KnowledgeCom.vue';
import NormalTextCom from '../chatComponents/normalTextCom/NormalTextCom.vue';
import RecordSetCom from '../chatComponents/recordSetCom/RecordSetCom.vue';
import ScriptMode from '../chatComponents/scriptMode/ScriptMode.vue';
import SummaryCom from '../chatComponents/summaryCom/SummaryCom.vue';
import type { Attach } from '../components/playBar/hook/useAttach';
import assistantPic from '/static/images/role/assistant-200x192.png';
import userPic from '/static/images/role/user-200x206.png';
import ContentCb from '../chatComponents/contentCbCom/index.vue';
import InputSelect from '../chatComponents/contentCbCom/InputSelect.vue';
import TimeRange from '../chatComponents/contentCbCom/TimeRange.vue';
import assistantPic from '../images/assistant.jpg';
import userPic from '../images/user.svg';
export const enum AnswerType {
   Knowledge = 'knowledge',
   RecordSet = 'recordset',
   Text = 'text',
   Summary = 'summary',
   Url = 'url',
   Map = 'map',
   Report = 'report_list',
   Script = 'script',
    ContentCb = 'content_cb',
}
export const answerTypeMapCom = {
@@ -17,37 +28,97 @@
   [AnswerType.RecordSet]: RecordSetCom,
   [AnswerType.Text]: NormalTextCom,
   [AnswerType.Summary]: SummaryCom,
   [AnswerType.Script]: ScriptMode,
   [AnswerType.ContentCb]: ContentCb,
};
export const enum RoleEnum {
   user = 'user',
   assistant = 'assistant',
   system = 'system',
}
export const AnswerState = {
   Null: null,
   Like: 1,
   Unlike: 0,
   Like: '1',
   Unlike: '0',
};
export type AnswerStateType = typeof AnswerState;
export type ContextHistory = {
   /** @description 数字字符串 */
   ratio: string;
   history_id: string;
   question: string;
};
export type ChatContent = {
   type: AnswerType;
   values: any;
   askMoreList?: ContextHistory[];
   errCode?: string;
   errMsg?: string;
   origin?: any;
   createTime?: string;
};
/**
 * mode 展示内容
 */
export type ModeContent = {
   type: string;
   mode: 'create_work_order';
   value: any;
};
export interface ChatMessage {
   historyId:string,
   historyId: string;
   role: RoleEnum;
   content?: ChatContent;
   state?: null | 1 | 0
   modeContent?: ModeContent;
   state?: null | '1' | '0';
   createTime?: string;
   stepGroup?: { value: StepItem[]; isShow: boolean }[];
   isStopMsg?: boolean;
   /** @description 是否被选择分享 */
   isChecked: boolean;
   conclusion?: any[];
   attachList?: Attach[];
}
export const roleImageMap = {
   [RoleEnum.user]: userPic,
   [RoleEnum.assistant]: assistantPic,
   [RoleEnum.system]: userPic,
};
export const enum StepEnum {
   Loading,
   Success,
   Error,
}
export const stepEnumMap = {
   [StepEnum.Loading]: 'process',
   [StepEnum.Success]: 'process',
   [StepEnum.Error]: 'process',
};
export const enum MultiChatType {
   Select = 'select',
   InputSelect = 'input-select',
   Summary = 'summary',
   Result = 'result',
   TimeRange = 'time_range',
}
type SubStep = {
   data: any;
   type: MultiChatType;
};
export type StepItem = {
   title: string;
   status: StepEnum;
   // 消耗时间
   ms?: string | number;
   subStep?: SubStep[];
   // isLoading?:boolean;
   /** @description 临时使用,控制强制不显示 loading */
   finishLoading?: boolean;
};