Spaces:
Running
Running
Pulastya B
commited on
Commit
Β·
7ea590f
1
Parent(s):
f898051
debug: Add console logging for plot extraction
Browse files- Log API response structure
- Log plots extraction from result
- Log when plots are added to message
- Log when rendering plot buttons
- Will help identify where plot data is lost
FRRONTEEEND/components/ChatInterface.tsx
CHANGED
|
@@ -135,6 +135,7 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 135 |
}
|
| 136 |
|
| 137 |
const data = await response.json();
|
|
|
|
| 138 |
|
| 139 |
let assistantContent = '';
|
| 140 |
let reports: Array<{name: string, path: string}> = [];
|
|
@@ -143,6 +144,8 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 143 |
// Check for reports in any /run endpoint response (not just when file is uploaded)
|
| 144 |
if (data.result) {
|
| 145 |
const result = data.result;
|
|
|
|
|
|
|
| 146 |
assistantContent = `β
Analysis Complete!\n\n`;
|
| 147 |
|
| 148 |
// Extract plots from result
|
|
@@ -152,6 +155,7 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 152 |
url: plot.url || plot.path?.replace('./outputs/', '/outputs/'),
|
| 153 |
type: (plot.url || plot.path)?.endsWith('.html') ? 'html' : 'image'
|
| 154 |
}));
|
|
|
|
| 155 |
}
|
| 156 |
|
| 157 |
// Extract report paths from workflow history
|
|
@@ -197,6 +201,8 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 197 |
throw new Error('Invalid response from API');
|
| 198 |
}
|
| 199 |
|
|
|
|
|
|
|
| 200 |
updateSession(activeSessionId, [...newMessages, {
|
| 201 |
id: (Date.now() + 1).toString(),
|
| 202 |
role: 'assistant',
|
|
@@ -473,12 +479,14 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 473 |
</div>
|
| 474 |
)}
|
| 475 |
{msg.plots && msg.plots.length > 0 && (
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
|
|
|
|
|
|
| 482 |
<button
|
| 483 |
key={idx}
|
| 484 |
onClick={() => setReportModalUrl(`${window.location.origin}${plot.url}`)}
|
|
@@ -492,6 +500,7 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 492 |
))}
|
| 493 |
</div>
|
| 494 |
</div>
|
|
|
|
| 495 |
)}
|
| 496 |
<div className="mt-2 text-[10px] opacity-20 font-mono">
|
| 497 |
{msg.timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
|
|
|
|
| 135 |
}
|
| 136 |
|
| 137 |
const data = await response.json();
|
| 138 |
+
console.log('π API Response:', JSON.stringify(data, null, 2));
|
| 139 |
|
| 140 |
let assistantContent = '';
|
| 141 |
let reports: Array<{name: string, path: string}> = [];
|
|
|
|
| 144 |
// Check for reports in any /run endpoint response (not just when file is uploaded)
|
| 145 |
if (data.result) {
|
| 146 |
const result = data.result;
|
| 147 |
+
console.log('π Plots in result:', result.plots);
|
| 148 |
+
console.log('π Artifacts in result:', result.artifacts);
|
| 149 |
assistantContent = `β
Analysis Complete!\n\n`;
|
| 150 |
|
| 151 |
// Extract plots from result
|
|
|
|
| 155 |
url: plot.url || plot.path?.replace('./outputs/', '/outputs/'),
|
| 156 |
type: (plot.url || plot.path)?.endsWith('.html') ? 'html' : 'image'
|
| 157 |
}));
|
| 158 |
+
console.log('β
Extracted plots:', plots);
|
| 159 |
}
|
| 160 |
|
| 161 |
// Extract report paths from workflow history
|
|
|
|
| 201 |
throw new Error('Invalid response from API');
|
| 202 |
}
|
| 203 |
|
| 204 |
+
console.log('π― Final message data - Reports:', reports.length, 'Plots:', plots.length);
|
| 205 |
+
|
| 206 |
updateSession(activeSessionId, [...newMessages, {
|
| 207 |
id: (Date.now() + 1).toString(),
|
| 208 |
role: 'assistant',
|
|
|
|
| 479 |
</div>
|
| 480 |
)}
|
| 481 |
{msg.plots && msg.plots.length > 0 && (
|
| 482 |
+
<>
|
| 483 |
+
{console.log('π¨ Rendering plots for message:', msg.id, msg.plots)}
|
| 484 |
+
<div className="mt-4 space-y-3">
|
| 485 |
+
<div className="text-xs font-semibold text-white/60 mb-2">
|
| 486 |
+
π Generated Visualizations ({msg.plots.length})
|
| 487 |
+
</div>
|
| 488 |
+
<div className="flex flex-wrap gap-2">
|
| 489 |
+
{msg.plots.map((plot, idx) => (
|
| 490 |
<button
|
| 491 |
key={idx}
|
| 492 |
onClick={() => setReportModalUrl(`${window.location.origin}${plot.url}`)}
|
|
|
|
| 500 |
))}
|
| 501 |
</div>
|
| 502 |
</div>
|
| 503 |
+
</>
|
| 504 |
)}
|
| 505 |
<div className="mt-2 text-[10px] opacity-20 font-mono">
|
| 506 |
{msg.timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
|