4.6.4-alpha (#569)
This commit is contained in:
22
packages/service/core/chat/controller.ts
Normal file
22
packages/service/core/chat/controller.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { ChatItemType } from '@fastgpt/global/core/chat/type';
|
||||
import { MongoChatItem } from './chatItemSchema';
|
||||
|
||||
export async function getChatItems({
|
||||
chatId,
|
||||
limit = 30,
|
||||
field
|
||||
}: {
|
||||
chatId?: string;
|
||||
limit?: number;
|
||||
field: string;
|
||||
}): Promise<{ history: ChatItemType[] }> {
|
||||
if (!chatId) {
|
||||
return { history: [] };
|
||||
}
|
||||
|
||||
const history = await MongoChatItem.find({ chatId }, field).sort({ _id: -1 }).limit(limit);
|
||||
|
||||
history.reverse();
|
||||
|
||||
return { history };
|
||||
}
|
||||
Reference in New Issue
Block a user