Spaces:
Running
Running
Pulastya B
commited on
Commit
·
d6ba760
1
Parent(s):
943877f
fix: Show report view buttons for all analysis responses
Browse files- Remove uploadedFile condition from report detection
- Detect reports in any /run endpoint response
- Fixes missing view button for ydata_profiling reports
- Report buttons now appear after analysis completes
FRRONTEEEND/components/ChatInterface.tsx
CHANGED
|
@@ -76,10 +76,30 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 76 |
|
| 77 |
let response;
|
| 78 |
|
| 79 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
const formData = new FormData();
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
formData.append('use_cache', 'true');
|
| 84 |
formData.append('max_iterations', '20');
|
| 85 |
|
|
@@ -114,7 +134,8 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 114 |
let assistantContent = '';
|
| 115 |
let reports: Array<{name: string, path: string}> = [];
|
| 116 |
|
| 117 |
-
|
|
|
|
| 118 |
const result = data.result;
|
| 119 |
assistantContent = `✅ Analysis Complete!\n\n`;
|
| 120 |
|
|
|
|
| 76 |
|
| 77 |
let response;
|
| 78 |
|
| 79 |
+
// Check if there's a recent file analysis in the conversation
|
| 80 |
+
const recentFileMessage = newMessages.slice(-5).find(m => m.file || m.content.includes('Uploaded:'));
|
| 81 |
+
const hasRecentFile = recentFileMessage && !uploadedFile;
|
| 82 |
+
|
| 83 |
+
if (uploadedFile || hasRecentFile) {
|
| 84 |
+
// Use /run endpoint for file analysis or follow-up questions about uploaded data
|
| 85 |
const formData = new FormData();
|
| 86 |
+
|
| 87 |
+
if (uploadedFile) {
|
| 88 |
+
formData.append('file', uploadedFile);
|
| 89 |
+
formData.append('task_description', input || 'Analyze this dataset and provide insights');
|
| 90 |
+
} else if (hasRecentFile) {
|
| 91 |
+
// For follow-up questions, extract the filename from recent context
|
| 92 |
+
const fileNameMatch = recentFileMessage?.content.match(/Uploaded: (.+)/);
|
| 93 |
+
const fileName = fileNameMatch ? fileNameMatch[1] : 'dataset.csv';
|
| 94 |
+
|
| 95 |
+
// Send follow-up request as a new task description
|
| 96 |
+
formData.append('task_description', input);
|
| 97 |
+
formData.append('session_id', activeSessionId);
|
| 98 |
+
|
| 99 |
+
// Note: Backend needs to support session-based file context
|
| 100 |
+
// For now, just send the task which should work with session memory
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
formData.append('use_cache', 'true');
|
| 104 |
formData.append('max_iterations', '20');
|
| 105 |
|
|
|
|
| 134 |
let assistantContent = '';
|
| 135 |
let reports: Array<{name: string, path: string}> = [];
|
| 136 |
|
| 137 |
+
// Check for reports in any /run endpoint response (not just when file is uploaded)
|
| 138 |
+
if (data.result) {
|
| 139 |
const result = data.result;
|
| 140 |
assistantContent = `✅ Analysis Complete!\n\n`;
|
| 141 |
|