diff --git a/src/pages/api/chat/history/updateHistoryQuote.ts b/src/pages/api/chat/history/updateHistoryQuote.ts index d906cf932..2b2e9aba9 100644 --- a/src/pages/api/chat/history/updateHistoryQuote.ts +++ b/src/pages/api/chat/history/updateHistoryQuote.ts @@ -27,7 +27,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) }, { $set: { - 'content.$.quote.$[quoteElem].isEdit': true + 'content.$.quote.$[quoteElem].source': '手动修改' } }, { diff --git a/src/pages/api/chat/saveChat.ts b/src/pages/api/chat/saveChat.ts index 5a9736bbc..796a94c37 100644 --- a/src/pages/api/chat/saveChat.ts +++ b/src/pages/api/chat/saveChat.ts @@ -58,11 +58,7 @@ export async function saveChat({ obj: item.obj, value: item.value, systemPrompt: item.systemPrompt, - quote: - item.quote?.map((item) => ({ - ...item, - isEdit: false - })) || [] + quote: item.quote || [] })); const [id] = await Promise.all([ diff --git a/src/pages/api/openapi/kb/appKbSearch.ts b/src/pages/api/openapi/kb/appKbSearch.ts index 125e8007d..0adbcff4d 100644 --- a/src/pages/api/openapi/kb/appKbSearch.ts +++ b/src/pages/api/openapi/kb/appKbSearch.ts @@ -12,7 +12,7 @@ import { ChatRoleEnum } from '@/constants/chat'; import { openaiEmbedding } from '../plugin/openaiEmbedding'; import { modelToolMap } from '@/utils/plugin'; -export type QuoteItemType = { id: string; q: string; a: string; isEdit: boolean }; +export type QuoteItemType = { id: string; q: string; a: string; source?: string }; type Props = { prompts: ChatItemSimpleType[]; similarity: number; @@ -92,7 +92,7 @@ export async function appKbSearch({ // search kb const { rows: searchRes } = await PgClient.select('modelData', { - fields: ['id', 'q', 'a'], + fields: ['id', 'q', 'a', 'source'], where: [ `kb_id IN (${model.chat.relatedKbs.map((item) => `'${item}'`).join(',')})`, 'AND', diff --git a/src/pages/chat/components/QuoteModal.tsx b/src/pages/chat/components/QuoteModal.tsx index 3fca5169e..b1510268c 100644 --- a/src/pages/chat/components/QuoteModal.tsx +++ b/src/pages/chat/components/QuoteModal.tsx @@ -126,7 +126,7 @@ const QuoteModal = ({ position={'relative'} _hover={{ '& .edit': { display: 'flex' } }} > - {item.isEdit && (编辑过)} + {item.source && ({item.source})} {item.q} {item.a}