Adds starting files

This commit is contained in:
2026-01-16 17:45:22 -03:00
parent da8f2984c2
commit c31d089efb
37 changed files with 2560 additions and 0 deletions

89
code/app/front.py Normal file
View File

@@ -0,0 +1,89 @@
import streamlit as st
import time
from backend import BDAgent
import boto3
# Configure the page - MUST BE FIRST
st.set_page_config(
page_title="Chatbot",
page_icon="💬",
layout="centered"
)
session = boto3.Session()
# Model selection with session state persistence
MODELS = [
"anthropic.claude-sonnet-4-5-20250929-v1:0",
"meta.llama4-maverick-17b-instruct-v1:0",
"meta.llama4-scout-17b-instruct-v1:0",
"amazon.nova-lite-v1:0",
"amazon.nova-pro-v1:0",
"amazon.nova-2-lite-v1:0"
]
selected_value = st.selectbox(
"Selecione o modelo:",
MODELS,
key="selected_model"
)
# Initialize chat history in session state
if "messages" not in st.session_state:
st.session_state.messages = []
# Display title
st.title("💬 Chatbot")
# Display chat history
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Chat input
if prompt := st.chat_input("Type your message here..."):
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})
# Display user message
with st.chat_message("user"):
st.markdown(prompt)
# Display assistant response
with st.chat_message("assistant"):
message_placeholder = st.empty()
# Simulate streaming response (replace with actual API call)
full_response = BDAgent.main(prompt,str(st.session_state.messages),selected_value)
# Simulate typing effect
displayed_response = ""
for char in full_response:
displayed_response += char
message_placeholder.markdown(displayed_response + "")
time.sleep(0.01)
message_placeholder.markdown(full_response)
# Add assistant response to chat history
st.session_state.messages.append({"role": "assistant", "content": full_response})
# Add a sidebar with options
with st.sidebar:
st.header("Options")
if st.button("Clear Chat History"):
st.session_state.messages = []
st.rerun()
st.divider()
st.markdown("""
### How to use:
1. Type your message in the input box
2. Press Enter or click Send
3. View the conversation history
""")