import { ToolCallTypes, ContentTypes, imageGenTools } from 'librechat-data-provider'; import type { TMessageContentParts, TMessage } from 'librechat-data-provider'; import type { TDisplayProps } from '~/common'; import RetrievalCall from './RetrievalCall'; import CodeAnalyze from './CodeAnalyze'; import Container from './Container'; import ToolCall from './ToolCall'; import Markdown from './Markdown'; import ImageGen from './ImageGen'; import Image from './Image'; import { cn } from '~/utils'; // import EditMessage from './EditMessage'; // Display Message Component const DisplayMessage = ({ text, isCreatedByUser = false, message, showCursor }: TDisplayProps) => { return (
{!isCreatedByUser ? ( ) : ( <>{text} )}
); }; export default function Part({ part, showCursor, isSubmitting, message, }: { part: TMessageContentParts; isSubmitting: boolean; showCursor: boolean; message: TMessage; }) { if (!part) { return null; } if (part.type === ContentTypes.TEXT) { // Access the value property return (
); } else if ( part.type === ContentTypes.TOOL_CALL && part[ContentTypes.TOOL_CALL].type === ToolCallTypes.CODE_INTERPRETER ) { const toolCall = part[ContentTypes.TOOL_CALL]; const code_interpreter = toolCall[ToolCallTypes.CODE_INTERPRETER]; return ( ); } else if ( part.type === ContentTypes.TOOL_CALL && part[ContentTypes.TOOL_CALL].type === ToolCallTypes.RETRIEVAL ) { const toolCall = part[ContentTypes.TOOL_CALL]; return ; } else if ( part.type === ContentTypes.TOOL_CALL && part[ContentTypes.TOOL_CALL].type === ToolCallTypes.FUNCTION && imageGenTools.has(part[ContentTypes.TOOL_CALL].function.name) ) { const toolCall = part[ContentTypes.TOOL_CALL]; return ( ); } else if ( part.type === ContentTypes.TOOL_CALL && part[ContentTypes.TOOL_CALL].type === ToolCallTypes.FUNCTION ) { const toolCall = part[ContentTypes.TOOL_CALL]; return ( ); } else if (part.type === ContentTypes.IMAGE_FILE) { const imageFile = part[ContentTypes.IMAGE_FILE]; const height = imageFile.height ?? 1920; const width = imageFile.width ?? 1080; return ( ); } return null; }