mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
Update rearanker code url. Add chat storage ip address (#717)
* save chat origin ip * reranker code url
This commit is contained in:
@@ -69,6 +69,8 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
|
||||
} = req.body as Props;
|
||||
|
||||
try {
|
||||
const originIp = requestIp.getClientIp(req);
|
||||
|
||||
await connectToDatabase();
|
||||
// body data check
|
||||
if (!messages) {
|
||||
@@ -99,7 +101,7 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
|
||||
if (shareId && outLinkUid) {
|
||||
const { user, appId, authType, responseDetail, uid } = await authOutLinkChatStart({
|
||||
shareId,
|
||||
ip: requestIp.getClientIp(req),
|
||||
ip: originIp,
|
||||
outLinkUid,
|
||||
question: question.value
|
||||
});
|
||||
@@ -245,7 +247,10 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
|
||||
value: answerText,
|
||||
responseData
|
||||
}
|
||||
]
|
||||
],
|
||||
metadata: {
|
||||
originIp
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,7 @@ type Props = {
|
||||
shareId?: string;
|
||||
outLinkUid?: string;
|
||||
content: [ChatItemType, ChatItemType];
|
||||
metadata?: Record<string, any>;
|
||||
};
|
||||
|
||||
export async function saveChat({
|
||||
@@ -29,7 +30,8 @@ export async function saveChat({
|
||||
source,
|
||||
shareId,
|
||||
outLinkUid,
|
||||
content
|
||||
content,
|
||||
metadata = {}
|
||||
}: Props) {
|
||||
try {
|
||||
const chat = await MongoChat.findOne(
|
||||
@@ -39,9 +41,14 @@ export async function saveChat({
|
||||
tmbId,
|
||||
appId
|
||||
},
|
||||
'_id'
|
||||
'_id metadata'
|
||||
);
|
||||
|
||||
const metadataUpdate = {
|
||||
...chat?.metadata,
|
||||
...metadata
|
||||
};
|
||||
|
||||
const promise: any[] = [
|
||||
MongoChatItem.insertMany(
|
||||
content.map((item) => ({
|
||||
@@ -53,6 +60,7 @@ export async function saveChat({
|
||||
}))
|
||||
)
|
||||
];
|
||||
console.log(metadataUpdate);
|
||||
|
||||
const title =
|
||||
chatContentReplaceBlock(content[0].value).slice(0, 20) ||
|
||||
@@ -65,7 +73,8 @@ export async function saveChat({
|
||||
{ chatId },
|
||||
{
|
||||
title,
|
||||
updateTime: new Date()
|
||||
updateTime: new Date(),
|
||||
metadata: metadataUpdate
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -80,7 +89,8 @@ export async function saveChat({
|
||||
title,
|
||||
source,
|
||||
shareId,
|
||||
outLinkUid
|
||||
outLinkUid,
|
||||
metadata: metadataUpdate
|
||||
})
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user