Spaces:
Runtime error
Runtime error
import requests | |
import streamlit as st | |
import streamlit.components.v1 as components | |
def semanticComparativeClassification(): | |
API_URL = "https://api-inference.huggingface.co/models/symanto/sn-xlm-roberta-base-snli-mnli-anli-xnli" | |
headers = {"Authorization": "Bearer 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"} | |
#API_URL = "https://api-inference.huggingface.co/models/Maite89/Roberta_finetuning_semantic_similarity_stsb_multi_mt" | |
def query(payload): | |
response = requests.post(API_URL, headers=headers, json=payload) | |
return response.json() | |
sentences = [ | |
"Conoces Lya2", | |
"He perdido la contraseña", | |
"Calendario de eventos", | |
"Cambios dobles", | |
"Cambios simples", | |
"Hola me estás saludando", | |
"Adiós te despides" | |
] | |
output = query({ | |
"inputs": { | |
"wait_for_model" : True, | |
"source_sentence": st.session_state.mytext, | |
"sentences": sentences | |
}, | |
}) | |
index = 0 | |
sentenceindex = -1 | |
max = 0 | |
for i in output: | |
st.write(sentences[index]," - ",i) | |
if i<max: | |
sentenceindex = index | |
index = index + 1 | |
sentenceindex = i.index(max(i)) | |
st.write("Hablamos de ", str(sentenceindex)) | |
return output | |
#x = st.slider('Select a value') | |
#st.write(x, 'squared is', x * x) | |
st.title('Reconocimiento semántico') | |
title = st.text_input('Pregunta', 'Hazme una pregunta', on_change=semanticComparativeClassification,key='mytext') | |
st.write('La pregunta es ', st.session_state.mytext) |