File size: 2,121 Bytes
3428039 48f8fc0 3428039 48f8fc0 3428039 48f8fc0 1a7a69b 48f8fc0 1a7a69b 48f8fc0 |
1 2 3 4 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import streamlit as st
from upload import upload_file_to_vectara
#from query import process_queries
import os
from st_app import launch_bot
import nest_asyncio
import asyncio
import uuid
# Setup for HTTP API Calls to Amplitude Analytics
if 'device_id' not in st.session_state:
st.session_state.device_id = str(uuid.uuid4())
if "feedback_key" not in st.session_state:
st.session_state.feedback_key = 0
if __name__ == "__main__":
# Ensure set_page_config is the first Streamlit command
st.set_page_config(page_title="Proa Capital Assistant", layout="centered")
# Load external CSS for custom styling
with open("style.css", "r") as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
# Main UI layout
st.markdown(
"""
<h1>Proa Capital</h1>
<div class="icon-container">
<!-- This yellowish box is the icon background -->
</div>
<h4>Add additional files here</h4>
""",
unsafe_allow_html=True
)
# Fetch credentials from environment variables
customer_id = os.getenv("VECTARA_CUSTOMER_ID", "")
api_key = os.getenv("VECTARA_API_KEY", "")
corpus_id = os.getenv("VECTARA_CORPUS_ID", "")
corpus_key = os.getenv("VECTARA_CORPUS_KEY", "")
# File uploader with drag-and-drop text + limit note
uploaded_files = st.file_uploader(
"Drag and drop file here\nLimit 200MB per file",
type=["pdf", "docx", "xlsx"],
accept_multiple_files=True
)
# If credentials exist and files are uploaded, handle them
if uploaded_files and customer_id and api_key and corpus_id and corpus_key:
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)
nest_asyncio.apply()
asyncio.run(launch_bot()) |