Nur Arifin Akbar commited on
Commit
6760933
Β·
1 Parent(s): b5b343e

Remove API configuration forms from frontend - use environment variables only

Browse files
Files changed (1) hide show
  1. app.py +16 -44
app.py CHANGED
@@ -99,9 +99,6 @@ def extract_paper_title_from_text(text: str) -> str:
99
 
100
  def review_paper(
101
  pdf_file,
102
- api_key: str,
103
- base_url: str,
104
- model_name: str,
105
  search_related: bool,
106
  progress=gr.Progress()
107
  ) -> tuple[str, str, str, str, str]:
@@ -110,10 +107,10 @@ def review_paper(
110
  if pdf_file is None:
111
  return "Please upload a PDF file.", "", "", "", ""
112
 
113
- # Get API credentials from environment or inputs
114
- final_api_key = api_key if api_key else os.getenv("OPENAI_API_KEY", "")
115
- final_base_url = base_url if base_url else os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1")
116
- final_model = model_name if model_name else os.getenv("MODEL_NAME", "gpt-3.5-turbo")
117
 
118
  if not final_api_key or final_api_key.strip() == "":
119
  return "Please provide an API key or set OPENAI_API_KEY environment variable.", "", "", "", ""
@@ -213,27 +210,7 @@ with gr.Blocks(title="AI Literature Review System", theme=gr.themes.Soft()) as d
213
 
214
  with gr.Row():
215
  with gr.Column(scale=1):
216
- gr.Markdown("### πŸ“€ Upload & Configure")
217
-
218
- with gr.Accordion("API Configuration", open=False):
219
- api_key_input = gr.Textbox(
220
- label="API Key",
221
- type="password",
222
- placeholder="Leave empty to use OPENAI_API_KEY env var",
223
- info="Your OpenAI-compatible API key"
224
- )
225
-
226
- base_url_input = gr.Textbox(
227
- label="Base URL",
228
- placeholder="Leave empty to use OPENAI_BASE_URL env var or default",
229
- info="API base URL (e.g., https://api.openai.com/v1)"
230
- )
231
-
232
- model_input = gr.Textbox(
233
- label="Model Name",
234
- placeholder="Leave empty to use MODEL_NAME env var or default",
235
- info="Model identifier (e.g., gpt-4, gpt-3.5-turbo)"
236
- )
237
 
238
  pdf_input = gr.File(
239
  label="Upload Research Paper (PDF)",
@@ -255,13 +232,9 @@ with gr.Blocks(title="AI Literature Review System", theme=gr.themes.Soft()) as d
255
  2. **Impactist**: Impact and significance
256
  3. **Novelty Seeker**: Originality and innovation
257
 
258
- ### πŸ”§ Setup:
259
- Set environment variables in `.env`:
260
- ```bash
261
- OPENAI_API_KEY=your-key-here
262
- OPENAI_BASE_URL=https://api.openai.com/v1
263
- MODEL_NAME=gpt-4
264
- ```
265
  """)
266
 
267
  with gr.Column(scale=2):
@@ -285,18 +258,17 @@ with gr.Blocks(title="AI Literature Review System", theme=gr.themes.Soft()) as d
285
  # Connect the button to the review function
286
  submit_btn.click(
287
  fn=review_paper,
288
- inputs=[pdf_input, api_key_input, base_url_input, model_input, search_related_checkbox],
289
  outputs=[summary_output, review_1_output, review_2_output, review_3_output, related_papers_output]
290
  )
291
 
292
  gr.Markdown("""
293
  ---
294
  ### πŸ“– How to Use:
295
- 1. Configure your API settings (or use environment variables)
296
- 2. Upload your research paper in PDF format
297
- 3. Optionally enable Semantic Scholar search for related papers
298
- 4. Click "Review Paper" and wait for the sequential multi-agent analysis (2-5 minutes)
299
- 5. Review the detailed feedback from all three reviewers
300
 
301
  ### πŸ“Š Score Interpretation:
302
  - **9-10**: Award Quality / Strong Accept
@@ -306,10 +278,10 @@ with gr.Blocks(title="AI Literature Review System", theme=gr.themes.Soft()) as d
306
  - **1-2**: Reject
307
 
308
  ### ⚠️ Notes:
309
- - Reviews are generated **sequentially** (one at a time) for better quality
310
- - Processing time depends on paper length and API response time
311
  - Ensure your PDF contains extractable text (not scanned images)
312
- - Semantic Scholar API is rate-limited; use moderately
313
  """)
314
 
315
 
 
99
 
100
  def review_paper(
101
  pdf_file,
 
 
 
102
  search_related: bool,
103
  progress=gr.Progress()
104
  ) -> tuple[str, str, str, str, str]:
 
107
  if pdf_file is None:
108
  return "Please upload a PDF file.", "", "", "", ""
109
 
110
+ # Get API credentials from environment variables
111
+ final_api_key = os.getenv("OPENAI_API_KEY", "")
112
+ final_base_url = os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1")
113
+ final_model = os.getenv("MODEL_NAME", "gpt-3.5-turbo")
114
 
115
  if not final_api_key or final_api_key.strip() == "":
116
  return "Please provide an API key or set OPENAI_API_KEY environment variable.", "", "", "", ""
 
210
 
211
  with gr.Row():
212
  with gr.Column(scale=1):
213
+ gr.Markdown("### πŸ“€ Upload Paper")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
  pdf_input = gr.File(
216
  label="Upload Research Paper (PDF)",
 
232
  2. **Impactist**: Impact and significance
233
  3. **Novelty Seeker**: Originality and innovation
234
 
235
+ ### ⏱️ Processing Time:
236
+ Expect 3-6 minutes for complete review
237
+ (Sequential processing with rate limiting)
 
 
 
 
238
  """)
239
 
240
  with gr.Column(scale=2):
 
258
  # Connect the button to the review function
259
  submit_btn.click(
260
  fn=review_paper,
261
+ inputs=[pdf_input, search_related_checkbox],
262
  outputs=[summary_output, review_1_output, review_2_output, review_3_output, related_papers_output]
263
  )
264
 
265
  gr.Markdown("""
266
  ---
267
  ### πŸ“– How to Use:
268
+ 1. Upload your research paper in PDF format
269
+ 2. Optionally enable Semantic Scholar search for related papers
270
+ 3. Click "Review Paper" and wait for the sequential multi-agent analysis (3-6 minutes)
271
+ 4. Review the detailed feedback from all three reviewers
 
272
 
273
  ### πŸ“Š Score Interpretation:
274
  - **9-10**: Award Quality / Strong Accept
 
278
  - **1-2**: Reject
279
 
280
  ### ⚠️ Notes:
281
+ - Reviews are generated **sequentially** (one at a time) with rate limiting
282
+ - Processing time: 3-6 minutes depending on paper length
283
  - Ensure your PDF contains extractable text (not scanned images)
284
+ - All API credentials are pre-configured
285
  """)
286
 
287