File size: 1,480 Bytes
7bd5533
ee233a4
7bd5533
 
 
 
 
 
 
 
c8c75ba
 
 
 
 
7bd5533
c8c75ba
 
 
 
 
 
7bd5533
 
 
 
c8c75ba
 
7bd5533
 
 
 
 
 
 
 
c8c75ba
7bd5533
 
 
 
 
 
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
# 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()