Spaces:
Sleeping
Sleeping
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() |