Spaces:
Build error
Build error
File size: 2,277 Bytes
f274d93 |
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 |
import gradio as gr
import numpy as np
import agent
import os
css_style = """
.gradio-container {
font-family: "IBM Plex Mono";
}
"""
def agent_run(q, openai_api_key, mapi_api_key):
os.environ["OPENAI_API_KEY"]=openai_api_key
os.environ["MAPI_API_KEY"]=mapi_api_key
try:
out = agent.agent_chain.run(input=q)
except:
out = "Something went wrong, please try again"
return out
with gr.Blocks(css=css_style) as demo:
gr.Markdown(f'''
# A LLM application developed during the LLM March *MADNESS* Hackathon
- Developed by: Mayk Caldas ([@maykcaldas](https://github.com/maykcaldas)) and Sam Cox ([@SamCox822](https://github.com/SamCox822))
## What is this?
- This is a demo of a LLM agent that can answer questions about materials science using the [LangChain🦜️🔗](https://github.com/hwchase17/langchain/) and the [Materials Project API](https://materialsproject.org/).
- Its behave is based on Large Language Models (LLM) and aim to be a tool to help scientists with quick predictions of a nunerous of properties of materials.
It is a work in progress, so please be patient with it.
### Some keys are needed in order to use it:
1. An openAI API key ( [Check it here](https://platform.openai.com/account/api-keys) )
2. A material project's API key ( [Check it here](https://materialsproject.org/api#api-key) )
''')
with gr.Accordion("List of properties we developed tools for", open=False):
gr.Markdown(f"""
Classification tasks: Stability, magnetism, gap_direct, metal,
regression tasks: band_gap, volume, density, atomic_density, formation energy per atom, energy per atom, electronic energy, ionic energy, total energy
""")
openai_api_key = gr.Textbox(
label="OpenAI API Key", placeholder="sk-...", type="password")
mapi_api_key = gr.Textbox(
label="Material Project API Key", placeholder="...", type="password")
with gr.Tab("MAPI Query"):
text_input = gr.Textbox(label="", placeholder="Enter question here...")
text_output = gr.Textbox()
text_button = gr.Button("Query!")
text_button.click(agent_run, inputs=[text_input, openai_api_key, mapi_api_key], outputs=text_output)
demo.launch()
|