Update app.py
Browse files
app.py
CHANGED
|
@@ -30,7 +30,7 @@ def get_chemical_info(chemical_name):
|
|
| 30 |
|
| 31 |
final_text = "\n".join(output)
|
| 32 |
|
| 33 |
-
# Save to file
|
| 34 |
file_path = f"/tmp/{chemical_name.replace(' ', '_')}_info.txt"
|
| 35 |
with open(file_path, "w") as f:
|
| 36 |
f.write(final_text)
|
|
@@ -41,7 +41,7 @@ def get_chemical_info(chemical_name):
|
|
| 41 |
return f"No information found for '{chemical_name}'. Please try a more precise name.", None
|
| 42 |
|
| 43 |
|
| 44 |
-
# Gradio
|
| 45 |
with gr.Blocks(title="ChemQuery: Learn Molecules Easily") as demo:
|
| 46 |
gr.Markdown("## ChemQuery: Learn Molecules Easily")
|
| 47 |
gr.Markdown(
|
|
@@ -50,8 +50,20 @@ with gr.Blocks(title="ChemQuery: Learn Molecules Easily") as demo:
|
|
| 50 |
)
|
| 51 |
|
| 52 |
with gr.Row():
|
| 53 |
-
chemical_input = gr.Textbox(label="Enter Chemical Name",
|
| 54 |
-
submit_btn = gr.Button("Submit", scale=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
output_text = gr.Textbox(label="Compound Information", lines=25)
|
| 57 |
download_file = gr.File(label="Download as TXT")
|
|
|
|
| 30 |
|
| 31 |
final_text = "\n".join(output)
|
| 32 |
|
| 33 |
+
# Save to a file
|
| 34 |
file_path = f"/tmp/{chemical_name.replace(' ', '_')}_info.txt"
|
| 35 |
with open(file_path, "w") as f:
|
| 36 |
f.write(final_text)
|
|
|
|
| 41 |
return f"No information found for '{chemical_name}'. Please try a more precise name.", None
|
| 42 |
|
| 43 |
|
| 44 |
+
# Gradio UI
|
| 45 |
with gr.Blocks(title="ChemQuery: Learn Molecules Easily") as demo:
|
| 46 |
gr.Markdown("## ChemQuery: Learn Molecules Easily")
|
| 47 |
gr.Markdown(
|
|
|
|
| 50 |
)
|
| 51 |
|
| 52 |
with gr.Row():
|
| 53 |
+
chemical_input = gr.Textbox(label="Enter Chemical Name", lines=1, scale=5)
|
| 54 |
+
submit_btn = gr.Button("Submit", scale=1, elem_id="submit-btn")
|
| 55 |
+
|
| 56 |
+
gr.Markdown(
|
| 57 |
+
"""
|
| 58 |
+
<style>
|
| 59 |
+
#submit-btn button {
|
| 60 |
+
background-color: #48CAE4 !important;
|
| 61 |
+
height: 48px !important;
|
| 62 |
+
font-weight: bold;
|
| 63 |
+
}
|
| 64 |
+
</style>
|
| 65 |
+
"""
|
| 66 |
+
)
|
| 67 |
|
| 68 |
output_text = gr.Textbox(label="Compound Information", lines=25)
|
| 69 |
download_file = gr.File(label="Download as TXT")
|