UNPKG

@lobehub/chat

Version:

Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.

23 lines (17 loc) 679 B
import { ChatMessage } from '@/types/message'; import { ThreadType } from '@/types/topic'; export const genMessage = ( messages: ChatMessage[], startMessageId: string | undefined, threadMode?: ThreadType, ) => { if (!startMessageId) return []; // 如果是独立话题模式,则只显示话题开始消息 if (threadMode === ThreadType.Standalone) { return messages.filter((m) => m.id === startMessageId); } // 如果是连续模式下,那么只显示话题开始消息和话题分割线 const targetIndex = messages.findIndex((item) => item.id === startMessageId); if (targetIndex < 0) return []; return messages.slice(0, targetIndex + 1); };