Spaces:
Runtime error
Runtime error
File size: 4,826 Bytes
d5a7540 a16ae54 d5a7540 6310132 a16ae54 d5a7540 2bc3ce0 d5a7540 a16ae54 d5a7540 a16ae54 d5a7540 a16ae54 |
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 |
"""
Agent workflow UI component for the pharmaceutical data management agent.
"""
import streamlit as st
def render_workflow_tab(session_state):
"""
Render the agent workflow visualization tab in the UI.
Args:
session_state: Streamlit session state
"""
st.subheader("Agent Workflow Visualization")
# Display current agent and status - ensure it's consistent
current_agent = session_state.conversation.get("current_agent", "understanding_agent")
status = session_state.conversation.get("status", "planning")
st.markdown(f"**Current State:** {status.title()}")
st.markdown(f"**Current Agent:** {current_agent.replace('_', ' ').title()}")
# Visualize the workflow
col1, col2, col3, col4 = st.columns(4)
# Determine which agent is active
understanding_active = current_agent == "understanding_agent"
planning_active = current_agent == "planning_agent"
sql_active = current_agent == "sql_generator_agent"
executor_active = current_agent == "executor_agent"
# Show the workflow visualization
with col1:
if understanding_active:
st.markdown("### π **Understanding**")
else:
st.markdown("### π Understanding")
st.markdown("Extracts user intent and asks clarification questions")
if "user_intent" in session_state.conversation and session_state.conversation["user_intent"]:
st.success("Completed")
elif understanding_active:
st.info("In Progress")
else:
st.warning("Not Started")
with col2:
if planning_active:
st.markdown("### π **Planning**")
else:
st.markdown("### π Planning")
st.markdown("Creates data pipeline plan with sources and transformations")
if "pipeline_plan" in session_state.conversation and session_state.conversation["pipeline_plan"]:
st.success("Completed")
elif planning_active:
st.info("In Progress")
elif understanding_active:
st.warning("Not Started")
else:
st.success("Completed")
with col3:
if sql_active:
st.markdown("### π» **SQL Generation**")
else:
st.markdown("### π» SQL Generation")
st.markdown("Converts plan into executable SQL queries")
if "sql_queries" in session_state.conversation and session_state.conversation["sql_queries"]:
st.success("Completed")
elif sql_active:
st.info("In Progress")
elif understanding_active or planning_active:
st.warning("Not Started")
else:
st.success("Completed")
with col4:
if executor_active:
st.markdown("### βοΈ **Execution**")
else:
st.markdown("### βοΈ Execution")
st.markdown("Executes queries and reports results")
if "execution_results" in session_state.conversation and session_state.conversation["execution_results"]:
st.success("Completed")
elif executor_active:
st.info("In Progress")
elif understanding_active or planning_active or sql_active:
st.warning("Not Started")
else:
st.success("Completed")
# Overall confidence score
if "confidence_scores" in session_state.conversation and "overall" in session_state.conversation["confidence_scores"]:
st.markdown("### Overall Pipeline Confidence")
score = session_state.conversation["confidence_scores"]["overall"] * 100
st.progress(score / 100, text=f"{score:.1f}%")
# Workflow decision points
if status == "complete":
if score > 80:
st.success("β
High confidence - Pipeline can be deployed automatically")
else:
st.warning("β οΈ Medium confidence - Human review recommended before deployment")
# Add human review section for pending approval status
if status == "pending_approval":
st.markdown("### π€ Human Review Required")
st.info("This pipeline requires human review before deployment")
col1, col2 = st.columns(2)
with col1:
if st.button("β
Approve Pipeline"):
# Update state to approved
session_state.conversation["status"] = "approved"
# Trigger execution to continue
st.rerun()
with col2:
if st.button("β Reject Pipeline"):
# Update state to rejected
session_state.conversation["status"] = "rejected"
st.error("Pipeline rejected. Please provide feedback to refine the pipeline.") |