graredcr commited on
Commit
d319ef7
·
1 Parent(s): 35b8a41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -16,14 +16,13 @@ def semanticComparativeClassification():
16
  semanticComparativeClassificationCall(api_url)
17
 
18
  def semanticComparativeClassificationCall(api_url: str):
 
19
  st.write("Model: ", api_url)
20
  time.sleep(1)
21
  headers = {"Authorization": "Bearer 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"}
22
  #API_URL = "https://api-inference.huggingface.co/models/Maite89/Roberta_finetuning_semantic_similarity_stsb_multi_mt"
23
  st.write("Log:")
24
- def query(payload):
25
-
26
-
27
  response = requests.post(api_url, headers=headers, json=payload)
28
  return response.json()
29
 
@@ -60,24 +59,25 @@ def semanticComparativeClassificationCall(api_url: str):
60
 
61
  #st.write(output)
62
  if "error" in output:
63
- st.write(output["error"])
64
  else:
65
  index=0
66
  for i in output:
67
- st.write(i," - ", sentences[index])
68
  index = index + 1
69
  maxim = max(output)
70
- st.write('MAX:', str(maxim))
 
71
 
72
  sentenceindex = output.index(maxim)
73
 
74
- st.write('Sentence index :', sentenceindex)
75
 
76
  if output[sentenceindex] < 0.3 :
77
- st.write("No tengo respuesta para esto, ¿me lo explicas mejor o te pongo en contacto con un humano?")
78
  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"
79
  else:
80
- st.write("Tema reconocido: ", str(sentences[sentenceindex]))
81
  st.session_state["respuesta"]= st.session_state["respuesta"] +api_url+"\nTema reconocido: \n<span style='color:#f00'>"+str(sentences[sentenceindex])+"</span>\n\n"
82
 
83
 
@@ -93,5 +93,8 @@ title = st.text_input('Pregunta', '', on_change=semanticComparativeClassificatio
93
 
94
  st.text_area( "Respuesta: ", key= "respuesta", height=200 )
95
 
96
- st.markdown("<div id='logwrapper'>LOG:"+st.session_state.mytext+"</div>", unsafe_allow_html=True)
 
 
 
97
 
 
16
  semanticComparativeClassificationCall(api_url)
17
 
18
  def semanticComparativeClassificationCall(api_url: str):
19
+ global container
20
  st.write("Model: ", api_url)
21
  time.sleep(1)
22
  headers = {"Authorization": "Bearer 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"}
23
  #API_URL = "https://api-inference.huggingface.co/models/Maite89/Roberta_finetuning_semantic_similarity_stsb_multi_mt"
24
  st.write("Log:")
25
+ def query(payload):
 
 
26
  response = requests.post(api_url, headers=headers, json=payload)
27
  return response.json()
28
 
 
59
 
60
  #st.write(output)
61
  if "error" in output:
62
+ container.write(output["error"])
63
  else:
64
  index=0
65
  for i in output:
66
+ container.write(i," - ", sentences[index])
67
  index = index + 1
68
  maxim = max(output)
69
+ container.write('MAX:', str(maxim))
70
+
71
 
72
  sentenceindex = output.index(maxim)
73
 
74
+ container.write('Sentence index :', sentenceindex)
75
 
76
  if output[sentenceindex] < 0.3 :
77
+ container.write("No tengo respuesta para esto, ¿me lo explicas mejor o te pongo en contacto con un humano?")
78
  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"
79
  else:
80
+ container.write("Tema reconocido: ", str(sentences[sentenceindex]))
81
  st.session_state["respuesta"]= st.session_state["respuesta"] +api_url+"\nTema reconocido: \n<span style='color:#f00'>"+str(sentences[sentenceindex])+"</span>\n\n"
82
 
83
 
 
93
 
94
  st.text_area( "Respuesta: ", key= "respuesta", height=200 )
95
 
96
+
97
+ container = st.container()
98
+ container.write("This is inside the container")#
99
+ #st.markdown("<div id='logwrapper'>LOG:"+st.session_state.mytext+"</div>", unsafe_allow_html=True)
100