mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
feat: quote source
This commit is contained in:
@@ -27,7 +27,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
'content.$.quote.$[quoteElem].isEdit': true
|
'content.$.quote.$[quoteElem].source': '手动修改'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@@ -58,11 +58,7 @@ export async function saveChat({
|
|||||||
obj: item.obj,
|
obj: item.obj,
|
||||||
value: item.value,
|
value: item.value,
|
||||||
systemPrompt: item.systemPrompt,
|
systemPrompt: item.systemPrompt,
|
||||||
quote:
|
quote: item.quote || []
|
||||||
item.quote?.map((item) => ({
|
|
||||||
...item,
|
|
||||||
isEdit: false
|
|
||||||
})) || []
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const [id] = await Promise.all([
|
const [id] = await Promise.all([
|
||||||
|
@@ -12,7 +12,7 @@ import { ChatRoleEnum } from '@/constants/chat';
|
|||||||
import { openaiEmbedding } from '../plugin/openaiEmbedding';
|
import { openaiEmbedding } from '../plugin/openaiEmbedding';
|
||||||
import { modelToolMap } from '@/utils/plugin';
|
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 = {
|
type Props = {
|
||||||
prompts: ChatItemSimpleType[];
|
prompts: ChatItemSimpleType[];
|
||||||
similarity: number;
|
similarity: number;
|
||||||
@@ -92,7 +92,7 @@ export async function appKbSearch({
|
|||||||
|
|
||||||
// search kb
|
// search kb
|
||||||
const { rows: searchRes } = await PgClient.select<QuoteItemType>('modelData', {
|
const { rows: searchRes } = await PgClient.select<QuoteItemType>('modelData', {
|
||||||
fields: ['id', 'q', 'a'],
|
fields: ['id', 'q', 'a', 'source'],
|
||||||
where: [
|
where: [
|
||||||
`kb_id IN (${model.chat.relatedKbs.map((item) => `'${item}'`).join(',')})`,
|
`kb_id IN (${model.chat.relatedKbs.map((item) => `'${item}'`).join(',')})`,
|
||||||
'AND',
|
'AND',
|
||||||
|
@@ -126,7 +126,7 @@ const QuoteModal = ({
|
|||||||
position={'relative'}
|
position={'relative'}
|
||||||
_hover={{ '& .edit': { display: 'flex' } }}
|
_hover={{ '& .edit': { display: 'flex' } }}
|
||||||
>
|
>
|
||||||
{item.isEdit && <Box color={'myGray.600'}>(编辑过)</Box>}
|
{item.source && <Box color={'myGray.600'}>({item.source})</Box>}
|
||||||
<Box>{item.q}</Box>
|
<Box>{item.q}</Box>
|
||||||
<Box>{item.a}</Box>
|
<Box>{item.a}</Box>
|
||||||
<Box
|
<Box
|
||||||
|
@@ -60,7 +60,7 @@ const ChatSchema = new Schema({
|
|||||||
id: String,
|
id: String,
|
||||||
q: String,
|
q: String,
|
||||||
a: String,
|
a: String,
|
||||||
isEdit: Boolean
|
source: String
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
default: []
|
default: []
|
||||||
|
Reference in New Issue
Block a user