joao-vectara commited on
Commit
d4b2763
·
verified ·
1 Parent(s): 5fb6c91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -31
app.py CHANGED
@@ -7,7 +7,7 @@ import nest_asyncio
7
  import asyncio
8
  import uuid
9
 
10
- #torch.classes.__path__ = []
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
- st.set_page_config(page_title="Proa Capital Assistant", layout="wide")
24
- # Load external CSS for custom styling
25
- with open("style.css", "r") as f:
26
- st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
27
-
28
- st.markdown(
29
- """
30
- <h1>Welcome to the Proa Capital 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
- customer_id = os.getenv("VECTARA_CUSTOMER_ID", "")
44
- api_key = os.getenv("VECTARA_API_KEY", "")
45
- corpus_id = os.getenv("VECTARA_CORPUS_ID", "")
46
- corpus_key = os.getenv("VECTARA_CORPUS_KEY", "")
 
47
 
48
  # File uploader with drag-and-drop text + limit note
49
- uploaded_files = st.file_uploader(
50
- "Drag and drop file here\nLimit 200MB per file",
51
- type=["pdf", "docx", "xlsx"],
52
- accept_multiple_files=True
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
- nest_asyncio.apply()
61
- asyncio.run(main())
 
 
 
 
 
 
 
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())