aquibmoin commited on
Commit
a9f5c93
·
verified ·
1 Parent(s): 3344bc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -3
app.py CHANGED
@@ -284,7 +284,7 @@ def generate_data_insights(user_input, exoplanet_data, max_tokens=500, temperatu
284
  return data_insights
285
 
286
 
287
- def export_to_word(response_content, subdomain_definition, science_goal):
288
  doc = Document()
289
 
290
  # Add a title (optional, you can remove this if not needed)
@@ -298,6 +298,18 @@ def export_to_word(response_content, subdomain_definition, science_goal):
298
  doc.add_heading('Science Goal:', level=1)
299
  doc.add_paragraph(science_goal)
300
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  # Split the response into sections based on ### headings
302
  sections = response_content.split('### ')
303
 
@@ -427,7 +439,17 @@ def chatbot(user_input, science_objectives="", context="", subdomain="", uploade
427
  response = f"### Science Objectives (User-Defined):\n\n{science_objectives}\n\n" + response
428
 
429
  # Export the response to a Word document
430
- word_doc_path = export_to_word(response, subdomain, user_input)
 
 
 
 
 
 
 
 
 
 
431
 
432
  # Fetch exoplanet data
433
  exoplanet_data = fetch_exoplanet_data()
@@ -486,7 +508,7 @@ with gr.Blocks() as demo:
486
  subdomain = gr.Textbox(lines=2, placeholder="Define your Subdomain...", label="Subdomain Definition")
487
 
488
  # PDF Upload Section (Up to 3 PDFs)
489
- gr.Markdown("## **Context Retrieval Documents [e.g. LUVOIR, HabEx Reports]**")
490
  uploaded_pdfs = gr.Files(file_types=[".pdf"], label="Upload Reference PDFs (Up to 3)", interactive=True)
491
 
492
  # Science Objectives Button & Input (Initially Hidden)
 
284
  return data_insights
285
 
286
 
287
+ def export_to_word(response_content, subdomain_definition, science_goal, context, max_tokens, temperature, top_p, frequency_penalty, presence_penalty):
288
  doc = Document()
289
 
290
  # Add a title (optional, you can remove this if not needed)
 
298
  doc.add_heading('Science Goal:', level=1)
299
  doc.add_paragraph(science_goal)
300
 
301
+ # Insert the User-defined Context
302
+ doc.add_heading('User-defined Context:', level=1)
303
+ doc.add_paragraph(context)
304
+
305
+ # Insert Model Parameters
306
+ doc.add_heading('Model Parameters:', level=1)
307
+ doc.add_paragraph(f"Max Tokens: {max_tokens}")
308
+ doc.add_paragraph(f"Temperature: {temperature}")
309
+ doc.add_paragraph(f"Top-p: {top_p}")
310
+ doc.add_paragraph(f"Frequency Penalty: {frequency_penalty}")
311
+ doc.add_paragraph(f"Presence Penalty: {presence_penalty}")
312
+
313
  # Split the response into sections based on ### headings
314
  sections = response_content.split('### ')
315
 
 
439
  response = f"### Science Objectives (User-Defined):\n\n{science_objectives}\n\n" + response
440
 
441
  # Export the response to a Word document
442
+ word_doc_path = export_to_word(
443
+ response,
444
+ subdomain,
445
+ user_input,
446
+ context,
447
+ max_tokens,
448
+ temperature,
449
+ top_p,
450
+ frequency_penalty,
451
+ presence_penalty
452
+ )
453
 
454
  # Fetch exoplanet data
455
  exoplanet_data = fetch_exoplanet_data()
 
508
  subdomain = gr.Textbox(lines=2, placeholder="Define your Subdomain...", label="Subdomain Definition")
509
 
510
  # PDF Upload Section (Up to 3 PDFs)
511
+ gr.Markdown("### **Documents for Context Retrieval [e.g. LUVOIR, HabEx Reports]**")
512
  uploaded_pdfs = gr.Files(file_types=[".pdf"], label="Upload Reference PDFs (Up to 3)", interactive=True)
513
 
514
  # Science Objectives Button & Input (Initially Hidden)