forked from nguyenphuc22/AppDataVisualization
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
141 lines (120 loc) · 6.31 KB
/
Copy pathmain.py
File metadata and controls
141 lines (120 loc) · 6.31 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import os
def initialize_folder_api():
directory = 'ChatBotUtils/image/'
if not os.path.exists(directory):
os.makedirs(directory)
filename = "ChatBotUtils/privateInfo.py"
if not os.path.exists(filename):
api_key = input("Please enter your OpenAI API key: ").strip()
with open(filename, "w") as file:
file.write(f"OPENAI_API_KEY = \"{api_key}\"\n")
else:
from ChatBotUtils.privateInfo import OPENAI_API_KEY
if OPENAI_API_KEY == "":
api_key = input("Please enter your OpenAI API key: ").strip()
with open(filename, "w") as file:
file.write(f"OPENAI_API_KEY = \"{api_key}\"\n")
else:
print("OpenAI API key is already set in privateInfo.py.")
initialize_folder_api()
import streamlit as st
from AppContext import AppContext
from DataManager.ProductManager import ProductManager
from DataManager.ReviewManager import ReviewManager
from FixedContent import FixedContent
from String import StringManager
from UI.Component.ChatBotView import chatbotView
from UI.Component.UploadFilesView import uploadFilesView
from UI.HomeScreen import homeScreen
from UI.Product.Hypothesis.HypothesisProductScreenBinh import hypothesisProductScreenBinh
from UI.Product.Hypothesis.HypothesisProductScreenPhuc import hypothesisProductScreenPhuc
from UI.Product.Hypothesis.HypothesisProductScreenThanh import hypothesisProductScreenThanh
from UI.Product.VisualizationProductScreen import visualizationProductScreen
from UI.Review.Hypothesis.HypothesisReviewScreenNhi import hypothesisReviewScreenNhi
from UI.Review.Hypothesis.HypothesisReviewScreenVien import hypothesisReviewScreenVien
from UI.Review.VisualizationReviewScreen import visualizationReviewScreen
from ChatBot import build_database
# Create an instance of StringManager
strings = StringManager.get_instance()
productManager = ProductManager.get_instance()
reviewManager = ReviewManager.get_instance()
appContext = AppContext.get_instance()
fixedContent = FixedContent.get_instance()
def main():
uploadFilesView(strings)
build_database()
menu = st.sidebar.selectbox(
strings.get_string("menu_title"),
strings.get_string("menu_options"),
)
print(f"Selected menu: {menu}")
if menu == strings.get_string("home_title"):
appContext.titlePage = strings.get_string("home_title")
print(f"Set titlePage to: {appContext.titlePage}")
homeScreen(strings)
elif menu == strings.get_string("product_title"):
product_menu = st.sidebar.selectbox(
strings.get_string("product_title"),
strings.get_string("product_options")
)
print(f"Selected product_menu: {product_menu}")
if product_menu == strings.get_string("data_visualization_title"):
appContext.titlePage = strings.get_string("product_title")
print(f"Set titlePage to: {appContext.titlePage}")
elif product_menu == strings.get_string("hypothesis_title"):
product_hypothesis_menu = st.sidebar.selectbox(
strings.get_string("hypothesis_title"),
strings.get_string("product_hypothesis_title")
)
print(f"Selected product_hypothesis_menu: {product_hypothesis_menu}")
if product_hypothesis_menu == strings.get_string("product_hypothesis_title")[0]:
appContext.titlePage = strings.get_string("product_hypothesis_title")[0]
elif product_hypothesis_menu == strings.get_string("product_hypothesis_title")[1]:
appContext.titlePage = strings.get_string("product_hypothesis_title")[1]
elif product_hypothesis_menu == strings.get_string("product_hypothesis_title")[2]:
appContext.titlePage = strings.get_string("product_hypothesis_title")[2]
print(f"Set titlePage to: {appContext.titlePage}")
elif menu == strings.get_string("review_title"):
review_menu = st.sidebar.selectbox(
strings.get_string("review_title"),
strings.get_string("review_options")
)
print(f"Selected review_menu: {review_menu}")
if review_menu == strings.get_string("data_visualization_title"):
appContext.titlePage = strings.get_string("review_title")
print(f"Set titlePage to: {appContext.titlePage}")
elif review_menu == strings.get_string("hypothesis_title"):
review_hypothesis_menu = st.sidebar.selectbox(
strings.get_string("hypothesis_title"),
strings.get_string("review_hypothesis_title")
)
print(f"Selected review_hypothesis_menu: {review_hypothesis_menu}")
if review_hypothesis_menu == strings.get_string("review_hypothesis_title")[0]:
appContext.titlePage = strings.get_string("review_hypothesis_title")[0]
elif review_hypothesis_menu == strings.get_string("review_hypothesis_title")[1]:
appContext.titlePage = strings.get_string("review_hypothesis_title")[1]
print(f"Set titlePage to: {appContext.titlePage}")
print(f"Final titlePage: {appContext.titlePage}")
if appContext.titlePage == strings.get_string("product_title"):
print("Executing visualizationProductScreen")
visualizationProductScreen(strings)
elif appContext.titlePage == strings.get_string("product_hypothesis_title")[0]:
hypothesisProductScreenPhuc(strings)
elif appContext.titlePage == strings.get_string("product_hypothesis_title")[1]:
hypothesisProductScreenThanh(strings)
# elif appContext.titlePage == strings.get_string("product_hypothesis_title")[2]:
# hypothesisProductScreenBinh(strings)
elif appContext.titlePage == strings.get_string("review_title"):
print("Executing visualizationReviewScreen")
visualizationReviewScreen(strings)
elif appContext.titlePage == strings.get_string("review_hypothesis_title")[1]:
hypothesisReviewScreenVien(strings)
elif appContext.titlePage == strings.get_string("review_hypothesis_title")[0]:
hypothesisReviewScreenNhi(strings)
print("===========================================")
chatbotView()
if __name__ == "__main__":
print("Main Entry...")
productManager.read_data("Data/filtered_data_product.xlsx")
reviewManager.read_data("Data/filtered_data_review.xlsx")
main()