Spaces:
Sleeping
Sleeping
Update app.py
Browse files310 unmodified lines3113123133143153163 unmodified lines320321322323324325326327328329330331332333334335336337338339310 unmodified linesRuns the multi-agent conversation in a background thread and yields conversation history updatesas a tuple: (chat update, log state update)."""def run_conversation():asyncio.run(multi_agent_conversation(task_message, log_queue, api_key, human_event, human_input_queue))3 unmodified lineswhile conversation_thread.is_alive() or not log_queue.empty():try:msg = log_queue.get(timeout=0.1)if isinstance(msg, tuple):if msg[0] in ("update", "result"):chat_update = gr.update(value=convert_history(msg[1]), visible=True)log_text = conversation_to_text(msg[1])state_update = gr.update(value=log_text)yield (chat_update, state_update)else:# Optionally handle log messages.passexcept queue.Empty:passtime.sleep(0.1)yield (gr.update(visible=True), gr.update())# -------------------- Multi-Agent Chat Function --------------------def multi_agent_chat(message: str, openai_api_key: str = None) -> Generator[Any, None, None]:310 unmodified lines3113123133143153163173 unmodified lines321322323324325326327328329330331332333334335336337338310 unmodified linesRuns the multi-agent conversation in a background thread and yields conversation history updatesas a tuple: (chat update, log state update)."""last_log_text = ""def run_conversation():asyncio.run(multi_agent_conversation(task_message, log_queue, api_key, human_event, human_input_queue))3 unmodified lineswhile conversation_thread.is_alive() or not log_queue.empty():try:msg = log_queue.get(timeout=0.1)if isinstance(msg, tuple) and msg[0] in ("update", "result"):chat_update = gr.update(value=convert_history(msg[1]), visible=True)last_log_text = conversation_to_text(msg[1])state_update = gr.update(value=last_log_text)yield (chat_update, state_update)else:passexcept queue.Empty:passtime.sleep(0.1)yield (gr.update(visible=True), gr.update(value=last_log_text))# -------------------- Multi-Agent Chat Function --------------------def multi_agent_chat(message: str, openai_api_key: str = None) -> Generator[Any, None, None]:
app.py+9-10