File size: 1,055 Bytes
ce243a5
d9f47da
ce243a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d9f47da
 
 
 
 
 
ce243a5
6432af5
 
 
 
 
 
 
 
 
ce243a5
6432af5
 
 
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
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:
    st.error("Your question doesn't have the required format. Please, correct it.")
    st.error(e)