shravya commited on
Commit
7b4a850
Β·
1 Parent(s): bb6a634

branch with all the code before cleanup

Browse files
pages.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # sidebar.py
2
+
3
+ import streamlit as st
4
+ import streamlit_router as sr
5
+
6
+ def common_sidebar(router):
7
+ st.sidebar.markdown("# Sidebar Navigation")
8
+ st.sidebar.markdown("---")
9
+ st.sidebar.markdown("### Pages")
10
+ if st.sidebar.button("Home"):
11
+ router.redirect(*router.build('/'))
12
+ if st.sidebar.button("TIL Feedback"):
13
+ router.redirect(*router.build('/feedback'))
14
+ if st.sidebar.button("Course Suggester"):
15
+ router.redirect(*router.build('/course_suggester'))
16
+ if st.sidebar.button("Course Lesson Extractor"):
17
+ router.redirect(*router.build('/lessons_extractor'))
18
+ if st.sidebar.button("Article Recommender"):
19
+ router.redirect(*router.build('/article_recommendor'))
20
+ if st.sidebar.button("Recent Article Suggester"):
21
+ router.redirect(*router.build('/research_article_suggester'))
22
+
23
+ def with_sidebar(func):
24
+ def wrapper(*args, **kwargs):
25
+ from ui_main import router # Import router from the main file
26
+ current_route = st.query_params.get("route", [""])[0]
27
+
28
+ if current_route in ['feedback', 'course_suggester', 'lessons_extractor', 'article_recommendor', 'research_article_suggester']:
29
+ common_sidebar(router)
30
+
31
+ return func(*args, **kwargs)
32
+ return wrapper
33
+
34
+
35
+
ui/article_recommendation.py CHANGED
@@ -2,7 +2,6 @@ from dotenv import load_dotenv
2
  import json
3
  import streamlit as st
4
  import utils.settings as settings
5
-
6
  from workflows.article_suggestion import article_recommendation_crew
7
  from utils.write_to_json import write_dict_to_json as write_dict_to_json
8
  load_dotenv()
@@ -17,7 +16,7 @@ def icon(emoji: str):
17
  )
18
 
19
 
20
- def main():
21
  page_bg_img = '''
22
  <style>
23
  [data-testid="stAppViewContainer"]{
@@ -106,4 +105,4 @@ def main():
106
  if st.sidebar.button("← Back to Main Page"):
107
  st.session_state.page = "main"
108
  if __name__ == "__main__":
109
- main()
 
2
  import json
3
  import streamlit as st
4
  import utils.settings as settings
 
5
  from workflows.article_suggestion import article_recommendation_crew
6
  from utils.write_to_json import write_dict_to_json as write_dict_to_json
7
  load_dotenv()
 
16
  )
17
 
18
 
19
+ def article_recommendor_main():
20
  page_bg_img = '''
21
  <style>
