Spaces:
Sleeping
Sleeping
try: | |
import streamlit as st | |
from mi_clase import pipeline | |
st.title("Ask your scientific question!") | |
expected_format = "What is color?\nA)Is a name.\nB)Is something horrible.\nC)I don't know.\nD)You should ask someone else.\nE)Ask in a pyshic book." | |
txt = st.text_area( | |
"follow this format while making your question:", | |
expected_format) | |
try: | |
lista = txt.split("E)") | |
e = lista[1] | |
lista = lista[0].split("D)") | |
d = lista[1] | |
lista = lista[0].split("C)") | |
c = lista[1] | |
lista = lista[0].split("B)") | |
b = lista[1] | |
lista = lista[0].split("A)") | |
a = lista[1] | |
q = lista[0] | |
mi_dict= { | |
"prompt":q, | |
"A":a, | |
"B":b, | |
"C":c, | |
"D":d, | |
"E":e | |
} | |
try: | |
answer = pipeline.give_the_best_answer(mi_dict) | |
st.write(mi_dict) | |
st.write(answer) | |
except Exception as e: | |
st.error("something bad happend to the model") | |
st.error(e) | |
except Exception as e: | |
st.error("Your question doesn't have the required format. Please, correct it.") | |
st.error(e) | |
except Exception as e: | |
st.error("error at the beggining") | |
st.error(e) |