Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ 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:
|
@@ -16,46 +16,52 @@ if 'device_id' not in st.session_state:
|
|
16 |
if "feedback_key" not in st.session_state:
|
17 |
st.session_state.feedback_key = 0
|
18 |
|
19 |
-
async def main():
|
20 |
-
await launch_bot()
|
21 |
-
|
22 |
if __name__ == "__main__":
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
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 |
-
|
41 |
-
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
47 |
|
48 |
# File uploader with drag-and-drop text + limit note
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
57 |
response = upload_file_to_vectara(file, customer_id, api_key, corpus_key)
|
58 |
st.write(f"Uploaded {file.name}: {response}")
|
59 |
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
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="Proa Capital 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>Digital Bank</h1>
|
31 |
|
32 |
<div class="icon-container">
|
33 |
<!-- This yellowish box is the icon background -->
|
|
|
|
|
34 |
</div>
|
35 |
|
36 |
<h4>Add additional files here</h4>
|
37 |
+
""",
|
38 |
+
unsafe_allow_html=True
|
39 |
+
)
|
40 |
|
41 |
+
# Fetch credentials from environment variables
|
42 |
+
customer_id = os.getenv("VECTARA_CUSTOMER_ID", "")
|
43 |
+
api_key = os.getenv("VECTARA_API_KEY", "")
|
44 |
+
corpus_id = os.getenv("VECTARA_CORPUS_ID", "")
|
45 |
+
corpus_key = os.getenv("VECTARA_CORPUS_KEY", "")
|
46 |
|
47 |
# File uploader with drag-and-drop text + limit note
|
48 |
+
uploaded_files = st.file_uploader(
|
49 |
+
"Drag and drop file here\nLimit 200MB per file",
|
50 |
+
type=["pdf", "docx", "xlsx"],
|
51 |
+
accept_multiple_files=True
|
52 |
+
)
|
53 |
+
|
54 |
+
# If credentials exist and files are uploaded, handle them
|
55 |
+
if uploaded_files and customer_id and api_key and corpus_id and corpus_key:
|
56 |
+
for file in uploaded_files:
|
57 |
response = upload_file_to_vectara(file, customer_id, api_key, corpus_key)
|
58 |
st.write(f"Uploaded {file.name}: {response}")
|
59 |
|
60 |
+
#if st.button("Run Queries"):
|
61 |
+
# results = process_queries(customer_id, api_key, corpus_key)
|
62 |
+
# for question, answer in results.items():
|
63 |
+
# st.subheader(question)
|
64 |
+
# st.write(answer)
|
65 |
+
|
66 |
+
nest_asyncio.apply()
|
67 |
+
asyncio.run(launch_bot())
|