Spaces:
Runtime error
Runtime error
File size: 3,592 Bytes
24ec802 31ae6cb 24ec802 dcee313 e38becc 1d9b2fb d84feea 9a5a539 3686bb5 7d78b47 9a5a539 3686bb5 dcee313 6aacb1a e26b373 56b478c e26b373 070c5e5 3686bb5 2c1d0fb 144a3a3 675f8dc 144a3a3 ae27f6e 144a3a3 ae27f6e b6ff19b ae27f6e b6ff19b 144a3a3 5773811 144a3a3 5773811 24ec802 2c1d0fb 24ec802 3145812 07a752d e0f9860 0963dd6 e0f9860 3145812 e0f9860 b4bc03a e0f9860 d9556aa e0f9860 7121326 6aacb1a 31ae6cb b2ab0e6 784a279 b2ab0e6 d17f3d9 7150cb8 e38becc 7121326 790c1c3 297abe8 d622b4c 297abe8 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
import requests
import streamlit as st
import streamlit.components.v1 as components
import time
tt = "ssss"
def semanticComparativeClassification():
st.session_state["respuesta"] = ""
apis_urls = [
"https://api-inference.huggingface.co/models/symanto/sn-xlm-roberta-base-snli-mnli-anli-xnli",
"https://api-inference.huggingface.co/models/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
"https://api-inference.huggingface.co/models/sentence-transformers/distiluse-base-multilingual-cased-v2"
]
for api_url in apis_urls:
semanticComparativeClassificationCall(api_url)
def semanticComparativeClassificationCall(api_url: str):
st.write("Model: ", api_url)
time.sleep(1)
headers = {"Authorization": "Bearer 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"}
#API_URL = "https://api-inference.huggingface.co/models/Maite89/Roberta_finetuning_semantic_similarity_stsb_multi_mt"
st.write("Log:")
def query(payload):
response = requests.post(api_url, headers=headers, json=payload)
return response.json()
sentences = [
"Conoces Lya2 , que es Lya2",
"He perdido la contrase帽a, no puedo entrar o acceder a Lya2",
"Calendario de eventos, creamos un evento , borramos un evento ",
"Sincronizamos Lya2 con el tel茅fono o m贸bil"
"Cambios",
"Cambios dobles , pedir, autorizar , borrar un cambio doble",
"Cambios simples , pedir, autorizar , borrar un cambio simple",
"Sessiones",
"Personal",
"Horarios",
"脕reas",
"Rastryco o rastrico",
"Sylbo la aplicaci贸n m贸bil de Lya2",
"Sylbo",
"Hola hi hola",
"Adi贸s adi贸s bye",
"Como programo el personal",
"Como asigno trabajo al personal"
"Pedir permisos",
"Pedir vacaciones"
]
output = query({
"inputs": {
"wait_for_model" : True,
"source_sentence": st.session_state.mytext,
"sentences": sentences
},
})
#st.write(output)
if "error" in output:
st.write(output["error"])
else:
index=0
for i in output:
st.write(i," - ", sentences[index])
index = index + 1
maxim = max(output)
st.write('MAX:', str(maxim))
sentenceindex = output.index(maxim)
st.write('Sentence index :', sentenceindex)
if output[sentenceindex] < 0.3 :
st.write("No tengo respuesta para esto, 驴me lo explicas mejor o te pongo en contacto con un humano?")
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"
else:
st.write("Tema reconocido: ", str(sentences[sentenceindex]))
st.session_state["respuesta"]= st.session_state["respuesta"] +api_url+"\nTema reconocido: \n<span style='color:#f00'>"+str(sentences[sentenceindex])+"</span>\n\n"
#x = st.slider('Select a value')
#st.write(x, 'squared is', x * x)
st.session_state.response = ""
st.title('Reconocimiento sem谩ntico')
title = st.text_input('Pregunta', '', on_change=semanticComparativeClassification,key='mytext')
st.text_area( "Respuesta: ", key= "respuesta", height=200 )
st.markdown("<div id='logwrapper'>LOG:"+tt+"</div>", unsafe_allow_html=True)
|