ProaC / app.py
joao-vectara's picture
Create app.py
4485574 verified
raw
history blame
1.23 kB
import streamlit as st
from upload import upload_file_to_vectara
from query import process_queries
import os
# Load external CSS
with open("style.css") as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
# Streamlit UI
st.set_page_config(page_title="STC Bank Assistant", layout="centered")
st.markdown("""
# Welcome to the STC Bank Assistant
🏡 **How may I help you?**
#### Add additional files here
""")
customer_id = str(os.environ['VECTARA_CUSTOMER_ID'])
api_key = str(os.environ['VECTARA_API_KEY'])
corpus_id = str(os.environ['VECTARA_CORPUS_ID'])
corpus_key = str(os.environ['VECTARA_CORPUS_KEY'])
uploaded_files = st.file_uploader("Upload PDF, DOCX, or XLSX files", type=["pdf", "docx", "xlsx"], accept_multiple_files=True)
if uploaded_files and customer_id and api_key and corpus_id:
for file in uploaded_files:
response = upload_file_to_vectara(file, customer_id, api_key, corpus_key)
st.write(f"Uploaded {file.name}: {response}")
if st.button("Run Queries"):
results = process_queries(customer_id, api_key, corpus_key)
for question, answer in results.items():
st.subheader(question)
st.write(answer)