shravya commited on
Commit
345f397
·
1 Parent(s): 0d1084a

ui(course_learn): Add expectation & Check Question

Browse files
Files changed (2) hide show
  1. ui/course_learn_suggest_expectations.py +132 -0
  2. ui_main.py +38 -24
ui/course_learn_suggest_expectations.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from workflows.courses.suggest_expectations import SuggestExpectations
3
+ 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"]{
11
+ background-image:url("https://www.shutterstock.com/image-vector/abstract-technology-communication-concept-vector-600nw-1914443275.jpg");
12
+ background-size:cover;
13
+ }
14
+ [data-testid="stHeader"]{
15
+ background: rgba(0,0,0,0);
16
+ }
17
+ [data-testid="stToolbar"]{
18
+ right: 2rem;
19
+ }
20
+ .header {
21
+ font-size: 38px;
22
+ font-weight: bold;
23
+ text-align: center;
24
+ color: #4b8bbe;
25
+ margin-bottom: 20px;
26
+ }
27
+ .subheader {
28
+ font-size: 24px;
29
+ font-weight: bold;
30
+ color: #4b8bbe;
31
+ }
32
+ .button:hover {
33
+ background-color: #357ab8;
34
+ }
35
+
36
+ .expectation {
37
+ font-weight: bold;
38
+ color: #333333;
39
+ }
40
+ .check-question {
41
+ color: #666666;
42
+ font-weight: bold;
43
+ }
44
+ input[type='text'] {
45
+ border: 2px solid #A0A0A0;
46
+ padding: 10px;
47
+ border-radius: 5px;
48
+ background-color: white;
49
+ font-size: 16px;
50
+ }
51
+ .stTextArea textarea {
52
+ height: 100px;
53
+ border: 2px solid #A0A0A0;
54
+ }
55
+
56
+ </style>
57
+ """, unsafe_allow_html=True)
58
+ _, col2, _ = st.columns([2, 6, 2])
59
+
60
+ default_content = {
61
+ "course": "SQL",
62
+ "module": "Query Optimization Techniques",
63
+ "tasks": [
64
+ "Watch this video https://youtu.be/BHwzDmr6d7s?si=sfFYnd73y9w0EjGB to understand SQL execution order and some optimization techniques.",
65
+ "Watch this video https://youtu.be/FoznjTU929c?si=6M3xUIUwAxE6EbKS to understand SQL explain command usage.",
66
+ "Go over these articles https://intellipaat.com/blog/sql-optimization-techniques/ & https://www.thoughtspot.com/data-trends/data-modeling/optimizing-sql-queries to understand various query optimization techniques."
67
+ ]
68
+ }
69
+
70
+ st.session_state_inputs = st.session_state_inputs if 'session_state' in st.session_state else default_content
71
+
72
+ with col2:
73
+ st.markdown(
74
+ "<div class='header'>Course Learn Suggest Expectation</div>", unsafe_allow_html=True)
75
+ course = st.text_input("##### Course Name", key="course",
76
+ help="Enter the name of the course", value=st.session_state_inputs["course"])
77
+ module = st.text_input("##### Module Name", key="module",
78
+ help="Enter the name of the module", value=st.session_state_inputs["module"])
79
+ tasks = st.text_area("##### Tasks", key="tasks", value="\n".join(
80
+ st.session_state_inputs["tasks"]), help="Enter the tasks to be covered in the module")
81
+
82
+ suggester = SuggestExpectations()
83
+ inputs = {"course": course, "module": module,
84
+ "tasks": tasks.split('\n')}
85
+
86
+ if st.button("Get Suggestions", key="suggestions", help="Click to get suggestions"):
87
+ responses = suggester.kickoff(inputs=inputs)
88
+ st.session_state.responses = responses
89
+
90
+ if 'responses' in st.session_state:
91
+ for response in st.session_state.responses["expectations"]:
92
+ with stylable_container(
93
+ key="response-container",
94
+ css_styles="""
95
+ {
96
+ background-color: #ffffff;
97
+ padding: 20px;
98
+ border-radius: 10px;
99
+ margin-top: 20px;
100
+ border: 1px solid #C0C0C0;
101
+ background-color: #f5f5f5;
102
+ box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
103
+ display:flex;
104
+ flex-wrap: wrap;
105
+ flex-direction: column;
106
+ }
107
+ .response{
108
+ font-size: 20px;
109
+ line-height: 1.5;
110
+ margin-bottom: 10px;
111
+ }
112
+ """,
113
+ ):
114
+ inner1, _ = st.columns([9, 1])
115
+ with inner1:
116
+ st.markdown(
117
+ f"<div class='response'><span class='expectation'>Expectation: </span> {response['expectation']}</div>", unsafe_allow_html=True)
118
+ st.markdown(
119
+ f"<div class='response'><span class='check-question'>Check Question: </span> {response['check_question']}</div>", unsafe_allow_html=True)
120
+ feedback = st.text_input(
121
+ "Feedback", key=f"feedback_{response['expectation']}", help="Enter your feedback here")
122
+ if st.button("Reload suggestions", key=f"reload_{response['expectation']}"):
123
+ rework = ExpectationRevision()
124
+ feedback_inputs = {
125
+ "expectation": response["expectation"], "check_question": response["check_question"], "request": feedback}
126
+ suggestions = rework.kickoff(
127
+ inputs=feedback_inputs)
128
+ st.write(suggestions)
129
+
130
+
131
+ if __name__ == "__main__":
132
+ main()
ui_main.py CHANGED
@@ -3,7 +3,8 @@ 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
  import math
8
  import streamlit as st
9
  import subprocess
@@ -13,11 +14,11 @@ load_dotenv()
13
  subprocess.run(["playwright", "install", "chromium"])
14
 
15
 
16
-
17
  def load_css(file_name):
18
  with open(file_name) as f:
19
  return f.read()
20
 
 
21
  def main():
22
 
23
  if 'page' not in st.session_state:
@@ -33,9 +34,13 @@ def main():
33
  feedback_main()
34
  elif st.session_state.page == "lessons_extractor":
35
  lessons_extractor_main()
 
 
 
36
 
37
  def show_main_page():
38
- st.set_page_config(page_title='Growthy AI Workflows', page_icon='📰',layout="wide")
 
39
  page_bg_img = '''
40
  <style>
41
  [data-testid="stAppViewContainer"]{
@@ -48,30 +53,38 @@ def show_main_page():
48
  [data-testid="stToolbar"]{
49
  right: 2rem;
50
  }
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","image":"https://agent.ai/icons/search.svg"},
66
- {"title": "Course Lesson Extractor", "description": "Extract lessons for a given course", "key": "lessons_extractor","image":"https://agent.ai/icons/business-analyst.svg"},
67
- {"title": "Article Recommender", "description": "Discover articles tailored to your interests.", "key": "article_recommendor","image":"https://agent.ai/icons/robot.svg"},
68
- {"title": "Recent Article Suggester", "description": "Get suggestions for recent research articles.", "key": "research_article_suggester","image":"https://agent.ai/icons/data.svg"},
 
 
 
 
 
 
 
69
  ]
70
 
71
  num_cols = 3
72
  num_rows = math.ceil(len(card_info) / num_cols)
73
 
74
- col1, col2, col3 = st.columns([2,6,2])
75
 
76
  with col2:
77
  for row in range(num_rows):
@@ -96,22 +109,22 @@ def show_main_page():
96
  justify-content: center;
97
  height:1000px;
98
  border: 1px solid #C0C0C0;
99
-
100
  } """,
101
- ):
102
- with st.container():
103
- st.image(card["image"])
104
- st.markdown(
105
- f"""
106
  <div style=" display: flex; flex-wrap:wrap; flex-direction: column; text-align: center; justify-content: center; align-items: center">
107
  <span style="font-weight:900; font-size: 24px;"> {card["title"]}</span>
108
  <p class="styled-description">{card["description"]}</p>
109
  </div>
110
  """, unsafe_allow_html=True
111
- )
112
- if st.button("Explore", key=card["key"]):
113
- st.session_state.page = card["key"]
114
- st.markdown(
115
  """
116
  <style>
117
  [data-testid="stImage"] img {
@@ -124,11 +137,12 @@ def show_main_page():
124
  }
125
  [data-testid="column"] {
126
  text-align: center;
127
- }
128
 
129
  </style>
130
  """, unsafe_allow_html=True
131
- )
132
-
 
133
  if __name__ == '__main__':
134
  main()
 
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
 
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:
 
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
  [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):
 
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 {
 
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()