pythonpyro's picture
Upload 2 files
083214f verified
Raw History Blame
2.31 kB
# ============================================================================
# app.py - FRONTEND
# ============================================================================
import gradio as gr
# Import backend functions and state management
from research_agent import process_message
# ============================================================================
# GRADIO APP DEFINITION
# ============================================================================
with gr.Blocks(title="Deep Research Agent") as demo:
# ============================================================================
# UI HEADER
# ============================================================================
gr.Markdown("# 🔬 Deep Research Assistant")
gr.Markdown("""
### How it works
1. Enter a research topic
2. The AI asks clarification questions
3. You answer them
4. The system performs deep research using RAG + Web
5. A structured report is generated
""")
# ============================================================================
# UI COMPONENTS
# ============================================================================
# Session state to track conversation across interactions
state = gr.State()
# Chatbot interface component
chatbot = gr.Chatbot()
# User input textbox
user_input = gr.Textbox(
placeholder="Enter your research topic or clarification...",
lines=2,
label="Your Message"
)
# Submit button
submit = gr.Button("Send")
# ============================================================================
# EVENT HANDLERS
# ============================================================================
# Wire button to processing function from backend
submit.click(
process_message, # Imported from research_agent.py
inputs=[user_input, chatbot, state],
outputs=[user_input, chatbot, state]
)
# ============================================================================
# APPLICATION ENTRY POINT
# ============================================================================
if __name__ == "__main__":
demo.launch()