aquibmoin commited on
Commit
359bfc7
·
verified ·
1 Parent(s): 0d48bc0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -25,10 +25,20 @@ ADS.TOKEN = os.getenv('ADS_API_KEY') # Ensure your ADS API key is stored in env
25
 
26
  # Define system message with instructions
27
  system_message = """
28
- You are ExosAI, a helpful assistant specializing in Exoplanet research.
29
- Given the following scientific context and user input, generate a table with five columns:
30
- Technical Requirements Table: Generate a table with the following columns:
31
- - Requirements: The specific observational requirements (e.g., UV observations, long wavelength observations).
 
 
 
 
 
 
 
 
 
 
32
  - Necessary: The necessary values or parameters (e.g., wavelength ranges, spatial resolution).
33
  - Desired: The desired values or parameters.
34
  - Justification: A scientific explanation of why these requirements are important.
@@ -41,7 +51,6 @@ Technical Requirements Table: Generate a table with the following columns:
41
  | Infrared Observations | Wavelength: 2.5–4.8 μm | Wavelength: 1.5–4.8 μm | Tracks water emissions and CO2 lines in icy bodies and small planetesimals | Also allows detection of 3 μm absorption feature in icy bodies. |
42
 
43
  Ensure the response is structured clearly and the technical requirements table follows this format.
44
-
45
  """
46
 
47
  def encode_text(text):
@@ -122,9 +131,9 @@ def fetch_exoplanet_data():
122
 
123
  def generate_response(user_input, relevant_context="", references=[], max_tokens=150, temperature=0.7, top_p=0.9, frequency_penalty=0.5, presence_penalty=0.0):
124
  if relevant_context:
125
- combined_input = f"Scientific Context: {relevant_context}\nUser Input: {user_input}\nPlease generate a table with the format: | Requirements | Necessary | Desired | Justification | Comments |"
126
  else:
127
- combined_input = f"User Input: {user_input}\nPlease generate a table with the format: | Requirements | Necessary | Desired | Justification | Comments |"
128
 
129
  response = client.chat.completions.create(
130
  model="gpt-4-turbo",
@@ -309,7 +318,7 @@ iface = gr.Interface(
309
  gr.Textbox(lines=2, placeholder="Enter your Science Goal here...", label="Prompt ExosAI"),
310
  gr.Textbox(lines=5, placeholder="Enter some context here...", label="Context"),
311
  gr.Checkbox(label="Use NASA SMD Bi-Encoder for Context"),
312
- gr.Slider(50, 1000, value=150, step=10, label="Max Tokens"),
313
  gr.Slider(0.0, 1.0, value=0.7, step=0.1, label="Temperature"),
314
  gr.Slider(0.0, 1.0, value=0.9, step=0.1, label="Top-p"),
315
  gr.Slider(0.0, 1.0, value=0.5, step=0.1, label="Frequency Penalty"),
@@ -323,7 +332,7 @@ iface = gr.Interface(
323
  gr.HTML(label="Miro"),
324
  gr.HTML(label="Generate Mind Map on Mapify")
325
  ],
326
- title="ExosAI - NASA SMD SCDD AI Assistant [version-0.6a]",
327
  description="ExosAI is an AI-powered assistant for generating and visualising HWO Science Cases",
328
  )
329
 
 
25
 
26
  # Define system message with instructions
27
  system_message = """
28
+ You are ExosAI, a helpful assistant specializing in Exoplanet and Astrophysics research.
29
+
30
+ Generate a detailed structured response based on the following science context and user input, including the necessary observables, physical parameters, and technical requirements for observations. The response should include the following sections:
31
+
32
+ Science Objectives: Describe key scientific study objectives related to the science context and user input.
33
+
34
+ Physical Parameters: Outline the physical parameters related to the science context and user input.
35
+
36
+ Observables: Specify the observables related to the science context and user input.
37
+
38
+ Description of Desired Observations: Detail the types of observations related to the science context and user input.
39
+
40
+ Technical Requirements Table: Generate a table with the following columns:
41
+ - Requirements: The specific observational requirements (e.g., UV observations, Optical observations or Infrared observations).
42
  - Necessary: The necessary values or parameters (e.g., wavelength ranges, spatial resolution).
43
  - Desired: The desired values or parameters.
44
  - Justification: A scientific explanation of why these requirements are important.
 
51
  | Infrared Observations | Wavelength: 2.5–4.8 μm | Wavelength: 1.5–4.8 μm | Tracks water emissions and CO2 lines in icy bodies and small planetesimals | Also allows detection of 3 μm absorption feature in icy bodies. |
52
 
53
  Ensure the response is structured clearly and the technical requirements table follows this format.
 
54
  """
55
 
56
  def encode_text(text):
 
131
 
132
  def generate_response(user_input, relevant_context="", references=[], max_tokens=150, temperature=0.7, top_p=0.9, frequency_penalty=0.5, presence_penalty=0.0):
133
  if relevant_context:
134
+ combined_input = f"Scientific Context: {relevant_context}\nUser Input: {user_input}\nPlease generate a detailed structured response as per the defined sections and table format."
135
  else:
136
+ combined_input = f"User Input: {user_input}\nPlease generate a detailed structured response as per the defined sections and table format."
137
 
138
  response = client.chat.completions.create(
139
  model="gpt-4-turbo",
 
318
  gr.Textbox(lines=2, placeholder="Enter your Science Goal here...", label="Prompt ExosAI"),
319
  gr.Textbox(lines=5, placeholder="Enter some context here...", label="Context"),
320
  gr.Checkbox(label="Use NASA SMD Bi-Encoder for Context"),
321
+ gr.Slider(50, 2000, value=150, step=10, label="Max Tokens"),
322
  gr.Slider(0.0, 1.0, value=0.7, step=0.1, label="Temperature"),
323
  gr.Slider(0.0, 1.0, value=0.9, step=0.1, label="Top-p"),
324
  gr.Slider(0.0, 1.0, value=0.5, step=0.1, label="Frequency Penalty"),
 
332
  gr.HTML(label="Miro"),
333
  gr.HTML(label="Generate Mind Map on Mapify")
334
  ],
335
+ title="ExosAI - NASA SMD SCDD AI Assistant [version-0.7a]",
336
  description="ExosAI is an AI-powered assistant for generating and visualising HWO Science Cases",
337
  )
338