Spaces:
Running
Running
File size: 8,840 Bytes
0913c52 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
"""
Display Components for Streamlit Interface
Reusable components for displaying workflow outputs.
"""
import streamlit as st
from workflow_monitor import PhaseType, ProgressUpdate
def display_phase_header(phase_name: str, status: str = "running", icon: str = "π"):
"""Display a phase header with status."""
status_colors = {
"running": "π",
"completed": "β
",
"error": "β",
"pending": "β³",
}
status_icon = status_colors.get(status, "π")
st.markdown(f"### {icon} {phase_name} {status_icon}")
def display_ideation_progress(workflow_data: dict):
"""Display ideation agent progress."""
with st.expander("π‘ Research Ideation", expanded=True):
cols = st.columns(4)
with cols[0]:
papers_count = len(workflow_data.get("ideation_papers", []))
st.metric("Papers Found", papers_count)
with cols[1]:
ideas_count = len(workflow_data.get("research_ideas", []))
st.metric("Ideas Generated", ideas_count)
with cols[2]:
novelty = workflow_data.get("novelty_score")
if novelty:
st.metric("Novelty Score", f"{novelty:.1f}/10")
else:
st.metric("Novelty Score", "Pending")
with cols[3]:
status = workflow_data.get("ideation_status", "Running")
st.info(status)
# Show ideation summary if available
if workflow_data.get("ideation_summary"):
st.markdown("**Summary:**")
st.markdown(workflow_data["ideation_summary"][:500] + "...")
# Show papers
if workflow_data.get("ideation_papers"):
with st.expander("π Papers Reviewed", expanded=False):
for i, paper in enumerate(workflow_data["ideation_papers"][:5], 1):
st.markdown(f"**{i}. {paper.get('title', 'Untitled')}**")
if paper.get("abstract"):
st.caption(paper["abstract"][:200] + "...")
def display_data_agent_progress(workflow_data: dict):
"""Display data agent progress."""
with st.expander("π Data Analysis", expanded=True):
cols = st.columns(4)
with cols[0]:
papers_count = len(workflow_data.get("papers", []))
st.metric("Papers Found", papers_count)
with cols[1]:
datasets_count = len(workflow_data.get("datasets", []))
st.metric("Datasets Found", datasets_count)
with cols[2]:
metrics_count = len(workflow_data.get("metrics", []))
st.metric("Metrics Found", metrics_count)
with cols[3]:
status = workflow_data.get("data_status", "Running")
st.info(status)
# Show data summary if available
if workflow_data.get("data_summary"):
st.markdown("**Data Summary:**")
st.markdown(workflow_data["data_summary"][:500] + "...")
# Show paper search summary
if workflow_data.get("paper_search_summary"):
with st.expander("π Paper Search Summary", expanded=False):
st.markdown(workflow_data["paper_search_summary"])
def display_experiment_progress(workflow_data: dict):
"""Display experiment agent progress."""
with st.expander("π§ͺ Experiment Execution", expanded=True):
# Revision info
current_rev = workflow_data.get("current_revision", 0)
max_rev = workflow_data.get("max_revisions", 5)
current_phase = workflow_data.get("current_phase", "init")
cols = st.columns(3)
with cols[0]:
st.metric("Current Revision", f"{current_rev + 1}/{max_rev}")
with cols[1]:
st.metric("Current Phase", current_phase)
with cols[2]:
results_count = len(workflow_data.get("execution_results", []))
st.metric("Execution Results", results_count)
# Show revision summaries
if workflow_data.get("revision_summaries"):
with st.expander("π Revision History", expanded=False):
for i, summary in enumerate(workflow_data["revision_summaries"], 1):
st.markdown(f"**Revision {i}:**")
st.markdown(summary[:300] + "...")
st.markdown("---")
def display_progress_updates(updates: list[ProgressUpdate]):
"""Display a timeline of progress updates."""
with st.expander("π Progress Log", expanded=False):
for update in reversed(updates[-20:]): # Show last 20 updates
timestamp = time.strftime("%H:%M:%S", time.localtime(update.timestamp))
# Status icon
status_icons = {
"started": "π",
"progress": "β³",
"completed": "β
",
"error": "β",
}
icon = status_icons.get(update.status, "βΉοΈ")
# Phase name
phase_names = {
PhaseType.IDEATION_LITERATURE_SEARCH: "Literature Search",
PhaseType.IDEATION_ANALYZE_PAPERS: "Analyzing Papers",
PhaseType.IDEATION_GENERATE_IDEAS: "Generating Ideas",
PhaseType.IDEATION_NOVELTY_CHECK: "Novelty Check",
PhaseType.IDEATION_REPORT: "Ideation Report",
PhaseType.DATA_PLANNING: "Data Planning",
PhaseType.DATA_EXECUTION: "Data Execution",
PhaseType.DATA_PAPER_SEARCH: "Paper Search",
PhaseType.DATA_FINALIZE: "Data Finalize",
PhaseType.EXPERIMENT_INIT: "Experiment Init",
PhaseType.EXPERIMENT_CODING: "Coding",
PhaseType.EXPERIMENT_EXEC: "Execution",
PhaseType.EXPERIMENT_SUMMARY: "Summary",
PhaseType.EXPERIMENT_ANALYSIS: "Analysis",
PhaseType.EXPERIMENT_REVISION: "Revision",
PhaseType.COMPLETE: "Complete",
PhaseType.ERROR: "Error",
}
phase_name = phase_names.get(update.phase, str(update.phase))
st.markdown(f"`{timestamp}` {icon} **{phase_name}**: {update.message}")
def display_final_results(workflow):
"""Display final workflow results."""
st.markdown("## π Final Results")
# Overall status
status_icon = "β
" if workflow.final_status == "success" else "β"
st.markdown(f"### {status_icon} Status: {workflow.final_status}")
# Tabs for different result sections
tabs = st.tabs(["Summary", "Ideation", "Data Analysis", "Experiments", "Raw Data"])
with tabs[0]:
st.markdown("### Complete Summary")
st.markdown(workflow.final_summary)
with tabs[1]:
st.markdown("### Research Ideation Results")
if workflow.ideation_summary:
st.markdown(workflow.ideation_summary)
if workflow.novelty_score:
st.metric("Novelty Score", f"{workflow.novelty_score:.2f}/10")
if workflow.novelty_feedback:
st.markdown("**Novelty Feedback:**")
st.info(workflow.novelty_feedback)
if workflow.ideation_papers:
st.markdown(f"**Papers Reviewed:** {len(workflow.ideation_papers)}")
with st.expander("Show Papers"):
st.json(workflow.ideation_papers)
with tabs[2]:
st.markdown("### Data Analysis Results")
if workflow.data_summary:
st.markdown(workflow.data_summary)
cols = st.columns(3)
with cols[0]:
st.metric("Papers Found", len(workflow.papers))
with cols[1]:
st.metric("Datasets Found", len(workflow.datasets))
with cols[2]:
st.metric("Metrics Found", len(workflow.metrics))
if workflow.paper_search_summary:
with st.expander("Paper Search Summary"):
st.markdown(workflow.paper_search_summary)
with tabs[3]:
st.markdown("### Experiment Execution Results")
if workflow.execution_results:
st.markdown(f"**Total Executions:** {len(workflow.execution_results)}")
for i, result in enumerate(workflow.execution_results, 1):
with st.expander(f"Execution {i}"):
st.json(result)
with tabs[4]:
st.markdown("### Raw Workflow Data")
st.json(
{
"current_phase": workflow.current_phase,
"final_status": workflow.final_status,
"workspace_path": str(workflow.workspace_path),
"session_name": workflow.session_name,
"run_data_workflow": workflow.run_data_workflow,
"run_experiment_workflow": workflow.run_experiment_workflow,
}
)
import time
|