File size: 1,311 Bytes
58f23af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import gradio as gr
from dotenv import load_dotenv
from research_manager import ResearchManager

load_dotenv(override=True)

async def run(query: str):
    progress_log = ""
    final_report = None

    async for chunk in ResearchManager().run(query):
        # Only update progress for status messages
        if "Searches" in chunk or "View trace" in chunk or "Email sent" in chunk:
            progress_log += chunk + "\n"
            yield progress_log, final_report
        else:
            # This is the final report
            final_report = chunk
            yield progress_log, final_report

with gr.Blocks(theme=gr.themes.Default(primary_hue="sky")) as ui:
    gr.Markdown("# 🔎 Deep Research Assistant")

    query_textbox = gr.Textbox(label="What topic would you like to research?")
    run_button = gr.Button("Run Research", variant="primary")

    with gr.Row():
        progress_box = gr.Textbox(label="Progress Log", lines=5)
        report_box = gr.Markdown(label="Final Report")

    run_button.click(
        fn=run,
        inputs=query_textbox,
        outputs=[progress_box,report_box],
    )

    query_textbox.submit(
        fn=run,
        inputs=query_textbox,
        outputs=[progress_box,report_box],
    )

ui.launch(inbrowser=True)