Files
FastGPT/projects/app/src/service/moduleDispatch/utils.ts
2023-12-12 14:42:20 +08:00

10 lines
331 B
TypeScript

import type { ChatItemType } from '@fastgpt/global/core/chat/type.d';
export const getHistories = (history?: ChatItemType[] | number, histories: ChatItemType[] = []) => {
if (!history) return [];
if (typeof history === 'number') return histories.slice(-history);
if (Array.isArray(history)) return history;
return [];
};