maykcaldas commited on
Commit
b2ed8a8
·
1 Parent(s): b64f6e0

Upload 6 files

Browse files
Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -9,9 +9,10 @@ css_style = """
9
  }
10
  """
11
 
12
- def agent_run(q, openai_api_key, mapi_api_key):
13
  os.environ["OPENAI_API_KEY"]=openai_api_key
14
  os.environ["MAPI_API_KEY"]=mapi_api_key
 
15
  agent_chain = agent.Agent(openai_api_key, mapi_api_key)
16
  try:
17
  out = agent_chain.run(q)
@@ -33,22 +34,39 @@ with gr.Blocks(css=css_style) as demo:
33
  ### Some keys are needed in order to use it:
34
  1. An openAI API key ( [Check it here](https://platform.openai.com/account/api-keys) )
35
  2. A material project's API key ( [Check it here](https://materialsproject.org/api#api-key) )
 
 
36
  ''')
37
  with gr.Accordion("List of properties we developed tools for", open=False):
38
  gr.Markdown(f"""
39
- Classification tasks: Stability, magnetism, gap direct and metal.
40
- Regression tasks: band_gap, volume, density, atomic_density, formation energy per atom, energy per atom, electronic energy, ionic energy and total energy.
41
- Reaction procedure for synthesis proposal.
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  """)
43
  openai_api_key = gr.Textbox(
44
  label="OpenAI API Key", placeholder="sk-...", type="password")
45
  mapi_api_key = gr.Textbox(
46
  label="Material Project API Key", placeholder="...", type="password")
 
 
47
  with gr.Tab("MAPI Query"):
48
  text_input = gr.Textbox(label="", placeholder="Enter question here...")
49
- text_output = gr.Textbox()
50
- text_button = gr.Button("Query!")
51
 
52
- text_button.click(agent_run, inputs=[text_input, openai_api_key, mapi_api_key], outputs=text_output)
53
 
54
  demo.launch()
 
9
  }
10
  """
11
 
12
+ def agent_run(q, openai_api_key, mapi_api_key, serp_api_key):
13
  os.environ["OPENAI_API_KEY"]=openai_api_key
14
  os.environ["MAPI_API_KEY"]=mapi_api_key
15
+ os.environ["SERPAPI_API_KEY"]=serp_api_key
16
  agent_chain = agent.Agent(openai_api_key, mapi_api_key)
17
  try:
18
  out = agent_chain.run(q)
 
34
  ### Some keys are needed in order to use it:
35
  1. An openAI API key ( [Check it here](https://platform.openai.com/account/api-keys) )
36
  2. A material project's API key ( [Check it here](https://materialsproject.org/api#api-key) )
37
+ 3. A SERP API key ( [Check it here](https://serpapi.com/account-api) )
38
+ - Only used if the chain decides to run a web search to answer the question.
39
  ''')
40
  with gr.Accordion("List of properties we developed tools for", open=False):
41
  gr.Markdown(f"""
42
+ - Classification tasks: "Is the material AnByCz stable?"
43
+ - Stable,
44
+ - Magnetic,
45
+ - Gap direct, and
46
+ - Metal.
47
+ - Regression tasks: "What is the band gap of the material AnByCz?"
48
+ - Band gap,
49
+ - Volume,
50
+ - Density,
51
+ - Atomic density,
52
+ - Formation energy per atom,
53
+ - Energy per atom,
54
+ - Electronic energy,
55
+ - Ionic energy, and
56
+ - Total energy.
57
+ - Reaction procedure for synthesis proposal: "Give me a reaction procedure to synthesize the material AnByCz"(under development)
58
  """)
59
  openai_api_key = gr.Textbox(
60
  label="OpenAI API Key", placeholder="sk-...", type="password")
61
  mapi_api_key = gr.Textbox(
62
  label="Material Project API Key", placeholder="...", type="password")
63
+ serp_api_key = gr.Textbox(
64
+ label="Material Project API Key", placeholder="...", type="password")
65
  with gr.Tab("MAPI Query"):
66
  text_input = gr.Textbox(label="", placeholder="Enter question here...")
67
+ text_output = gr.Textbox(placeholder="Your answer will appear here...")
68
+ text_button = gr.Button("Ask!")
69
 
70
+ text_button.click(agent_run, inputs=[text_input, openai_api_key, mapi_api_key, serp_api_key], outputs=text_output)
71
 
72
  demo.launch()