Update app.py
Browse files
app.py
CHANGED
@@ -130,6 +130,8 @@ def handle_user_interaction(
|
|
130 |
# Get the *current* UI-compatible history from the state for a clean start
|
131 |
# We will build on top of this for all UI updates
|
132 |
ui_history = []
|
|
|
|
|
133 |
for msg in current_state.get(STATE_HISTORY, []):
|
134 |
if msg.get('message_type') != "internal_resource_summary":
|
135 |
role = "assistant" if msg.get("role") == "model" else "user"
|
@@ -149,7 +151,7 @@ def handle_user_interaction(
|
|
149 |
# Handle file display logic (this part remains the same)
|
150 |
all_file_names = sorted(list(set(file_names_state + [f.name for f in uploaded_files or []])))
|
151 |
file_display_md = "#### Uploaded Resources:\n" + "\n".join([f"- `{os.path.basename(name)}`" for name in all_file_names]) if all_file_names else ""
|
152 |
-
file_uploader_visible = not bool(
|
153 |
file_display_visible = bool(all_file_names)
|
154 |
|
155 |
print("YIELD 1: Displaying user message and initial status.")
|
@@ -239,7 +241,7 @@ def handle_user_interaction(
|
|
239 |
gr.update(value=final_ui_history),
|
240 |
gr.update(value=""),
|
241 |
final_state,
|
242 |
-
gr.update(visible=
|
243 |
gr.update(interactive=True),
|
244 |
explainer_accordion_update,
|
245 |
explainer_box_update,
|
@@ -478,5 +480,4 @@ if __name__ == "__main__":
|
|
478 |
logger.critical("FATAL: Could not initialize DSPy or orchestrator modules in Admin mode.")
|
479 |
else:
|
480 |
logger.info("Starting in VISITOR mode. Waiting for user to provide API key.")
|
481 |
-
demo.queue().launch(debug=True)
|
482 |
-
|
|
|
130 |
# Get the *current* UI-compatible history from the state for a clean start
|
131 |
# We will build on top of this for all UI updates
|
132 |
ui_history = []
|
133 |
+
is_first_turn = current_state.get(STATE_IS_FIRST_TURN, False)
|
134 |
+
|
135 |
for msg in current_state.get(STATE_HISTORY, []):
|
136 |
if msg.get('message_type') != "internal_resource_summary":
|
137 |
role = "assistant" if msg.get("role") == "model" else "user"
|
|
|
151 |
# Handle file display logic (this part remains the same)
|
152 |
all_file_names = sorted(list(set(file_names_state + [f.name for f in uploaded_files or []])))
|
153 |
file_display_md = "#### Uploaded Resources:\n" + "\n".join([f"- `{os.path.basename(name)}`" for name in all_file_names]) if all_file_names else ""
|
154 |
+
file_uploader_visible = is_first_turn and not bool(uploaded_files)
|
155 |
file_display_visible = bool(all_file_names)
|
156 |
|
157 |
print("YIELD 1: Displaying user message and initial status.")
|
|
|
241 |
gr.update(value=final_ui_history),
|
242 |
gr.update(value=""),
|
243 |
final_state,
|
244 |
+
gr.update(visible=False, interactive=False),
|
245 |
gr.update(interactive=True),
|
246 |
explainer_accordion_update,
|
247 |
explainer_box_update,
|
|
|
480 |
logger.critical("FATAL: Could not initialize DSPy or orchestrator modules in Admin mode.")
|
481 |
else:
|
482 |
logger.info("Starting in VISITOR mode. Waiting for user to provide API key.")
|
483 |
+
demo.queue().launch(debug=True)
|
|