import React from 'react'; import { observer } from 'mobx-react'; import { AssistantMessage, Citation } from './types'; interface MessageComponentProps { message: AssistantMessage; index: number; onFollowUpClick: (question: string) => void; onCitationClick: (citation: Citation) => void; updateMessageCitations: (index: number, citations: Citation[]) => void; } const MessageComponentBox: React.FC = function ({ message, index, onFollowUpClick, onCitationClick, updateMessageCitations }) { const renderContent = (content: string) => { if (!message.citations || message.citations.length === 0) { return content; } const parts = []; let lastIndex = 0; message.citations.forEach((citation, idx) => { const location = citation.text_location; const textBefore = content.slice(lastIndex, location); const citationButton = ( ); parts.push(textBefore, citationButton); lastIndex = location; }); parts.push(content.slice(lastIndex)); return parts; }; return (
{renderContent(message.text_content)}
{message.follow_up_questions && message.follow_up_questions.length > 0 && (

Follow-up Questions:

{message.follow_up_questions.map((question, idx) => ( ))}
)}
); }; export default observer(MessageComponentBox);