balibabu
feat: rename conversation and delete conversation and preview reference image and fetch file thumbnails (#79)
6a6f6eb
| import { IConversation, IReference } from '@/interfaces/database/chat'; | |
| import { EmptyConversationId, variableEnabledFieldMap } from './constants'; | |
| export const excludeUnEnabledVariables = (values: any) => { | |
| const unEnabledFields: Array<keyof typeof variableEnabledFieldMap> = | |
| Object.keys(variableEnabledFieldMap).filter((key) => !values[key]) as Array< | |
| keyof typeof variableEnabledFieldMap | |
| >; | |
| return unEnabledFields.map( | |
| (key) => `llm_setting.${variableEnabledFieldMap[key]}`, | |
| ); | |
| }; | |
| export const isConversationIdExist = (conversationId: string) => { | |
| return conversationId !== EmptyConversationId && conversationId !== ''; | |
| }; | |
| export const getDocumentIdsFromConversionReference = (data: IConversation) => { | |
| const documentIds = data.reference.reduce( | |
| (pre: Array<string>, cur: IReference) => { | |
| cur.doc_aggs | |
| .map((x) => x.doc_id) | |
| .forEach((x) => { | |
| if (pre.every((y) => y !== x)) { | |
| pre.push(x); | |
| } | |
| }); | |
| return pre; | |
| }, | |
| [], | |
| ); | |
| return documentIds.join(','); | |
| }; | |