Spaces:
Running
Running
Pulastya B
commited on
Commit
Β·
5992afe
1
Parent(s):
c82abb7
Fix plot rendering: extract from workflow_history, remove debug code, update system prompt
Browse files
FRRONTEEEND/components/ChatInterface.tsx
CHANGED
|
@@ -135,7 +135,6 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 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,21 +143,9 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 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
|
| 152 |
-
if (result.plots && Array.isArray(result.plots)) {
|
| 153 |
-
plots = result.plots.map((plot: any) => ({
|
| 154 |
-
title: plot.title || 'Plot',
|
| 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
|
| 162 |
if (result.workflow_history) {
|
| 163 |
const reportTools = ['generate_ydata_profiling_report', 'generate_plotly_dashboard', 'generate_all_plots'];
|
| 164 |
const plotTools = [
|
|
@@ -232,8 +219,6 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 232 |
throw new Error('Invalid response from API');
|
| 233 |
}
|
| 234 |
|
| 235 |
-
console.log('π― Final message data - Reports:', reports.length, 'Plots:', plots.length);
|
| 236 |
-
|
| 237 |
updateSession(activeSessionId, [...newMessages, {
|
| 238 |
id: (Date.now() + 1).toString(),
|
| 239 |
role: 'assistant',
|
|
@@ -410,13 +395,6 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 410 |
ref={scrollRef}
|
| 411 |
className="flex-1 overflow-y-auto p-4 md:p-8 space-y-8 scroll-smooth"
|
| 412 |
>
|
| 413 |
-
{/* ALWAYS VISIBLE DEBUG */}
|
| 414 |
-
<div className="fixed top-20 right-4 bg-red-500 text-white p-4 rounded-lg z-50 text-xs">
|
| 415 |
-
π΄ Frontend Version: {Date.now()}<br/>
|
| 416 |
-
Messages: {activeSession.messages.length}<br/>
|
| 417 |
-
Last msg plots: {activeSession.messages[activeSession.messages.length - 1]?.plots?.length || 0}
|
| 418 |
-
</div>
|
| 419 |
-
|
| 420 |
{activeSession.messages.length === 0 ? (
|
| 421 |
<div className="h-full flex flex-col items-center justify-center text-center px-4">
|
| 422 |
<motion.div
|
|
@@ -516,22 +494,8 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 516 |
})}
|
| 517 |
</div>
|
| 518 |
)}
|
| 519 |
-
{/* DEBUG: Force show plots section */}
|
| 520 |
-
{msg.role === 'assistant' && msg.content?.includes('Visualizations') && (
|
| 521 |
-
<div className="mt-4 space-y-3 border-2 border-yellow-500">
|
| 522 |
-
<div className="text-xs font-semibold text-yellow-400 mb-2">
|
| 523 |
-
π DEBUG: Plots section (should appear if msg has Visualizations in content)
|
| 524 |
-
</div>
|
| 525 |
-
<div className="text-xs text-white/60">
|
| 526 |
-
msg.plots exists: {msg.plots ? 'YES' : 'NO'}<br/>
|
| 527 |
-
msg.plots length: {msg.plots?.length || 0}<br/>
|
| 528 |
-
msg.plots data: {JSON.stringify(msg.plots)}
|
| 529 |
-
</div>
|
| 530 |
-
</div>
|
| 531 |
-
)}
|
| 532 |
{msg.plots && msg.plots.length > 0 && (
|
| 533 |
<>
|
| 534 |
-
{console.log('π¨ Rendering plots for message:', msg.id, msg.plots)}
|
| 535 |
<div className="mt-4 space-y-3">
|
| 536 |
<div className="text-xs font-semibold text-white/60 mb-2">
|
| 537 |
π Generated Visualizations ({msg.plots.length})
|
|
|
|
| 135 |
}
|
| 136 |
|
| 137 |
const data = await response.json();
|
|
|
|
| 138 |
|
| 139 |
let assistantContent = '';
|
| 140 |
let reports: Array<{name: string, path: string}> = [];
|
|
|
|
| 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 workflow_history (PRIMARY SOURCE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
if (result.workflow_history) {
|
| 150 |
const reportTools = ['generate_ydata_profiling_report', 'generate_plotly_dashboard', 'generate_all_plots'];
|
| 151 |
const plotTools = [
|
|
|
|
| 219 |
throw new Error('Invalid response from API');
|
| 220 |
}
|
| 221 |
|
|
|
|
|
|
|
| 222 |
updateSession(activeSessionId, [...newMessages, {
|
| 223 |
id: (Date.now() + 1).toString(),
|
| 224 |
role: 'assistant',
|
|
|
|
| 395 |
ref={scrollRef}
|
| 396 |
className="flex-1 overflow-y-auto p-4 md:p-8 space-y-8 scroll-smooth"
|
| 397 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
{activeSession.messages.length === 0 ? (
|
| 399 |
<div className="h-full flex flex-col items-center justify-center text-center px-4">
|
| 400 |
<motion.div
|
|
|
|
| 494 |
})}
|
| 495 |
</div>
|
| 496 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
{msg.plots && msg.plots.length > 0 && (
|
| 498 |
<>
|
|
|
|
| 499 |
<div className="mt-4 space-y-3">
|
| 500 |
<div className="text-xs font-semibold text-white/60 mb-2">
|
| 501 |
π Generated Visualizations ({msg.plots.length})
|
src/orchestrator.py
CHANGED
|
@@ -405,6 +405,13 @@ class DataScienceCopilot:
|
|
| 405 |
"""Build comprehensive system prompt for the copilot."""
|
| 406 |
return """You are an autonomous Data Science Agent. You EXECUTE tasks, not advise.
|
| 407 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
**CRITICAL: Tool Calling Format**
|
| 409 |
When you need to use a tool, respond with a JSON block like this:
|
| 410 |
```json
|
|
|
|
| 405 |
"""Build comprehensive system prompt for the copilot."""
|
| 406 |
return """You are an autonomous Data Science Agent. You EXECUTE tasks, not advise.
|
| 407 |
|
| 408 |
+
**CRITICAL: User Interface Integration**
|
| 409 |
+
- The user interface automatically displays clickable buttons for all generated plots, reports, and outputs
|
| 410 |
+
- DO NOT mention file paths (e.g., "./outputs/plots/...") in your responses
|
| 411 |
+
- DO NOT say "Output File: ..." or "Saved to: ..." - users can click buttons to view outputs
|
| 412 |
+
- Simply describe what was created and what insights it shows
|
| 413 |
+
- Example: Instead of "π Output File: ./outputs/plots/heatmap.html", say "Generated an interactive correlation heatmap showing relationships between variables"
|
| 414 |
+
|
| 415 |
**CRITICAL: Tool Calling Format**
|
| 416 |
When you need to use a tool, respond with a JSON block like this:
|
| 417 |
```json
|