-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
282 lines (235 loc) · 8.51 KB
/
app.py
File metadata and controls
282 lines (235 loc) · 8.51 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
"""
Main Streamlit application for Research Paper Summary Generation and Evaluation.
"""
import streamlit as st
import sys
import os
# Add src directory to path
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
# Import components
from src.ui_components.generator_interface import GeneratorInterface
from src.ui_components.evaluator_interface import EvaluatorInterface
from src.ui_components.dashboard_interface import DashboardInterface
from src.utils.session_manager import SessionManager
from src.database.models import create_tables
# Page configuration
st.set_page_config(
page_title="Research made Readable - AI Summary & Evaluation",
page_icon="📚",
layout="wide",
initial_sidebar_state="expanded"
)
# Custom CSS for better styling
st.markdown("""
<style>
.main-header {
font-size: 3rem;
font-weight: bold;
text-align: center;
color: #2563EB;
margin-bottom: 1rem;
}
.sub-header {
font-size: 1.2rem;
text-align: center;
color: #6B7280;
margin-bottom: 2rem;
}
.role-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 2rem;
border-radius: 10px;
color: white;
text-align: center;
margin: 1rem 0;
cursor: pointer;
transition: transform 0.2s;
}
.role-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.metric-card {
background: #F8F9FA;
padding: 1.5rem;
border-radius: 8px;
border-left: 4px solid #2563EB;
margin: 1rem 0;
}
.sidebar-nav {
background: #F1F5F9;
padding: 1rem;
border-radius: 8px;
margin-bottom: 1rem;
}
</style>
""", unsafe_allow_html=True)
def initialize_app():
"""Initialize the application."""
# Initialize session state
SessionManager.init_session_state()
# Initialize DuckDB and Parquet storage
try:
create_tables()
st.session_state.database_available = True
st.session_state.database_type = "DuckDB + Parquet"
except Exception as e:
st.session_state.database_available = False
st.warning(f"DuckDB storage not available: {str(e)}. Some features may be limited.")
def render_sidebar():
"""Render the sidebar navigation."""
st.sidebar.markdown('<div class="sidebar-nav">', unsafe_allow_html=True)
st.sidebar.title("🔍 Research made Readable")
st.sidebar.markdown("*AI-Powered Research Summary Platform*")
st.sidebar.markdown('</div>', unsafe_allow_html=True)
# Navigation menu
page = st.sidebar.selectbox(
"Navigate to:",
["🏠 Home", "📝 Generator", "🔍 Evaluator", "📊 Dashboard"],
index=0
)
# Set current page in session state
page_mapping = {
"🏠 Home": "home",
"📝 Generator": "generator",
"🔍 Evaluator": "evaluator",
"📊 Dashboard": "dashboard"
}
SessionManager.set_state('current_page', page_mapping[page])
# Sidebar statistics
st.sidebar.markdown("---")
st.sidebar.subheader("📈 Quick Stats")
if st.session_state.get('database_available', False):
try:
from src.database.operations import DatabaseOperations
db_ops = DatabaseOperations()
stats = db_ops.get_evaluation_stats()
st.sidebar.metric("Total Evaluations", stats['total_evaluations'])
st.sidebar.metric("Avg Factuality", f"{stats['avg_factuality']}/5")
st.sidebar.metric("Avg Readability", f"{stats['avg_readability']}/5")
db_ops.close()
except Exception as e:
st.sidebar.error("Unable to load stats")
else:
st.sidebar.info("Database not available")
# Help section
st.sidebar.markdown("---")
st.sidebar.subheader("❓ Help")
st.sidebar.markdown("""
**Generator**: Upload papers and create AI summaries
**Evaluator**: Rate summaries for quality and accuracy
**Dashboard**: View analytics and export data
""")
def render_home_page():
"""Render the home page with role selection."""
st.markdown('<h1 class="main-header">🔍 Research made Readable</h1>', unsafe_allow_html=True)
st.markdown('<p class="sub-header">AI-Powered Research Summary Generation & Evaluation Platform</p>', unsafe_allow_html=True)
# Introduction
st.markdown("""
Welcome to Research made Readable, a comprehensive platform for generating and evaluating AI-powered research paper summaries.
This tool helps researchers, students, and academics quickly understand complex research papers through intelligent summarization.
""")
# Role selection cards
st.subheader("🎯 Choose Your Role")
col1, col2 = st.columns(2)
with col1:
if st.button("📝 Content Generator", use_container_width=True, type="primary"):
SessionManager.set_state('current_page', 'generator')
st.rerun()
st.markdown("""
**Generate AI Summaries**
- Upload BibTeX and PDF files
- Configure AI models and prompts
- Generate layman summaries
- View generation history
""")
with col2:
if st.button("🔍 Content Evaluator", use_container_width=True, type="secondary"):
SessionManager.set_state('current_page', 'evaluator')
st.rerun()
st.markdown("""
**Evaluate Summary Quality**
- Review generated summaries
- Rate factuality and readability
- Provide feedback and comments
- Help improve AI models
""")
# Quick access to dashboard
st.markdown("---")
col1, col2, col3 = st.columns([1, 1, 1])
with col2:
if st.button("📊 View Dashboard", use_container_width=True):
SessionManager.set_state('current_page', 'dashboard')
st.rerun()
# Features overview
st.markdown("---")
st.subheader("✨ Key Features")
col1, col2, col3 = st.columns(3)
with col1:
st.markdown("""
**🤖 Multi-Model AI**
- GPT-4, Claude, Deepseek
- Llama, Mistral support
- Customizable parameters
""")
with col2:
st.markdown("""
**📊 Quality Evaluation**
- Factuality assessment
- Readability scoring
- Comparative analysis
""")
with col3:
st.markdown("""
**📈 Analytics Dashboard**
- Model performance metrics
- Data visualization
- Export capabilities
""")
# About section
with st.expander("ℹ️ About Research made Readable"):
st.markdown("""
Research made Readable is designed to bridge the gap between complex academic research and accessible understanding.
Our platform leverages state-of-the-art AI models to create high-quality summaries that maintain scientific
accuracy while improving readability for diverse audiences.
**How it works:**
1. Upload research papers (BibTeX metadata or PDF files)
2. Configure AI models and summarization prompts
3. Generate summaries using various AI models
4. Evaluate summary quality through human review
5. Analyze performance metrics and export data
**Supported formats:**
- BibTeX (.bib) files with abstracts
- PDF research papers
- Multiple AI model integrations
""")
def main():
"""Main application function."""
# Initialize the application
initialize_app()
# Render sidebar
render_sidebar()
# Get current page
current_page = SessionManager.get_state('current_page', 'home')
# Render appropriate page
if current_page == 'home':
render_home_page()
elif current_page == 'generator':
generator = GeneratorInterface()
generator.render()
elif current_page == 'evaluator':
evaluator = EvaluatorInterface()
evaluator.render()
elif current_page == 'dashboard':
dashboard = DashboardInterface()
dashboard.render()
# Footer
st.markdown("---")
st.markdown("""
<div style="text-align: center; color: #6B7280; padding: 2rem;">
<p>Research made Readable - AI-Powered Research Summary Platform</p>
<p>Built with ❤️ using Streamlit</p>
</div>
""", unsafe_allow_html=True)
if __name__ == "__main__":
main()