agshiv92 commited on
Commit
c921f21
·
verified ·
1 Parent(s): f1dc7a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -53
app.py CHANGED
@@ -1,53 +1,53 @@
1
- import streamlit as st
2
- import os
3
- import sys
4
- from dotenv import load_dotenv
5
-
6
- from task6_model_deployment.scripts.query_engine import index_connection, initialize_retriever, index_retrieval, load_config
7
- # Load environment variables
8
- load_dotenv()
9
-
10
- # Add the scripts directory to the system path
11
- script_dir = os.path.dirname(os.path.abspath(__file__))
12
- base_dir = os.path.dirname(script_dir)
13
- print(base_dir)
14
- scripts_dir = os.path.join(base_dir, 'scripts')
15
- logo_path = os.path.join(base_dir,'TorontoCanadaChapter_CanPolicyInsight', 'task6_model_deployment', 'assets', 'logo.png')
16
- sys.path.append(scripts_dir)
17
-
18
- # Import functions from the query engine script
19
-
20
-
21
- def main():
22
- # Create a side-by-side layout using columns
23
- col1, col2 = st.columns([1, 5]) # Adjust the width ratios of the columns as needed
24
-
25
- # Display the logo in the first column
26
- with col1:
27
- if os.path.exists(logo_path):
28
- st.image(logo_path, width=80) # Adjust the width to resize the logo
29
- else:
30
- st.error(f"Logo not found at: {logo_path}")
31
-
32
- # Display the title in the second column
33
- with col2:
34
- st.title("Canada Policy Explorer")
35
-
36
- # Initialize Pinecone connection and retrieverC:\Users\agshi\Desktop\Omdena\Canada Policy\TorontoCanadaChapter_CanPolicyInsight\task6_model_deployment\configs
37
- config_path = os.path.join(base_dir,'TorontoCanadaChapter_CanPolicyInsight','task6_model_deployment','configs','config.yaml')
38
- config = load_config(config_path)
39
- pinecone_index,summary_index = index_connection(config_path)
40
- retriever,summary_retriever = initialize_retriever(pinecone_index,summary_index)
41
- st.write("Welcome to the Canada Policy Navigator. Explore policy insights and more.")
42
- # User input for query
43
- query_text = st.text_input("Enter your query:", "")
44
-
45
- if st.button("Submit"):
46
- if query_text:
47
- response = index_retrieval(retriever, summary_retriever, query_text)
48
- st.write(response.response)
49
- else:
50
- st.warning("Please enter a query.")
51
-
52
- if __name__ == "__main__":
53
- main()
 
1
+ import streamlit as st
2
+ import os
3
+ import sys
4
+ from dotenv import load_dotenv
5
+
6
+ from task6_model_deployment.scripts.query_engine import index_connection, initialize_retriever, index_retrieval, load_config
7
+ # Load environment variables
8
+ load_dotenv()
9
+
10
+ # Add the scripts directory to the system path
11
+ script_dir = os.path.dirname(os.path.abspath(__file__))
12
+ base_dir = os.path.dirname(script_dir)
13
+ print(base_dir)
14
+ scripts_dir = os.path.join(base_dir, 'scripts')
15
+ logo_path = os.path.join(base_dir,'app', 'task6_model_deployment', 'assets', 'logo.png')
16
+ sys.path.append(scripts_dir)
17
+
18
+ # Import functions from the query engine script
19
+
20
+
21
+ def main():
22
+ # Create a side-by-side layout using columns
23
+ col1, col2 = st.columns([1, 5]) # Adjust the width ratios of the columns as needed
24
+
25
+ # Display the logo in the first column
26
+ with col1:
27
+ if os.path.exists(logo_path):
28
+ st.image(logo_path, width=80) # Adjust the width to resize the logo
29
+ else:
30
+ st.error(f"Logo not found at: {logo_path}")
31
+
32
+ # Display the title in the second column
33
+ with col2:
34
+ st.title("Canada Policy Explorer")
35
+
36
+ # Initialize Pinecone connection and retrieverC:\Users\agshi\Desktop\Omdena\Canada Policy\TorontoCanadaChapter_CanPolicyInsight\task6_model_deployment\configs
37
+ config_path = os.path.join(base_dir,'app','task6_model_deployment','configs','config.yaml')
38
+ config = load_config(config_path)
39
+ pinecone_index,summary_index = index_connection(config_path)
40
+ retriever,summary_retriever = initialize_retriever(pinecone_index,summary_index)
41
+ st.write("Welcome to the Canada Policy Navigator. Explore policy insights and more.")
42
+ # User input for query
43
+ query_text = st.text_input("Enter your query:", "")
44
+
45
+ if st.button("Submit"):
46
+ if query_text:
47
+ response = index_retrieval(retriever, summary_retriever, query_text)
48
+ st.write(response.response)
49
+ else:
50
+ st.warning("Please enter a query.")
51
+
52
+ if __name__ == "__main__":
53
+ main()