Update app.py
Browse filesAdding agentic
app.py
CHANGED
@@ -1,52 +1,69 @@
|
|
1 |
import streamlit as st
|
2 |
from upload import upload_file_to_vectara
|
3 |
-
from query import process_queries
|
4 |
import os
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
<
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
)
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from upload import upload_file_to_vectara
|
3 |
+
#from query import process_queries
|
4 |
import os
|
5 |
+
from st_app import launch_bot
|
6 |
+
import nest_asyncio
|
7 |
+
import asyncio
|
8 |
+
import uuid
|
9 |
|
10 |
+
|
11 |
+
|
12 |
+
# Setup for HTTP API Calls to Amplitude Analytics
|
13 |
+
if 'device_id' not in st.session_state:
|
14 |
+
st.session_state.device_id = str(uuid.uuid4())
|
15 |
+
|
16 |
+
if "feedback_key" not in st.session_state:
|
17 |
+
st.session_state.feedback_key = 0
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
# Ensure set_page_config is the first Streamlit command
|
21 |
+
st.set_page_config(page_title="STC Bank Assistant", layout="centered")
|
22 |
+
|
23 |
+
# Load external CSS for custom styling
|
24 |
+
with open("style.css", "r") as f:
|
25 |
+
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
26 |
+
|
27 |
+
# Main UI layout
|
28 |
+
st.markdown(
|
29 |
+
"""
|
30 |
+
<h1>Welcome to the STC Bank Assistant</h1>
|
31 |
+
|
32 |
+
<div class="icon-container">
|
33 |
+
<!-- This yellowish box is the icon background -->
|
34 |
+
<div class="icon-box">💼</div>
|
35 |
+
<p class="icon-text">How may I help you?</p>
|
36 |
+
</div>
|
37 |
+
|
38 |
+
<h4>Add additional files here</h4>
|
39 |
+
""",
|
40 |
+
unsafe_allow_html=True
|
41 |
+
)
|
42 |
+
|
43 |
+
# Fetch credentials from environment variables
|
44 |
+
customer_id = os.getenv("VECTARA_CUSTOMER_ID", "")
|
45 |
+
api_key = os.getenv("VECTARA_API_KEY", "")
|
46 |
+
corpus_id = os.getenv("VECTARA_CORPUS_ID", "")
|
47 |
+
corpus_key = os.getenv("VECTARA_CORPUS_KEY", "")
|
48 |
+
|
49 |
+
# File uploader with drag-and-drop text + limit note
|
50 |
+
uploaded_files = st.file_uploader(
|
51 |
+
"Drag and drop file here\nLimit 200MB per file",
|
52 |
+
type=["pdf", "docx", "xlsx"],
|
53 |
+
accept_multiple_files=True
|
54 |
+
)
|
55 |
+
|
56 |
+
# If credentials exist and files are uploaded, handle them
|
57 |
+
if uploaded_files and customer_id and api_key and corpus_id and corpus_key:
|
58 |
+
for file in uploaded_files:
|
59 |
+
response = upload_file_to_vectara(file, customer_id, api_key, corpus_key)
|
60 |
+
st.write(f"Uploaded {file.name}: {response}")
|
61 |
+
|
62 |
+
#if st.button("Run Queries"):
|
63 |
+
# results = process_queries(customer_id, api_key, corpus_key)
|
64 |
+
# for question, answer in results.items():
|
65 |
+
# st.subheader(question)
|
66 |
+
# st.write(answer)
|
67 |
+
|
68 |
+
nest_asyncio.apply()
|
69 |
+
asyncio.run(launch_bot())
|