22
  [data-testid="stAppViewContainer"]{
 
105
  if st.sidebar.button("← Back to Main Page"):
106
  st.session_state.page = "main"
107
  if __name__ == "__main__":
108
+ article_recommendor_main()
ui/course_learn_suggest_expectations.py CHANGED
@@ -4,7 +4,9 @@ from streamlit_extras.stylable_container import stylable_container
4
  from workflows.courses.expectation_revision import ExpectationRevision
5
 
6
 
7
- def main():
 
 
8
  st.markdown("""
9
  <style>
10
  [data-testid="stAppViewContainer"]{
@@ -143,4 +145,4 @@ def main():
143
 
144
 
145
  if __name__ == "__main__":
146
- main()
 
4
  from workflows.courses.expectation_revision import ExpectationRevision
5
 
6
 
7
+
8
+
9
+ def course_suggester_main():
10
  st.markdown("""
11
  <style>
12
  [data-testid="stAppViewContainer"]{
 
145
 
146
 
147
  if __name__ == "__main__":
148
+ course_suggester_main()
ui/course_lessons_extractor.py CHANGED
@@ -4,6 +4,7 @@ from contextlib import contextmanager
4
  from dotenv import load_dotenv
5
  from workflows.courses.lessons_extractor import LessonsExtractor
6
  from streamlit_extras.capture import stdout
 
7
  load_dotenv()
8
 
9
 
@@ -16,8 +17,7 @@ def setup_event_loop():
16
  finally:
17
  loop.close()
18
  asyncio.set_event_loop(None)
19
-
20
- def main():
21
  page_bg_img = '''
22
  <style>
23
  [data-testid="stAppViewContainer"]{
@@ -71,4 +71,4 @@ def main():
71
  st.markdown(f"Concpets: {', '.join(lesson['concepts'])}")
72
 
73
  if __name__ == "__main__":
74
- main()
 
4
  from dotenv import load_dotenv
5
  from workflows.courses.lessons_extractor import LessonsExtractor
6
  from streamlit_extras.capture import stdout
7
+
8
  load_dotenv()
9
 
10
 
 
17
  finally:
18
  loop.close()
19
  asyncio.set_event_loop(None)
20
+ def lessons_extractor_main():
 
21
  page_bg_img = '''
22
  <style>
23
  [data-testid="stAppViewContainer"]{
 
71
  st.markdown(f"Concpets: {', '.join(lesson['concepts'])}")
72
 
73
  if __name__ == "__main__":
74
+ lessons_extractor_main()
ui/research_paper.py CHANGED
@@ -4,7 +4,9 @@ from streamlit_extras.capture import stdout
4
 
5
 
6
 
7
- def main():
 
 
8
 
9
  st.markdown(
10
  """
@@ -139,4 +141,4 @@ def main():
139
  if st.sidebar.button("← Back to Main Page"):
140
  st.session_state.page = "main"
141
  if __name__ == "__main__":
142
- main()
 
4
 
5
 
6
 
7
+
8
+
9
+ def research_article_suggester_main():
10
 
11
  st.markdown(
12
  """
 
141
  if st.sidebar.button("← Back to Main Page"):
142
  st.session_state.page = "main"
143
  if __name__ == "__main__":
144
+ research_aricle_suggester_main()
ui/til_feedback.py CHANGED
@@ -5,7 +5,11 @@ from streamlit_extras.capture import stdout
5
  from langsmith import Client
6
  from workflows.utils.feedback import Feedback
7
 
 
 
8
  load_dotenv()
 
 
9
  def feedback_main():
10
 
11
  page_bg_img = '''
@@ -125,5 +129,6 @@ def clear_feedback_state(results):
125
  if key.endswith("_feedback_given"):
126
  st.session_state[key] = False
127
 
 
128
  if __name__ == "__main__":
129
  feedback_main()
 
5
  from langsmith import Client
6
  from workflows.utils.feedback import Feedback
7
 
8
+
9
+
10
  load_dotenv()
11
+
12
+
13
  def feedback_main():
14
 
15
  page_bg_img = '''
 
129
  if key.endswith("_feedback_given"):
130
  st.session_state[key] = False
131
 
132
+
133
  if __name__ == "__main__":
134
  feedback_main()
ui_main.py CHANGED
@@ -1,46 +1,39 @@
1
  from dotenv import load_dotenv
2
  from streamlit_extras.stylable_container import stylable_container
3
- from ui.article_recommendation import main as article_recommendor_main
4
- from ui.course_lessons_extractor import main as lessons_extractor_main
5
- from ui.research_paper import main as research_article_suggester_main
6
- from ui.til_feedback import feedback_main
7
- from ui.course_learn_suggest_expectations import main as course_suggester_main
 
8
  import math
9
  import streamlit as st
10
  import subprocess
 
11
 
12
  load_dotenv()
13
 
14
  subprocess.run(["playwright", "install", "chromium"])
15
 
 
16
 
17
  def load_css(file_name):
18
  with open(file_name) as f:
19
  return f.read()
20
 
21
-
22
- def main():
23
-
24
- if 'page' not in st.session_state:
25
- st.session_state.page = "main"
26
-
27
- if st.session_state.page == "main":
28
- show_main_page()
29
- elif st.session_state.page == "article_recommendor":
30
- article_recommendor_main()
31
- elif st.session_state.page == "research_article_suggester":
32
- research_article_suggester_main()
33
- elif st.session_state.page == "feedback":
34
- feedback_main()
35
- elif st.session_state.page == "lessons_extractor":
36
- lessons_extractor_main()
37
- elif st.session_state.page == "course_suggester":
38
- course_suggester_main()
39
 
40
 
41
  def show_main_page():
42
- st.set_page_config(page_title='Growthy AI Workflows',
43
- page_icon='πŸ“°', layout="wide")
44
  page_bg_img = '''
45
  <style>
46
  [data-testid="stAppViewContainer"]{
@@ -53,96 +46,141 @@ def show_main_page():
53
  [data-testid="stToolbar"]{
54
  right: 2rem;
55
  }
56
-
57
-
 
 
58
  </style>
59
  '''
60
  st.markdown(page_bg_img, unsafe_allow_html=True)
61
-
62
  css = load_css("ui/main.css")
63
 
64
  st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)
65
 
66
- st.markdown('<div class="main-title">Welcome to Growthy AI Workflows!</div>',
67
- unsafe_allow_html=True)
68
  st.markdown("---")
69
 
 
 
 
 
 
 
 
 
70
  card_info = [
71
- {"title": "TIL Feedback", "description": "Provide your valuable feedback.",
72
- "key": "feedback", "image": "https://agent.ai/icons/search.svg"},
73
- {"title": "Course Learn suggest Expectations", "description": "Get expectation & check question for course",
74
- "key": "course_suggester", "image": "https://agent.ai/icons/prospecting.svg"},
75
- {"title": "Course Lesson Extractor", "description": "Extract lessons for a given course",
76
- "key": "lessons_extractor", "image": "https://agent.ai/icons/business-analyst.svg"},
77
- {"title": "Article Recommender", "description": "Discover articles tailored to your interests.",
78
- "key": "article_recommendor", "image": "https://agent.ai/icons/robot.svg"},
79
- {"title": "Recent Article Suggester", "description": "Get suggestions for recent research articles.",
80
- "key": "research_article_suggester", "image": "https://agent.ai/icons/data.svg"},
81
-
82
- ]
83
 
84
  num_cols = 3
85
  num_rows = math.ceil(len(card_info) / num_cols)
86
 
87
- col1, col2, col3 = st.columns([1, 8, 1])
88
 
89
  with col2:
90
  for row in range(num_rows):
91
- cols = st.columns(num_cols)
92
  for col in range(num_cols):
93
  index = row * num_cols + col
94
  if index < len(card_info):
95
  card = card_info[index]
96
  with cols[col]:
97
- with stylable_container(
98
- key="inside_container_with_border",
99
- css_styles="""
100
- {
101
- background-color: #e9eaec;
102
- border-radius: 10px;
103
- box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
104
- padding:10px;
105
- display: flex;
106
- flex-direction: row;
107
- flex-wrap: wrap;
108
- align-items: center;
109
- justify-content: center;
110
- height:1000px;
111
- border: 1px solid #C0C0C0;
112
-
113
- } """,
114
- ):
115
- with st.container():
116
- st.image(card["image"])
117
- st.markdown(
118
- f"""
119
- <div style=" display: flex; flex-wrap:wrap; flex-direction: column; text-align: center; justify-content: center; align-items: center">
120
- <span style="font-weight:900; font-size: 24px;"> {card["title"]}</span>
121
- <p class="styled-description">{card["description"]}</p>
122
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  """, unsafe_allow_html=True
124
- )
125
- if st.button("Explore", key=card["key"]):
126
- st.session_state.page = card["key"]
127
- st.markdown(
128
- """
129
- <style>
130
- [data-testid="stImage"] img {
131
- padding:10px;
132
- height: 100px;
133
- width: 100px;
134
- border-radius: 50%;
135
- border: 2px solid white;
136
-
137
- }
138
- [data-testid="column"] {
139
- text-align: center;
140
- }
141
-
142
- </style>
143
- """, unsafe_allow_html=True
144
- )
145
-
146
-
147
- if __name__ == '__main__':
148
- main()
 
 
 
 
 
 
 
 
 
1
  from dotenv import load_dotenv
2
  from streamlit_extras.stylable_container import stylable_container
3
+ from ui.article_recommendation import article_recommendor_main
4
+ from ui.course_lessons_extractor import lessons_extractor_main
5
+ from ui.research_paper import research_article_suggester_main
6
+ from ui.til_feedback import feedback_main
7
+ from ui.course_learn_suggest_expectations import course_suggester_main
8
+ # from pages import card_main
9
  import math
10
  import streamlit as st
11
  import subprocess
12
+ import streamlit_router as sr
13
 
14
  load_dotenv()
15
 
16
  subprocess.run(["playwright", "install", "chromium"])
17
 
18
+ st.set_page_config(page_title='Growthy AI Workflows', page_icon='πŸ“°',layout="wide")
19
 
20
  def load_css(file_name):
21
  with open(file_name) as f:
22
  return f.read()
23
 
24
+ def common_sidebar():
25
+ st.sidebar.markdown("# Sidebar Navigation")
26
+ st.sidebar.markdown("---")
27
+ st.sidebar.markdown("### Pages")
28
+ st.sidebar.button("Home", on_click=lambda: router.redirect(*router.build("show_main_page")))
29
+ st.sidebar.button("TIL Feedback", on_click=lambda: router.redirect(*router.build("feedback_main_wrapper")))
30
+ st.sidebar.button("Course Suggester", on_click=lambda: router.redirect(*router.build("course_suggester_main_wrapper")))
31
+ st.sidebar.button("Course Lesson Extractor", on_click=lambda: router.redirect(*router.build("lessons_extractor_main_wrapper")))
32
+ st.sidebar.button("Article Recommender", on_click=lambda: router.redirect(*router.build("article_recommendor_main_wrapper")))
33
+ st.sidebar.button("Recent Article Suggester", on_click=lambda: router.redirect(*router.build("research_article_suggester_main_wrapper")))
 
 
 
 
 
 
 
 
34
 
35
 
36
  def show_main_page():
 
 
37
  page_bg_img = '''
38
  <style>
39
  [data-testid="stAppViewContainer"]{
 
46
  [data-testid="stToolbar"]{
47
  right: 2rem;
48
  }
49
+ [data-testid="column"] {
50
+ text-align: center;
51
+ }
52
+
53
  </style>
54
  '''
55
  st.markdown(page_bg_img, unsafe_allow_html=True)
56
+
57
  css = load_css("ui/main.css")
58
 
59
  st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)
60
 
61
+ st.markdown('<div class="main-title">Welcome to Growthy AI Workflows!</div>', unsafe_allow_html=True)
 
62
  st.markdown("---")
63
 
64
+ # card_info = [
65
+ # {"title": "TIL Feedback", "description": "Provide your valuable feedback.", "key": "feedback_main_wrapper","image":"https://agent.ai/icons/search.svg"},
66
+ # {"title": "Course Suggester", "description": "Get suggestions for courses", "key": "course_suggester_main_wrapper","image":"https://agent.ai/icons/prospecting.svg"},
67
+ # {"title": "Course Lesson Extractor", "description": "Extract lessons for a given course", "key": "lessons_extractor_main_wrapper","image":"https://agent.ai/icons/business-analyst.svg"},
68
+ # {"title": "Article Recommender", "description": "Discover articles tailored to your interests.", "key": "article_recommendor_main_wrapper","image":"https://agent.ai/icons/robot.svg"},
69
+ # {"title": "Recent Article Suggester", "description": "Get suggestions for recent research articles.", "key": "research_article_suggester_main_wrapper","image":"https://agent.ai/icons/data.svg"},
70
+
71
+ # ]
72
  card_info = [
73
+ {"title": "TIL Feedback", "description": "Provide your valuable feedback.", "key": "feedback_main_wrapper", "image": "πŸ“"},
74
+ {"title": "Course Suggester", "description": "Get suggestions for courses", "key": "course_suggester_main_wrapper", "image": "πŸ“š"},
75
+ {"title": "Course Lesson Extractor", "description": "Extract lessons for a given course", "key": "lessons_extractor_main_wrapper", "image": "πŸ“‘"},
76
+ {"title": "Article Recommender", "description": "Discover articles tailored to your interests.", "key": "article_recommendor_main_wrapper", "image": "πŸ“°"},
77
+ {"title": "Recent Article Suggester", "description": "Get suggestions for recent research articles.", "key": "research_article_suggester_main_wrapper", "image": "πŸ”"},
78
+ ]
 
 
 
 
 
 
79
 
80
  num_cols = 3
81
  num_rows = math.ceil(len(card_info) / num_cols)
82
 
83
+ col1, col2, col3 = st.columns([1,8,1])
84
 
85
  with col2:
86
  for row in range(num_rows):
87
+ cols = st.columns(num_cols,gap="large")
88
  for col in range(num_cols):
89
  index = row * num_cols + col
90
  if index < len(card_info):
91
  card = card_info[index]
92
  with cols[col]:
93
+ with st.container(height=280,border=False):
94
+ with stylable_container(
95
+ key="inside_container_with_border",
96
+
97
+ css_styles="""
98
+ {
99
+ background-color: #e9eaec;
100
+ border-radius: 10px;
101
+ box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
102
+ # padding:10px;
103
+ display: flex;
104
+ flex-direction: row;
105
+ flex-wrap: wrap;
106
+ align-items: center;
107
+ justify-content: center;
108
+ border: 1px solid #C0C0C0;
109
+ text-align: center;
110
+ margin-bottom: 10px;
111
+ } """,
112
+ ):
113
+ # with st.container():
114
+ st.markdown(
115
+ f"""
116
+ <div style="
117
+ font-size: 4rem;
118
+ margin-bottom: 10px;
119
+ ">
120
+ {card['image']}
121
+ </div>
122
+ """, unsafe_allow_html=True
123
+ )
124
+ st.markdown(
125
+ f"""
126
+ <div style=" display: flex; flex-wrap:wrap; flex-direction: column; text-align: center; justify-content: center; align-items: center">
127
+ <span style="font-weight:900; font-size: 24px;"> {card["title"]}</span>
128
+ <p class="styled-description">{card["description"]}</p>
129
+ </div>
130
+ """, unsafe_allow_html=True
131
+ )
132
+ if st.button("Explore", key=card["key"]):
133
+ router.redirect(*router.build(f"{card['key']}"))
134
+ # st.experimental_rerun()
135
+ # st.session_state.page = card["key"]
136
+
137
+ st.markdown(
138
+ """
139
+ <style>
140
+ # [data-testid="stImage"] img {
141
+ # padding:10px;
142
+ # height: 100px;
143
+ # width: 100px;
144
+ # border-radius: 50%;
145
+ # border: 2px solid white;
146
+
147
+ # }
148
+
149
+ [data-testid="column"] div[data-testid="column"]{
150
+ margin: 10px;
151
+ }
152
+ </style>
153
  """, unsafe_allow_html=True
154
+ )
155
+
156
+ # Wrapping each main page function to include the common sidebar
157
+ def feedback_main_wrapper():
158
+ common_sidebar()
159
+ feedback_main()
160
+
161
+ def course_suggester_main_wrapper():
162
+ common_sidebar()
163
+ course_suggester_main()
164
+
165
+ def lessons_extractor_main_wrapper():
166
+ common_sidebar()
167
+ lessons_extractor_main()
168
+
169
+ def article_recommendor_main_wrapper():
170
+ common_sidebar()
171
+ article_recommendor_main()
172
+
173
+ def research_article_suggester_main_wrapper():
174
+ common_sidebar()
175
+ research_article_suggester_main()
176
+
177
+ router = sr.StreamlitRouter()
178
+
179
+ router.register(show_main_page, '/')
180
+ router.register(feedback_main_wrapper, '/feedback', methods=['GET'])
181
+ router.register(course_suggester_main_wrapper, '/course_suggester')
182
+ router.register(lessons_extractor_main_wrapper, '/lessons_extractor')
183
+ router.register(article_recommendor_main_wrapper, '/article_recommendor')
184
+ router.register(research_article_suggester_main_wrapper, '/research_article_suggester')
185
+
186
+ router.serve()