Spaces:
Runtime error
Runtime error
| import requests | |
| import streamlit as st | |
| import streamlit.components.v1 as components | |
| def query(payload): | |
| response = requests.post(API_URL, headers=headers, json=payload) | |
| return response.json() | |
| def semanticComparativeClassification(): | |
| st.write(st.session_state.mytext) | |
| #API_URL = "https://api-inference.huggingface.co/models/Maite89/Roberta_finetuning_semantic_similarity_stsb_multi_mt" | |
| API_URL = "https://api-inference.huggingface.co/models/symanto/sn-xlm-roberta-base-snli-mnli-anli-xnli" | |
| headers = {"Authorization": "Bearer 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"} | |
| 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(i) | |
| if i>max: | |
| sentenceindex = index | |
| index = index + 1 | |
| st.write("Hablamos de ", sentences[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', '¿Conoces Lya2?', on_change=semanticComparativeClassification,key='mytext') | |
| st.write('La pregunta es ', st.session_state.mytext) |