update links

This commit is contained in:
zachary62 2025-05-13 11:14:12 -04:00
parent d5e58f0a45
commit 9424ace44a
15 changed files with 70 additions and 49 deletions

View File

@ -87,7 +87,8 @@ From there, it's easy to implement popular design patterns like ([Multi-](https:
| [Text2SQL](https://github.com/The-Pocket/PocketFlow/tree/main/cookbook/pocketflow-text2sql) | ★☆☆ <br> *Beginner* | Convert natural language to SQL queries with an auto-debug loop | | [Text2SQL](https://github.com/The-Pocket/PocketFlow/tree/main/cookbook/pocketflow-text2sql) | ★☆☆ <br> *Beginner* | Convert natural language to SQL queries with an auto-debug loop |
| [MCP](https://github.com/The-Pocket/PocketFlow/tree/main/cookbook/pocketflow-mcp) | ★☆☆ <br> *Beginner* | Agent using Model Context Protocol for numerical operations | | [MCP](https://github.com/The-Pocket/PocketFlow/tree/main/cookbook/pocketflow-mcp) | ★☆☆ <br> *Beginner* | Agent using Model Context Protocol for numerical operations |
| [A2A](https://github.com/The-Pocket/PocketFlow/tree/main/cookbook/pocketflow-a2a) | ★☆☆ <br> *Beginner* | Agent wrapped with Agent-to-Agent protocol for inter-agent communication | | [A2A](https://github.com/The-Pocket/PocketFlow/tree/main/cookbook/pocketflow-a2a) | ★☆☆ <br> *Beginner* | Agent wrapped with Agent-to-Agent protocol for inter-agent communication |
| [Web HITL](https://github.com/The-Pocket/PocketFlow/tree/main/cookbook/pocketflow-web-hitl) | ★☆☆ <br> *Beginner* | A minimal web service for a human review loop with SSE updates | | [Streamlit HITL](https://github.com/The-Pocket/PocketFlow/tree/main/cookbook/pocketflow-streamlit-hitl) | ★☆☆ <br> *Beginner* | Streamlit app for human-in-the-loop review |
| [FastAPI HITL](https://github.com/The-Pocket/PocketFlow/tree/main/cookbook/pocketflow-fastapi-hitl) | ★☆☆ <br> *Beginner* | FastAPI app for async human review loop with SSE |
</div> </div>

View File

Before

Width:  |  Height:  |  Size: 447 KiB

After

Width:  |  Height:  |  Size: 447 KiB

View File

@ -30,12 +30,18 @@ with st.expander("Show Session State (Shared Data)"):
st.json(display_state) st.json(display_state)
# --- Stage: Initial Input --- # --- Stage: Initial Input ---
if st.session_state.stage == "initial": st.header("1. Submit Data for Processing")
st.header("1. Submit Data for Processing") task_input_value = st.text_area(
# Use st.session_state.task_input directly for the text area's value "Enter data to process:",
task_input_value = st.text_area("Enter data to process:", value=st.session_state.task_input, height=150) value=st.session_state.task_input,
height=150,
if st.button("Submit"): disabled=(st.session_state.stage != "initial")
)
# Disable button if not in 'initial' stage
submit_button_disabled = (st.session_state.stage != "initial")
if st.button("Submit", disabled=submit_button_disabled):
if not submit_button_disabled: # Process click only if button was not meant to be disabled
if not task_input_value.strip(): if not task_input_value.strip():
st.error("Please enter some data to process.") st.error("Please enter some data to process.")
else: else:
@ -70,17 +76,21 @@ if st.session_state.stage == "initial":
# Keep stage as initial # Keep stage as initial
# --- Stage: Awaiting Review --- # --- Stage: Awaiting Review ---
elif st.session_state.stage == "awaiting_review": st.header("2. Review Processed Output")
st.header("2. Review Processed Output") # Get processed output directly from session state
# Get processed output directly from session state processed_output = st.session_state.get("processed_output", "No output to review yet.")
processed_output = st.session_state.get("processed_output", "Error: Processed output not found!") # Display placeholder if no output yet or not in review stage
output_to_display = processed_output if st.session_state.stage == "awaiting_review" else "Output will appear here after submission."
st.subheader("Output to Review:")
st.markdown(f"```\n{str(processed_output)}\n```") # Display as markdown code block st.subheader("Output to Review:")
st.markdown(f"```\\n{str(output_to_display)}\\n```") # Display as markdown code block
col1, col2, _ = st.columns([1, 1, 5]) # Layout buttons
with col1: col1, col2, _ = st.columns([1, 1, 5]) # Layout buttons
if st.button("Approve"): with col1:
# Disable button if not in 'awaiting_review' stage
approve_button_disabled = (st.session_state.stage != "awaiting_review")
if st.button("Approve", disabled=approve_button_disabled):
if not approve_button_disabled: # Process click only if button was not meant to be disabled
print("Approve button clicked.") print("Approve button clicked.")
st.session_state.error_message = None st.session_state.error_message = None
try: try:
@ -106,51 +116,61 @@ elif st.session_state.stage == "awaiting_review":
st.rerun() # Rerun to show error message st.rerun() # Rerun to show error message
with col2: with col2:
if st.button("Reject"): # Disable button if not in 'awaiting_review' stage
print("Reject button clicked.") reject_button_disabled = (st.session_state.stage != "awaiting_review")
st.session_state.error_message = None # Clear previous errors if st.button("Reject", disabled=reject_button_disabled):
# Go back to initial stage to allow modification/resubmission if not reject_button_disabled: # Process click only if button was not meant to be disabled
st.session_state.stage = "initial" print("Reject button clicked.")
# Keep the rejected output visible in the input field for modification st.session_state.error_message = None # Clear previous errors
st.session_state.task_input = st.session_state.get("processed_output", st.session_state.task_input) # Go back to initial stage to allow modification/resubmission
# Clear the processed output so it doesn't linger st.session_state.stage = "initial"
if "processed_output" in st.session_state: del st.session_state.processed_output # Keep the rejected output visible in the input field for modification
if "final_result" in st.session_state: del st.session_state.final_result st.session_state.task_input = st.session_state.get("processed_output", st.session_state.task_input)
st.info("Task rejected. Modify the input below and resubmit.") # Clear the processed output so it doesn't linger
print("Task rejected. Moving back to 'initial' stage.") if "processed_output" in st.session_state: del st.session_state.processed_output
st.rerun() if "final_result" in st.session_state: del st.session_state.final_result
st.info("Task rejected. Modify the input below and resubmit.")
print("Task rejected. Moving back to 'initial' stage.")
st.rerun()
# --- Stage: Completed --- # --- Stage: Completed ---
elif st.session_state.stage == "completed": st.header("3. Task Completed")
st.header("3. Task Completed") # Get final result directly from session state
# Get final result directly from session state final_result = st.session_state.get("final_result", "Task not completed yet.")
final_result = st.session_state.get("final_result", "Error: Final result not found!") # Display placeholder if not completed
st.subheader("Final Result:") result_to_display = final_result if st.session_state.stage == "completed" else "Final result will appear here upon completion."
st.subheader("Final Result:")
if st.session_state.stage == "completed":
st.success("Task approved and completed successfully!") st.success("Task approved and completed successfully!")
st.text_area("", value=str(final_result), height=200, disabled=True) st.text_area("", value=str(result_to_display), height=200, disabled=True) # Always disabled for display
if st.button("Start Over"): # Disable button if not in 'completed' or 'rejected_final' stage
start_over_button_disabled = not (st.session_state.stage == "completed" or st.session_state.stage == "rejected_final")
if st.button("Start Over", disabled=start_over_button_disabled):
if not start_over_button_disabled: # Process click only if button was not meant to be disabled
print("Start Over button clicked.") print("Start Over button clicked.")
reset_state() reset_state()
st.rerun() st.rerun()
# --- Stage: Rejected --- # --- Stage: Rejected -- (This section appears to be for a final rejected state, let's adjust for visibility)
elif st.session_state.stage == "rejected_final": # elif st.session_state.stage == "rejected_final": # Removed conditional rendering
st.header("3. Task Rejected") # We'll integrate the display of rejection into the "Task Completed" area or manage it distinctly
# For now, this specific "rejected_final" header might be redundant if we always show "3. Task Completed" area
# And handle the message within it.
if st.session_state.stage == "rejected_final":
st.header("3. Task Rejected") # This can be shown when in this specific state.
st.error("The processed output was rejected.") st.error("The processed output was rejected.")
# Get rejected output directly from session state # Get rejected output directly from session state
rejected_output = st.session_state.get("processed_output", "") rejected_output = st.session_state.get("processed_output", "")
if rejected_output: if rejected_output:
st.text_area("Rejected Output:", value=str(rejected_output), height=150, disabled=True) st.text_area("Rejected Output:", value=str(rejected_output), height=150, disabled=True)
# The "Start Over" button for this state is handled by the one in "Task Completed" section due to shared disabling logic.
if st.button("Start Over"):
print("Start Over button clicked.")
reset_state()
st.rerun()
# --- Display Error Messages --- # --- Display Error Messages ---
if st.session_state.error_message: if st.session_state.error_message:
st.error(st.session_state.error_message) st.error(st.session_state.error_message)
# --- Add a button to reset state anytime (for debugging) --- # --- Add a button to reset state anytime (for debugging) ---
# st.sidebar.button("Reset State", on_click=reset_state) # Removed sidebar # st.sidebar.button("Reset State", on_click=reset_state) # Removed sidebar

View File

@ -7,7 +7,7 @@ def process_task(task_input: str) -> str:
""" """
print(f"Processing task: {task_input[:50]}...") print(f"Processing task: {task_input[:50]}...")
result = f"Rephrased text for the following input: {task_input}" result = f"Dummy rephrased text for the following input: {task_input}"
# Simulate some work # Simulate some work
time.sleep(2) time.sleep(2)