Spaces:
Sleeping
Sleeping
| # File: app.py | |
| import streamlit as st | |
| from orchestrator.dispatcher import Dispatcher | |
| from components.sidebar import render_sidebar | |
| from components.paper_list import render_paper_list | |
| from components.notebook_view import render_notebook | |
| from components.graph_view import render_graph | |
| def main(): | |
| # Page configuration with theming | |
| st.set_page_config(page_title="AI Research Companion", layout="wide", initial_sidebar_state="expanded") | |
| # Render sidebar for inputs: query, num results, theme | |
| query, num_results, theme, search_clicked = render_sidebar() | |
| # Dynamically inject simple dark CSS if chosen | |
| if theme == "Dark": | |
| st.markdown( | |
| "<style>body {background-color: #0E1117; color: #E6E1DC;} .stButton>button {background-color: #2563EB; color: white;}</style>", | |
| unsafe_allow_html=True | |
| ) | |
| if search_clicked and query: | |
| dispatcher = Dispatcher() | |
| # 1. Search for papers via MCP servers | |
| papers = dispatcher.search_papers(query, limit=num_results) | |
| render_paper_list(papers) | |
| # 2. Show notebook for the first paper | |
| if papers: | |
| first_id = papers[0]["id"] | |
| notebook_cells = dispatcher.get_notebook_cells(first_id) | |
| render_notebook(notebook_cells) | |
| # 3. Visualize a knowledge graph for the paper | |
| graph_data = dispatcher.get_graph(first_id) | |
| render_graph(graph_data) | |
| if __name__ == "__main__": | |
| main() | |