Lets design QA Personal assistant. Chat window to interact with AI. Daily schedule in the left side. upload files option. task manager to add / delete tasks.
Drop files here
or click to upload
import streamlit as st
import pandas as pd
from datetime import datetime
import json
import os
# Initialize session state
if 'tasks' not in st.session_state:
st.session_state.tasks = []
if 'messages' not in st.session_state:
st.session_state.messages = []
if 'schedule' not in st.session_state:
st.session_state.schedule = []
# Page configuration
st.set_page_config(layout="wide")
st.title("QA Personal Assistant")
# Create columns for layout
col1, col2 = st.columns([1, 2])
# Left column - Schedule and Tasks
with col1:
st.subheader("Daily Schedule")
# Add new schedule item
with st.expander("Add Schedule Item"):
schedule_date = st.date_input("Date")
schedule_time = st.time_input("Time")
schedule_desc = st.text_input("Description")
if st.button("Add to Schedule"):
st.session_state.schedule.append({
"datetime": f"{schedule_date} {schedule_time}",
"description": schedule_desc
})
# Display schedule
if st.session_state.schedule:
schedule_df = pd.DataFrame(st.session_state.schedule)
st.dataframe(schedule_df)
st.divider()
# Task Manager
st.subheader("Task Manager")
# Add new task
with st.expander("Add New Task"):
task_title = st.text_input("Task Title")
task_priority = st.selectbox("Priority", ["High", "Medium", "Low"])
if st.button("Add Task"):
if task_title:
st.session_state.tasks.append({
"title": task_title,
"priority": task_priority,
"completed": False
})
# Display tasks
for idx, task in enumerate(st.session_state.tasks):
col_check, col_info, col_delete = st.columns([1, 4, 1])
with col_check:
task_completed = st.checkbox("", task["completed"], key=f"task_{idx}")
st.session_state.tasks[idx]["completed"] = task_completed
with col_info:
st.write(f"**{task['title']}** ({task['priority']})")
with col_delete:
if st.button("🗑️", key=f"delete_{idx}"):
st.session_state.tasks.pop(idx)
st.rerun()
st.divider()
# File Upload
st.subheader("Upload Files")
uploaded_file = st.file_uploader("Choose a file", type=['txt', 'pdf', 'doc', 'docx'])
if uploaded_file is not None:
# Save the file
with open(os.path.join("uploads", uploaded_file.name), "wb") as f:
f.write(uploaded_file.getbuffer())
st.success(f"Saved file: {uploaded_file.name}")
# Right column - Chat Interface
with col2:
st.subheader("Chat with AI Assistant")
# Display chat messages
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Chat input
if prompt := st.chat_input("How can I help you?"):
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})
with st.chat_message("user"):
st.markdown(prompt)
# Simulate AI response
response = f"I understand you said: {prompt}\nThis is a simulated response. In a real implementation, you would integrate with an AI model API."
# Display assistant response
with st.chat_message("assistant"):
st.markdown(response)
# Add assistant response to chat history
st.session_state.messages.append({"role": "assistant", "content": response})
# Create uploads directory if it doesn't exist
if not os.path.exists("uploads"):
os.makedirs("uploads")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?