|
import streamlit as st |
|
from upload import upload_file_to_vectara |
|
|
|
import os |
|
from st_app import launch_bot |
|
import nest_asyncio |
|
import asyncio |
|
import uuid |
|
|
|
|
|
|
|
|
|
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__": |
|
|
|
st.set_page_config(page_title="Proa Capital Assistant", layout="centered") |
|
|
|
|
|
with open("style.css", "r") as f: |
|
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True) |
|
|
|
|
|
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 |
|
) |
|
|
|
|
|
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", "") |
|
|
|
|
|
uploaded_files = st.file_uploader( |
|
"Drag and drop file here\nLimit 200MB per file", |
|
type=["pdf", "docx", "xlsx"], |
|
accept_multiple_files=True |
|
) |
|
|
|
|
|
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}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nest_asyncio.apply() |
|
asyncio.run(launch_bot()) |