+ {/* 如果没有Session,显示上传区域 */}
+ {!hasSession ? (
+
+
+
+
+
+
+
上传数据文件
+
+ 支持 CSV、Excel 格式
最大 10MB
+
+
+
{
+ const file = e.target.files?.[0];
+ if (file) onFileUpload(file);
+ }}
+ className="hidden"
+ id="file-upload-sidebar"
+ />
+
+
+
+ ) : (
+ // 如果有Session,显示简化的消息列表
+
+ {messages.length === 0 && (
+
+
👋 您好!我是您的AI数据分析师
+
试试说:"把age列的缺失值填补为中位数"
+
+ )}
+ {messages.map((msg) => (
+
+ {msg.content}
+
+ ))}
+ {isLoading && (
+
+ )}
+
+ )}
+
+ {/* 输入区域 */}
+ {hasSession && (
+
+
+ {
+ if (e.key === 'Enter' && e.currentTarget.value.trim()) {
+ onSendMessage(e.currentTarget.value);
+ e.currentTarget.value = '';
+ }
+ }}
+ disabled={isLoading}
+ />
+
+
+
+ 按 Enter 发送消息
+
+
+ )}
+