Spaces:
Sleeping
Sleeping
Commit
Β·
be6f776
1
Parent(s):
e83ea81
ui correction for display
Browse files
src/langgraphagenticai/ui/streamlitui/display_result.py
CHANGED
|
@@ -15,6 +15,26 @@ class DisplayResultStreamlit:
|
|
| 15 |
self.graph = graph
|
| 16 |
self.user_message = user_message
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def display_result_on_ui(self):
|
| 19 |
usecase= self.usecase
|
| 20 |
graph = self.graph
|
|
@@ -125,58 +145,41 @@ class DisplayResultStreamlit:
|
|
| 125 |
st.session_state.graph_config = {"configurable": {"thread_id": uuid.uuid4()}}
|
| 126 |
|
| 127 |
# Create a placeholder to show output or interrupts.
|
| 128 |
-
output_placeholder = st.empty()
|
| 129 |
-
|
| 130 |
ui = SDLCUI()
|
| 131 |
col1, col2 = st.columns(2) # Create two columns
|
| 132 |
st.session_state.state['Final_Result'] = []
|
| 133 |
if 'Final_Result' not in st.session_state:
|
| 134 |
st.session_state['Final_Result'] = []
|
| 135 |
-
with col1:
|
| 136 |
-
st.subheader('Final Result')
|
| 137 |
-
|
| 138 |
-
with col2:
|
| 139 |
-
st.subheader('human in loop : __interrupt__')
|
| 140 |
if st.session_state.graph_stage =='initial' and 'current_step' in st.session_state.state and st.session_state.state['current_step']!='' :
|
| 141 |
graph_stream = graph.stream(st.session_state["state"], config=st.session_state.graph_config )
|
| 142 |
if graph_stream:
|
| 143 |
|
| 144 |
for event in graph_stream:
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
if d:
|
| 150 |
-
for key, value in d.items():
|
| 151 |
-
with st.expander(label=key):
|
| 152 |
-
st.markdown(value)
|
| 153 |
-
with col2:
|
| 154 |
-
if "__interrupt__" in event:
|
| 155 |
-
st.session_state.graph_stage = "waiting"
|
| 156 |
-
st.rerun()
|
| 157 |
-
break
|
| 158 |
else:
|
| 159 |
st.session_state.graph_stage = "finished"
|
| 160 |
# --- Stage 2: Display Human Input UI ---
|
| 161 |
if st.session_state.graph_stage == "waiting":
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
st.rerun()
|
| 177 |
|
| 178 |
-
|
| 179 |
-
|
| 180 |
|
| 181 |
# --- Stage 3: Resume Graph Execution ---
|
| 182 |
# When resuming after interrupt
|
|
@@ -188,19 +191,11 @@ class DisplayResultStreamlit:
|
|
| 188 |
st.session_state["state"],
|
| 189 |
config=st.session_state.thread_config
|
| 190 |
):
|
| 191 |
-
with
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
for key, value in d.items():
|
| 197 |
-
with st.expander(label=key):
|
| 198 |
-
st.markdown(value)
|
| 199 |
-
with col2:
|
| 200 |
-
if "__interrupt__" in event:
|
| 201 |
-
st.session_state.graph_stage = "waiting"
|
| 202 |
-
st.rerun()
|
| 203 |
-
break
|
| 204 |
|
| 205 |
|
| 206 |
# Determine if the workflow has reached the finish point (fix_test_cases node reached).
|
|
|
|
| 15 |
self.graph = graph
|
| 16 |
self.user_message = user_message
|
| 17 |
|
| 18 |
+
def load_content_for_review(self):
|
| 19 |
+
expander_labels = {
|
| 20 |
+
"user_stories": "User Stories", # generate_user_stories
|
| 21 |
+
"po_feedback": "PO Feedback", # product_owner_review
|
| 22 |
+
"design_docs": "Design Documents", # create_design_docs
|
| 23 |
+
"design_feedback": "Design Feedback", # design_review
|
| 24 |
+
"review_feedback": "Review Feedback", # decision_design_review
|
| 25 |
+
"generate_code": "Generated Code", # generate_code
|
| 26 |
+
"test_cases": "Test Cases", # write_test_cases
|
| 27 |
+
"security_feedback": "Security Feedback", # security_review
|
| 28 |
+
"test_feedback": "Test Feedback", # decision_test_cases_review
|
| 29 |
+
}
|
| 30 |
+
non_empty_items = [(key, label, st.session_state.state.get(key, "")) for key, label in expander_labels.items() if st.session_state.state.get(key, "")]
|
| 31 |
+
|
| 32 |
+
# Get the second last item
|
| 33 |
+
if len(non_empty_items) >= 2:
|
| 34 |
+
key, label, value = non_empty_items[-2]
|
| 35 |
+
with st.expander(label):
|
| 36 |
+
st.markdown(value)
|
| 37 |
+
|
| 38 |
def display_result_on_ui(self):
|
| 39 |
usecase= self.usecase
|
| 40 |
graph = self.graph
|
|
|
|
| 145 |
st.session_state.graph_config = {"configurable": {"thread_id": uuid.uuid4()}}
|
| 146 |
|
| 147 |
# Create a placeholder to show output or interrupts.
|
|
|
|
|
|
|
| 148 |
ui = SDLCUI()
|
| 149 |
col1, col2 = st.columns(2) # Create two columns
|
| 150 |
st.session_state.state['Final_Result'] = []
|
| 151 |
if 'Final_Result' not in st.session_state:
|
| 152 |
st.session_state['Final_Result'] = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
if st.session_state.graph_stage =='initial' and 'current_step' in st.session_state.state and st.session_state.state['current_step']!='' :
|
| 154 |
graph_stream = graph.stream(st.session_state["state"], config=st.session_state.graph_config )
|
| 155 |
if graph_stream:
|
| 156 |
|
| 157 |
for event in graph_stream:
|
| 158 |
+
if "__interrupt__" in event:
|
| 159 |
+
st.session_state.graph_stage = "waiting"
|
| 160 |
+
st.rerun()
|
| 161 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
else:
|
| 163 |
st.session_state.graph_stage = "finished"
|
| 164 |
# --- Stage 2: Display Human Input UI ---
|
| 165 |
if st.session_state.graph_stage == "waiting":
|
| 166 |
+
col2_1, col2_2 = st.columns(2)
|
| 167 |
+
with col2_1:
|
| 168 |
+
# Load Results:
|
| 169 |
+
self.load_content_for_review()
|
| 170 |
+
if st.button("β
Approve"):
|
| 171 |
+
st.session_state.user_decision = "approve"
|
| 172 |
+
st.session_state.graph_stage = "resumed"
|
| 173 |
+
st.rerun()
|
| 174 |
+
with col2_2:
|
| 175 |
+
feedback = st.text_area(label='Provide Feedback or edit automated feedback',value=st.session_state.state['current_result'], key="feedback_input")
|
| 176 |
+
if st.button("π Request Change"):
|
| 177 |
+
st.session_state.user_decision = feedback if feedback else "reject"
|
| 178 |
+
st.session_state.graph_stage = "resumed"
|
| 179 |
+
st.rerun()
|
|
|
|
| 180 |
|
| 181 |
+
if st.session_state.graph_stage == "waiting":
|
| 182 |
+
st.stop()
|
| 183 |
|
| 184 |
# --- Stage 3: Resume Graph Execution ---
|
| 185 |
# When resuming after interrupt
|
|
|
|
| 191 |
st.session_state["state"],
|
| 192 |
config=st.session_state.thread_config
|
| 193 |
):
|
| 194 |
+
# with col2:
|
| 195 |
+
if "__interrupt__" in event:
|
| 196 |
+
st.session_state.graph_stage = "waiting"
|
| 197 |
+
st.rerun()
|
| 198 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
|
| 201 |
# Determine if the workflow has reached the finish point (fix_test_cases node reached).
|
src/langgraphagenticai/ui/streamlitui/sdlcfeedback.py
CHANGED
|
@@ -172,8 +172,6 @@ class SDLCUI:
|
|
| 172 |
st.success("β
SDLC Process Completed Successfully!")
|
| 173 |
with st.expander("Requirements"):
|
| 174 |
st.write(state.get("requirements", ""))
|
| 175 |
-
with st.expander("Decision"):
|
| 176 |
-
st.write(state.get("decision", ""))
|
| 177 |
with st.expander("User Stories"):
|
| 178 |
st.write(state.get("user_stories", ""))
|
| 179 |
with st.expander("Design Documents"):
|
|
|
|
| 172 |
st.success("β
SDLC Process Completed Successfully!")
|
| 173 |
with st.expander("Requirements"):
|
| 174 |
st.write(state.get("requirements", ""))
|
|
|
|
|
|
|
| 175 |
with st.expander("User Stories"):
|
| 176 |
st.write(state.get("user_stories", ""))
|
| 177 |
with st.expander("Design Documents"):
|