Create app.py
Browse filesChanging app.py
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from upload import upload_file_to_vectara
|
| 3 |
+
from query import process_queries
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
# Ensure set_page_config is the first Streamlit command
|
| 7 |
+
st.set_page_config(page_title="STC Bank Assistant", layout="centered")
|
| 8 |
+
|
| 9 |
+
# Load external CSS
|
| 10 |
+
with open("style.css") as f:
|
| 11 |
+
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
| 12 |
+
|
| 13 |
+
# Streamlit UI
|
| 14 |
+
st.markdown("""
|
| 15 |
+
# Welcome to the STC Bank Assistant
|
| 16 |
+
|
| 17 |
+
🏡 **How may I help you?**
|
| 18 |
+
|
| 19 |
+
#### Add additional files here
|
| 20 |
+
""")
|
| 21 |
+
|
| 22 |
+
# Fetch credentials from environment variables
|
| 23 |
+
customer_id = os.getenv("VECTARA_CUSTOMER_ID", "")
|
| 24 |
+
api_key = os.getenv("VECTARA_API_KEY", "")
|
| 25 |
+
corpus_id = os.getenv("VECTARA_CORPUS_ID", "")
|
| 26 |
+
corpus_key = os.getenv("VECTARA_CORPUS_KEY", "")
|
| 27 |
+
|
| 28 |
+
uploaded_files = st.file_uploader("Upload PDF, DOCX, or XLSX files", type=["pdf", "docx", "xlsx"], accept_multiple_files=True)
|
| 29 |
+
|
| 30 |
+
if uploaded_files and customer_id and api_key and corpus_id and corpus_key:
|
| 31 |
+
for file in uploaded_files:
|
| 32 |
+
response = upload_file_to_vectara(file, customer_id, api_key, corpus_key)
|
| 33 |
+
st.write(f"Uploaded {file.name}: {response}")
|
| 34 |
+
|
| 35 |
+
if st.button("Run Queries"):
|
| 36 |
+
results = process_queries(customer_id, api_key, corpus_key)
|
| 37 |
+
for question, answer in results.items():
|
| 38 |
+
st.subheader(question)
|
| 39 |
+
st.write(answer)
|