File size: 2,930 Bytes
8fd59af
 
dab3f26
8fd59af
dab3f26
8fd59af
dab3f26
8fd59af
 
 
 
 
 
 
 
 
 
 
 
dab3f26
8fd59af
 
 
dab3f26
8fd59af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9185ee1
 
 
8fd59af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f75873
8fd59af
dab3f26
 
8fd59af
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from colorama import init, Fore, Style
from research_manager import ResearchManager
import gradio as gr
import os

def run_research(topic_input, questions_input, section_length, groq_key):

    research_task = {
        "topic" : topic_input,
        "key_questions" : questions_input.split(','),
        "report_type" : "market study",
        'section_length' : section_length,
         "guidelines": [
            "The report MUST fully answer all the questions",
            "The report MUST only contain information that can be cited from a URL content",
            "The report DOES NOT contain unverified information and contains only facts",
        ],
    }
    os.environ['GEMINI_API_KEY'] = groq_key

    # Initialize Research Manager
    research_manager = ResearchManager(research_task)
    yield from research_manager.start_research()



def main():
    with gr.Blocks(css="""
        .report-container {
            height: 90vh; 
            overflow-y: auto;
            border: 1px solid #ddd;
            border-radius: 4px;
            padding: 1rem;
        }
    """) as demo:
        with gr.Row():
            with gr.Column():
                topic_input = gr.Textbox(
                    label="Research Topic",
                    placeholder="Enter your research topic...",
                    value="How is MS copilot performing in the enterprise search market ?"
                )
                questions_input = gr.Textbox(
                    label="Key Questions (comma-separated)",
                    placeholder="Enter key questions...",
                    value="What are the user reviews?,  How is the pricing structure?, how does it compare against glean?"
                )
                section_length = gr.Slider(
                    label="Section Length (words)",
                    minimum=300,
                    maximum=500,
                    step=100,
                    value=300)
                groq_key = gr.Textbox(
                    label="Gemini API Key",
                    info="#### Get your free Gemini API key from [aistudio.google.com/app/apikey](https://aistudio.google.com/app/apikey)",
                    placeholder="Enter your Gemini API key...",
                    value="your_groq_key"
                )

                start_btn = gr.Button("Start Research", variant="primary")
                progress_output = gr.HTML(label="Progress Bar")
            with gr.Column():
                with gr.Column(elem_classes="report-container"):
                    report_outline = gr.Markdown(label="Report Outline")  
        
        start_btn.click(
            fn=run_research,
            inputs=[topic_input, questions_input, section_length, groq_key],
            outputs=[start_btn, progress_output, report_outline],  
            show_progress="bar" 
        )

    demo.queue().launch(share = True)
    

if __name__ == "__main__":
    main()