Spaces:
Sleeping
Sleeping
File size: 1,340 Bytes
53e0a4a dea6e8d 205c1d0 7309032 21403be 5a7327c 7309032 5a7327c e58a867 5a7327c 06cc1a2 5a7327c 7309032 495c008 56b163f 7309032 41a9792 7309032 60d90af 4f4d5be 06cc1a2 e58a867 06cc1a2 4f4d5be |
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 |
import streamlit as st
import os
from modelo import get_chain
os.environ["OPENAI_API_KEY"] = st.secrets['OPENAI_API_KEY'] # agregada en la config de hugginface
# Initialization
if 'historial' not in st.session_state:
st.session_state['historial'] = ['🤖 Hola soy tu asistente del dia de hoy, en que te puedo ayudar']
def get_historial():
return st.session_state["historial"]
def add_historial(respuesta):
st.session_state["historial"].append(respuesta["query"])
st.session_state["historial"].append(respuesta["result"])
#Menu Visual
st.markdown("<h1 style='text-align: center; color: yellow;'>Chatbot SII</h1>", unsafe_allow_html=True) #mandar un texto en html
st.header("🤖🦾ChatBot entrenado con preguntas frecuentes del sitio del servicios de impuestos interno de Chile.")
pregunta = st.text_area('Ingresa tu pregunta:', value="Que es un APA?")
st.divider()
tmp_button = st.button("CLICK")
st.write(get_historial()[0])
st.divider()
#Fin Menu
chain = get_chain(st.secrets['OPENAI_API_KEY'])
if tmp_button: #Esperar al boton
out = chain.invoke(pregunta)
add_historial(out)
print(get_historial())
st.write(f"<p style='text-align: right;style='text-size: 30px; background-color: yellow;color: black;'>{out['result']}</p>", unsafe_allow_html=True)
#st.rerun() #Restart app
else:
st.stop() |