Pecximenes's picture
Adding new features: feedback and login/create acount
f5c3f28
import streamlit as st
import sys
import os
# Configuração do caminho para incluir as pastas necessárias
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Importando módulos necessários
from interface.chatbot import Chatbot
from interface.login import Login
def main():
app = Chatbot()
login = Login()
if not st.session_state.user_authorized:
login.mount_login_page()
else:
with st.sidebar:
app.create_sidebar()
user_query = app.mount_chatbot() # Recebe o input de texto feito pelo usuário
app.display_chat()
if st.session_state.is_feedback_active:
app.display_feedback()
if app.user_button_input:
st.chat_message("user").write(app.user_button_input)
app.generate_answer(app.user_button_input)
app.user_button_input = "" # Zerando a variável após uso
st.session_state.is_feedback_active = True # Ativando o feedback
app.display_feedback()
if user_query:
# Escreve e armazena a mensagem do usuário
st.chat_message("user").write(user_query)
app.generate_answer(user_query) # Gera, envia e armazena a resposta do assistente
st.session_state.is_feedback_active = True # Ativando o feedback
app.display_feedback()
if __name__ == "__main__":
main()