Spaces:
Sleeping
Sleeping
Download app.py from lemosryan007/deep_research: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/spaces/lemosryan007/deep_research/resolve/main/app.py
- Command line
-
hf download hf://spaces/lemosryan007/deep_research/app.py
-
curl -L -o app.py https://huggingface.co/spaces/lemosryan007/deep_research/resolve/main/app.py
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) | |