Spaces:
Sleeping
Sleeping
IDAgents Developer
commited on
Commit
·
252cb5b
1
Parent(s):
de46839
Fix: Agent chat now works properly - Update all remaining functions to use per-user agent storage
Browse files
app.py
CHANGED
|
@@ -726,9 +726,10 @@ def build_ui():
|
|
| 726 |
agent_name, user_text, histories,
|
| 727 |
deescalation_culture, deescalation_meds,
|
| 728 |
stewardship_site, stewardship_biofilm, stewardship_response, stewardship_crcl, stewardship_severity, stewardship_allergies,
|
| 729 |
-
empiric_age, empiric_allergies, empiric_labs, empiric_culture, empiric_meds, empiric_site, empiric_biofilm, empiric_response, empiric_crcl, empiric_severity
|
|
|
|
| 730 |
):
|
| 731 |
-
agent_json =
|
| 732 |
if agent_json:
|
| 733 |
agent_data = json.loads(agent_json)
|
| 734 |
skills = agent_data.get("skills", [])
|
|
@@ -822,7 +823,7 @@ def build_ui():
|
|
| 822 |
# Call chatpanel_handle, but get extra challenger info from simulate_agent_response_stream
|
| 823 |
import asyncio
|
| 824 |
from core.agents.chat_orchestrator import simulate_agent_response_stream
|
| 825 |
-
agent_json_val =
|
| 826 |
history_val = histories.get(agent_name, [])
|
| 827 |
result = None
|
| 828 |
async def run_stream():
|
|
@@ -916,7 +917,7 @@ def build_ui():
|
|
| 916 |
# Dropdown to pick which agent to chat with
|
| 917 |
agent_picker = gr.Dropdown(
|
| 918 |
label="Select Agent",
|
| 919 |
-
choices=
|
| 920 |
interactive=True
|
| 921 |
)
|
| 922 |
|
|
@@ -1550,8 +1551,8 @@ def build_ui():
|
|
| 1550 |
|
| 1551 |
# --- Show/hide stewardship fields based on agent selection ---
|
| 1552 |
|
| 1553 |
-
def update_dynamic_vars_visibility(agent_name):
|
| 1554 |
-
agent_json =
|
| 1555 |
if agent_json:
|
| 1556 |
agent_data = json.loads(agent_json)
|
| 1557 |
skills = agent_data.get("skills", [])
|
|
@@ -1761,9 +1762,10 @@ def build_ui():
|
|
| 1761 |
agent_name, user_text, histories,
|
| 1762 |
deescalation_culture, deescalation_meds,
|
| 1763 |
stewardship_site, stewardship_biofilm, stewardship_response, stewardship_crcl, stewardship_severity, stewardship_allergies,
|
| 1764 |
-
empiric_age, empiric_allergies, empiric_labs, empiric_culture, empiric_meds, empiric_site, empiric_biofilm, empiric_response, empiric_crcl, empiric_severity
|
|
|
|
| 1765 |
):
|
| 1766 |
-
agent_json =
|
| 1767 |
# Prevent tool invocation on empty/whitespace input (e.g., initial greeting or agent selection)
|
| 1768 |
if user_text is None or not str(user_text).strip():
|
| 1769 |
# Just return the current history, do not invoke any tool
|
|
@@ -1977,7 +1979,7 @@ def build_ui():
|
|
| 1977 |
# Use simulate_agent_response_stream for all agents to ensure challenger logic is applied
|
| 1978 |
import asyncio
|
| 1979 |
from core.agents.chat_orchestrator import simulate_agent_response_stream
|
| 1980 |
-
agent_json_val =
|
| 1981 |
history_val = histories.get(agent_name, [])
|
| 1982 |
result = None
|
| 1983 |
# Prevent repeated tool invocation: if the last assistant message is a tool request for the same required fields, do not re-invoke
|
|
|
|
| 726 |
agent_name, user_text, histories,
|
| 727 |
deescalation_culture, deescalation_meds,
|
| 728 |
stewardship_site, stewardship_biofilm, stewardship_response, stewardship_crcl, stewardship_severity, stewardship_allergies,
|
| 729 |
+
empiric_age, empiric_allergies, empiric_labs, empiric_culture, empiric_meds, empiric_site, empiric_biofilm, empiric_response, empiric_crcl, empiric_severity,
|
| 730 |
+
request: gr.Request
|
| 731 |
):
|
| 732 |
+
agent_json = get_user_agent(request, agent_name)
|
| 733 |
if agent_json:
|
| 734 |
agent_data = json.loads(agent_json)
|
| 735 |
skills = agent_data.get("skills", [])
|
|
|
|
| 823 |
# Call chatpanel_handle, but get extra challenger info from simulate_agent_response_stream
|
| 824 |
import asyncio
|
| 825 |
from core.agents.chat_orchestrator import simulate_agent_response_stream
|
| 826 |
+
agent_json_val = get_user_agent(request, agent_name)
|
| 827 |
history_val = histories.get(agent_name, [])
|
| 828 |
result = None
|
| 829 |
async def run_stream():
|
|
|
|
| 917 |
# Dropdown to pick which agent to chat with
|
| 918 |
agent_picker = gr.Dropdown(
|
| 919 |
label="Select Agent",
|
| 920 |
+
choices=[], # Will be populated per-user by refresh_chat_dropdown
|
| 921 |
interactive=True
|
| 922 |
)
|
| 923 |
|
|
|
|
| 1551 |
|
| 1552 |
# --- Show/hide stewardship fields based on agent selection ---
|
| 1553 |
|
| 1554 |
+
def update_dynamic_vars_visibility(agent_name, request: gr.Request):
|
| 1555 |
+
agent_json = get_user_agent(request, agent_name)
|
| 1556 |
if agent_json:
|
| 1557 |
agent_data = json.loads(agent_json)
|
| 1558 |
skills = agent_data.get("skills", [])
|
|
|
|
| 1762 |
agent_name, user_text, histories,
|
| 1763 |
deescalation_culture, deescalation_meds,
|
| 1764 |
stewardship_site, stewardship_biofilm, stewardship_response, stewardship_crcl, stewardship_severity, stewardship_allergies,
|
| 1765 |
+
empiric_age, empiric_allergies, empiric_labs, empiric_culture, empiric_meds, empiric_site, empiric_biofilm, empiric_response, empiric_crcl, empiric_severity,
|
| 1766 |
+
request: gr.Request
|
| 1767 |
):
|
| 1768 |
+
agent_json = get_user_agent(request, agent_name)
|
| 1769 |
# Prevent tool invocation on empty/whitespace input (e.g., initial greeting or agent selection)
|
| 1770 |
if user_text is None or not str(user_text).strip():
|
| 1771 |
# Just return the current history, do not invoke any tool
|
|
|
|
| 1979 |
# Use simulate_agent_response_stream for all agents to ensure challenger logic is applied
|
| 1980 |
import asyncio
|
| 1981 |
from core.agents.chat_orchestrator import simulate_agent_response_stream
|
| 1982 |
+
agent_json_val = get_user_agent(request, agent_name)
|
| 1983 |
history_val = histories.get(agent_name, [])
|
| 1984 |
result = None
|
| 1985 |
# Prevent repeated tool invocation: if the last assistant message is a tool request for the same required fields, do not re-invoke
|