CoolFace
Apppublic

ruDra2916/KnowSphere

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
deep_research.py67 linesDownload Raw Back to root
1import gradio as gr
2from dotenv import load_dotenv
3from research_manager import ResearchManager
4
5load_dotenv(override=True)
6
7
8async def run(query: str):
9    async for chunk in ResearchManager().run(query):
10        yield chunk
11
12
13with gr.Blocks(
14    theme=gr.themes.Default(primary_hue="pink"),
15    css="""
16        #title {
17            font-size: 2.5rem;
18            text-align: center;
19            font-weight: bold;
20            color: #fffdd0; /* Creamy white */
21            margin-bottom: 0.5rem;
22        }
23        #subtitle {
24            text-align: center;
25            font-size: 1.1rem;
26            color: #bbb;
27            margin-bottom: 1.5rem;
28        }
29        #output-box {
30            background-color: #2a2a3a;
31            padding: 1.5rem;
32            border-radius: 16px;
33            color: #f3f3f3;
34            font-size: 1rem;
35            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
36            min-height: 300px;
37        }
38    """
39) as ui:
40    with gr.Column():
41        gr.Markdown("<div id='title'>๐Ÿง  KnowSphere</div>")
42        gr.Markdown("<div id='subtitle'>Explore research topics with style and intelligence</div>")
43
44    with gr.Row():
45        with gr.Column(scale=1, min_width=350):
46            gr.Markdown("### ๐Ÿ” What topic would you like to explore?")
47            query_textbox = gr.Textbox(
48                label="Research Topic",
49                placeholder="e.g., Ethical Concerns in AI",
50                lines=1,
51                max_lines=1,
52                autofocus=True
53            )
54            run_button = gr.Button("โœจ Generate Report", variant="primary", size="lg")
55            gr.Markdown("โžก๏ธ Research summary appears on the right")
56
57        with gr.Column(scale=2, min_width=500):
58            gr.Markdown("### ๐Ÿ“‘ Report Summary")
59            report = gr.Markdown(
60                "Please enter a topic and click **Generate Report** to begin.",
61                elem_id="output-box"
62            )
63
64    run_button.click(fn=run, inputs=query_textbox, outputs=report)
65    query_textbox.submit(fn=run, inputs=query_textbox, outputs=report)
66
67ui.launch(inbrowser=True)