Spaces:
Sleeping

deep_research / app.py
lemosryan007's picture
Upload folder using huggingface_hub
f233663 verified
Raw History Blame Contribute Delete
1.68 kB
import gradio as gr
from dotenv import load_dotenv
from research2_manager import ResearchManager # make sure this is your latest version
load_dotenv(override=True)
# --- Async generator that streams the manager output ---
async def run(query: str, clarifications: str):
"""Stream the ResearchManager output into the Gradio interface."""
try:
async for chunk in ResearchManager().run(query=query, clarifications=clarifications or None):
yield chunk
except Exception as e:
yield f"**Error:** {e!s}"
# --- Gradio UI ---
with gr.Blocks(theme=gr.themes.Default(primary_hue="sky")) as ui:
gr.Markdown("## 🔎 Deep Research Agent (Interactive — No Email)")
with gr.Row():
query_textbox = gr.Textbox(
label="Main Research Query",
placeholder="e.g. Battery storage logistics in Southeast Asia",
lines=2,
)
clarification_box = gr.Textbox(
label="Answers to Clarifying Questions",
placeholder="(Leave blank on first run — you’ll get questions back.)",
lines=4,
)
run_button = gr.Button("▶️ Run Research", variant="primary")
report_output = gr.Markdown("")
# Hook up the run function (async streaming)
run_button.click(
fn=run,
inputs=[query_textbox, clarification_box],
outputs=report_output,
)
query_textbox.submit(
fn=run,
inputs=[query_textbox, clarification_box],
outputs=report_output,
)
# --- Enable async queue ---
if __name__ == "__main__":
ui.queue(default_concurrency_limit=2, status_update_rate=1).launch(inbrowser=True)