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