Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,43 +1,61 @@
|
|
| 1 |
-
# File: app.py
|
| 2 |
import streamlit as st
|
| 3 |
from orchestrator.dispatcher import Dispatcher
|
| 4 |
from components.sidebar import render_sidebar
|
| 5 |
from components.paper_list import render_paper_list
|
| 6 |
from components.notebook_view import render_notebook
|
| 7 |
from components.graph_view import render_graph
|
| 8 |
-
|
| 9 |
|
| 10 |
def main():
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
query, num_results, theme, search_clicked = render_sidebar()
|
| 16 |
|
| 17 |
-
#
|
| 18 |
if theme == "Dark":
|
| 19 |
st.markdown(
|
| 20 |
-
"
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
)
|
| 23 |
|
|
|
|
| 24 |
if search_clicked and query:
|
| 25 |
dispatcher = Dispatcher()
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
papers = dispatcher.search_papers(query, limit=num_results)
|
| 29 |
render_paper_list(papers)
|
| 30 |
|
| 31 |
-
# 2. Show notebook for the first paper
|
| 32 |
if papers:
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
render_notebook(notebook_cells)
|
| 36 |
|
| 37 |
-
|
| 38 |
-
graph_data = dispatcher.get_graph(first_id)
|
| 39 |
render_graph(graph_data)
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
if __name__ == "__main__":
|
| 43 |
main()
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from orchestrator.dispatcher import Dispatcher
|
| 3 |
from components.sidebar import render_sidebar
|
| 4 |
from components.paper_list import render_paper_list
|
| 5 |
from components.notebook_view import render_notebook
|
| 6 |
from components.graph_view import render_graph
|
| 7 |
+
from orchestrator.gemini import gemini_generate
|
| 8 |
|
| 9 |
def main():
|
| 10 |
+
st.set_page_config(
|
| 11 |
+
page_title="🚀 MCP Research Companion",
|
| 12 |
+
layout="wide",
|
| 13 |
+
initial_sidebar_state="expanded"
|
| 14 |
+
)
|
| 15 |
|
| 16 |
+
# Sidebar: user query, num results, theme, gemini prompt, etc.
|
| 17 |
+
query, num_results, theme, search_clicked, gemini_prompt = render_sidebar()
|
| 18 |
|
| 19 |
+
# Optional theme
|
| 20 |
if theme == "Dark":
|
| 21 |
st.markdown(
|
| 22 |
+
"""
|
| 23 |
+
<style>
|
| 24 |
+
body {background-color: #0E1117; color: #E6E1DC;}
|
| 25 |
+
.stButton>button {background-color: #2563EB; color: white;}
|
| 26 |
+
</style>
|
| 27 |
+
""",
|
| 28 |
+
unsafe_allow_html=True,
|
| 29 |
)
|
| 30 |
|
| 31 |
+
# Search and display papers
|
| 32 |
if search_clicked and query:
|
| 33 |
dispatcher = Dispatcher()
|
| 34 |
+
with st.spinner("Searching MCP servers..."):
|
| 35 |
+
papers = dispatcher.search_papers(query, limit=num_results)
|
|
|
|
| 36 |
render_paper_list(papers)
|
| 37 |
|
|
|
|
| 38 |
if papers:
|
| 39 |
+
first_paper = papers[0]
|
| 40 |
+
st.subheader("Gemini-Powered Abstract Summarizer")
|
| 41 |
+
if st.button("Summarize Abstract with Gemini"):
|
| 42 |
+
with st.spinner("Gemini is generating summary..."):
|
| 43 |
+
summary = gemini_generate(first_paper["abstract"])
|
| 44 |
+
st.success(summary)
|
| 45 |
+
|
| 46 |
+
# Show notebook and graph
|
| 47 |
+
notebook_cells = dispatcher.get_notebook_cells(first_paper["id"])
|
| 48 |
render_notebook(notebook_cells)
|
| 49 |
|
| 50 |
+
graph_data = dispatcher.get_graph(first_paper["id"])
|
|
|
|
| 51 |
render_graph(graph_data)
|
| 52 |
|
| 53 |
+
# Gemini research Q&A, even if user hasn't hit 'Search'
|
| 54 |
+
if gemini_prompt:
|
| 55 |
+
st.header("💡 Gemini Research Q&A")
|
| 56 |
+
with st.spinner("Gemini is thinking..."):
|
| 57 |
+
answer = gemini_generate(gemini_prompt)
|
| 58 |
+
st.success(answer)
|
| 59 |
|
| 60 |
if __name__ == "__main__":
|
| 61 |
main()
|