Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,9 +17,8 @@ def semanticComparativeClassification():
|
|
17 |
for api_url in apis_urls:
|
18 |
semanticComparativeClassificationCall(api_url)
|
19 |
|
20 |
-
def semanticComparativeClassificationCall(api_url: str):
|
21 |
-
st.session_state.logresp =
|
22 |
-
st.session_state["logresp"] = st.session_state["logresp"] + "Model: "+api_url+"\n"
|
23 |
time.sleep(1)
|
24 |
headers = {"Authorization": "Bearer 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"}
|
25 |
#API_URL = "https://api-inference.huggingface.co/models/Maite89/Roberta_finetuning_semantic_similarity_stsb_multi_mt"
|
@@ -61,25 +60,25 @@ def semanticComparativeClassificationCall(api_url: str):
|
|
61 |
|
62 |
#st.write(output)
|
63 |
if "error" in output:
|
64 |
-
st.session_state
|
65 |
else:
|
66 |
index=0
|
67 |
for i in output:
|
68 |
-
st.session_state
|
69 |
#container.write(i," - ", sentences[index])
|
70 |
index = index + 1
|
71 |
maxim = max(output)
|
72 |
-
st.session_state
|
73 |
|
74 |
sentenceindex = output.index(maxim)
|
75 |
|
76 |
-
st.session_state
|
77 |
|
78 |
if output[sentenceindex] < 0.3 :
|
79 |
-
st.session_state
|
80 |
st.session_state["respuesta"]= st.session_state["respuesta"] +api_url+"\nNo tengo respuesta para esto, ¿me lo explicas mejor o te pongo en contacto con un humano?"+"\n\n"
|
81 |
else:
|
82 |
-
st.session_state
|
83 |
st.session_state["respuesta"] = st.session_state["respuesta"] +api_url+"\nTema reconocido: \n"+str(sentences[sentenceindex])+"\n\n"
|
84 |
|
85 |
|
@@ -91,7 +90,7 @@ def semanticComparativeClassificationCall(api_url: str):
|
|
91 |
|
92 |
|
93 |
st.session_state.response = ""
|
94 |
-
st.session_state.logresp = "
|
95 |
st.title('Reconocimiento semántico')
|
96 |
title = st.text_input('Pregunta', '', on_change=semanticComparativeClassification,key='mytext')
|
97 |
|
@@ -101,6 +100,6 @@ st.text_area( "Respuesta: ", key= "respuesta", height=200 )
|
|
101 |
# Section 1
|
102 |
button = st.button('Button')
|
103 |
button_placeholder = st.empty()
|
104 |
-
button_placeholder.write(st.session_state["logresp"])
|
105 |
|
106 |
|
|
|
17 |
for api_url in apis_urls:
|
18 |
semanticComparativeClassificationCall(api_url)
|
19 |
|
20 |
+
def semanticComparativeClassificationCall(api_url: str):
|
21 |
+
st.session_state.logresp = st.session_state.logresp + "Model: "+api_url+"\n"
|
|
|
22 |
time.sleep(1)
|
23 |
headers = {"Authorization": "Bearer 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"}
|
24 |
#API_URL = "https://api-inference.huggingface.co/models/Maite89/Roberta_finetuning_semantic_similarity_stsb_multi_mt"
|
|
|
60 |
|
61 |
#st.write(output)
|
62 |
if "error" in output:
|
63 |
+
st.session_state.logresp = st.session_state.logresp + output["error"] +'\n'
|
64 |
else:
|
65 |
index=0
|
66 |
for i in output:
|
67 |
+
st.session_state.logresp = st.session_state.logresp+ str(i) +' - '+sentences[index]+'\n'
|
68 |
#container.write(i," - ", sentences[index])
|
69 |
index = index + 1
|
70 |
maxim = max(output)
|
71 |
+
st.session_state.logresp = st.session_state.logresp+'MAX:'+str(maxim)+'\n'
|
72 |
|
73 |
sentenceindex = output.index(maxim)
|
74 |
|
75 |
+
st.session_state.logresp = st.session_state.logresp+str(sentenceindex)+'\n'
|
76 |
|
77 |
if output[sentenceindex] < 0.3 :
|
78 |
+
st.session_state.logresp = st.session_state.logresp+api_url+"\nNo tengo respuesta para esto, ¿me lo explicas mejor o te pongo en contacto con un humano? \n\n"
|
79 |
st.session_state["respuesta"]= st.session_state["respuesta"] +api_url+"\nNo tengo respuesta para esto, ¿me lo explicas mejor o te pongo en contacto con un humano?"+"\n\n"
|
80 |
else:
|
81 |
+
st.session_state.logresp = st.session_state.logresp+api_url+"\nTema reconocido: "+ str(sentences[sentenceindex])+"\n\n"
|
82 |
st.session_state["respuesta"] = st.session_state["respuesta"] +api_url+"\nTema reconocido: \n"+str(sentences[sentenceindex])+"\n\n"
|
83 |
|
84 |
|
|
|
90 |
|
91 |
|
92 |
st.session_state.response = ""
|
93 |
+
st.session_state.logresp = ""
|
94 |
st.title('Reconocimiento semántico')
|
95 |
title = st.text_input('Pregunta', '', on_change=semanticComparativeClassification,key='mytext')
|
96 |
|
|
|
100 |
# Section 1
|
101 |
button = st.button('Button')
|
102 |
button_placeholder = st.empty()
|
103 |
+
button_placeholder.write(st.session_state[f"logresp"])
|
104 |
|
105 |
|