theRealNG commited on
Commit
5134ccc
ยท
unverified ยท
2 Parent(s): 5dc54c6b49d827

Merge pull request #40 from beautiful-code/course_learn_suggest_expectations_refactor

Browse files
app/ui/course_learn_suggest_expectations.py CHANGED
@@ -62,10 +62,10 @@ def course_suggester_main():
62
  default_content = {
63
  "course": "SQL",
64
  "module": "Query Optimization Techniques",
65
- "tasks": [
66
- "Watch this video https://youtu.be/BHwzDmr6d7s?si=sfFYnd73y9w0EjGB to understand SQL execution order and some optimization techniques.",
67
- "Watch this video https://youtu.be/FoznjTU929c?si=6M3xUIUwAxE6EbKS to understand SQL explain command usage.",
68
- "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."
69
  ],
70
  "expectation": "Should understand the importance of indexing in query optimization.",
71
  "check_question": "How does indexing improve query performance?"
@@ -80,8 +80,8 @@ def course_suggester_main():
80
  help="Enter the name of the course", value=st.session_state_inputs["course"])
81
  module = st.text_input("##### Module Name", key="module",
82
  help="Enter the name of the module", value=st.session_state_inputs["module"])
83
- tasks = st.text_area("##### Tasks", key="tasks", value="\n".join(
84
- st.session_state_inputs["tasks"]), help="Enter the tasks to be covered in the module")
85
  existing_expectation = st.text_input(
86
  "##### Existing Expectation", key="existing_expectation", value=st.session_state_inputs["expectation"])
87
  existing_check_question = st.text_input(
@@ -90,7 +90,7 @@ def course_suggester_main():
90
  suggester = SuggestExpectations()
91
  inputs = {
92
  "course": course, "module": module,
93
- "tasks": tasks.split('\n'),
94
  "existing_expectations": [
95
  Expectation(
96
  expectation=existing_expectation,
@@ -140,7 +140,7 @@ def course_suggester_main():
140
  feedback_inputs = {
141
  "expectation": response["expectation"], "check_question": response["check_question"], "request": feedback,
142
  "course": course, "module": module,
143
- "tasks": tasks.split('\n'),
144
  }
145
  suggestions = rework.kickoff(
146
  inputs=feedback_inputs)
 
62
  default_content = {
63
  "course": "SQL",
64
  "module": "Query Optimization Techniques",
65
+ "concepts": [
66
+ "SQL execution order and some optimization techniques.",
67
+ "SQL explain command usage.",
68
+ "Various query optimization techniques."
69
  ],
70
  "expectation": "Should understand the importance of indexing in query optimization.",
71
  "check_question": "How does indexing improve query performance?"
 
80
  help="Enter the name of the course", value=st.session_state_inputs["course"])
81
  module = st.text_input("##### Module Name", key="module",
82
  help="Enter the name of the module", value=st.session_state_inputs["module"])
83
+ concepts = st.text_area("##### Concepts", key="concepts", value="\n".join(
84
+ st.session_state_inputs["concepts"]), help="Enter the concepts to be covered in the module")
85
  existing_expectation = st.text_input(
86
  "##### Existing Expectation", key="existing_expectation", value=st.session_state_inputs["expectation"])
87
  existing_check_question = st.text_input(
 
90
  suggester = SuggestExpectations()
91
  inputs = {
92
  "course": course, "module": module,
93
+ "concepts": concepts.split('\n'),
94
  "existing_expectations": [
95
  Expectation(
96
  expectation=existing_expectation,
 
140
  feedback_inputs = {
141
  "expectation": response["expectation"], "check_question": response["check_question"], "request": feedback,
142
  "course": course, "module": module,
143
+ "concepts": concepts.split('\n'),
144
  }
145
  suggestions = rework.kickoff(
146
  inputs=feedback_inputs)
app/workflows/courses/expectation_revision.py CHANGED
@@ -9,7 +9,7 @@ import os
9
  class Inputs(BaseModel):
10
  course: str
11
  module: str
12
- tasks: List[str]
13
  expectation: str
14
  check_question: str
15
  request: str
@@ -26,7 +26,7 @@ class ExpectationRevision:
26
  self.request = inputs["request"]
27
  self.course = inputs["course"]
28
  self.module = inputs["module"]
29
- self.tasks = inputs["tasks"]
30
  llm_response = self._get_suggestion()
31
  return {
32
  "run_id": self.run_id,
@@ -51,7 +51,7 @@ class ExpectationRevision:
51
  with callbacks.collect_runs() as cb:
52
  response = chain.invoke({
53
  "learning_outcome": self.learning_outcome, "check_question": self.check_question, "request": self.request,
54
- "course": self.course, "module": self.module, "tasks": "* " + ("\n* ".join(self.tasks)),
55
  "format_instructions": parser.get_format_instructions()
56
  })
57
  self.run_id = cb.traced_runs[0].id
 
9
  class Inputs(BaseModel):
10
  course: str
11
  module: str
12
+ concepts: List[str]
13
  expectation: str
14
  check_question: str
15
  request: str
 
26
  self.request = inputs["request"]
27
  self.course = inputs["course"]
28
  self.module = inputs["module"]
29
+ self.concepts = inputs["concepts"]
30
  llm_response = self._get_suggestion()
31
  return {
32
  "run_id": self.run_id,
 
51
  with callbacks.collect_runs() as cb:
52
  response = chain.invoke({
53
  "learning_outcome": self.learning_outcome, "check_question": self.check_question, "request": self.request,
54
+ "course": self.course, "module": self.module, "concepts": "* " + ("\n* ".join(self.concepts)),
55
  "format_instructions": parser.get_format_instructions()
56
  })
57
  self.run_id = cb.traced_runs[0].id
app/workflows/courses/suggest_check_question.py CHANGED
@@ -10,7 +10,7 @@ import os
10
  class Inputs(BaseModel):
11
  course: str
12
  module: str
13
- tasks: List[str]
14
  expectation: str
15
 
16
 
@@ -30,7 +30,7 @@ class SuggestCheckQuestion:
30
  self.course = inputs["course"]
31
  self.module = inputs["module"]
32
  self.learning_outcome = inputs["expectation"]
33
- self.tasks = inputs["tasks"]
34
  llm_response = self._get_check_quesiton()
35
  return {
36
  "run_id": self.run_id,
@@ -44,7 +44,7 @@ class SuggestCheckQuestion:
44
 
45
  with callbacks.collect_runs() as cb:
46
  llm_response = chain.invoke({
47
- "course": self.course, "module": self.module, "tasks": "* " + ("\n* ".join(self.tasks)),
48
  "format_instructions": parser.get_format_instructions(),
49
  "learning_outcome": self.learning_outcome
50
  })
 
10
  class Inputs(BaseModel):
11
  course: str
12
  module: str
13
+ concepts: List[str]
14
  expectation: str
15
 
16
 
 
30
  self.course = inputs["course"]
31
  self.module = inputs["module"]
32
  self.learning_outcome = inputs["expectation"]
33
+ self.concepts = inputs["concepts"]
34
  llm_response = self._get_check_quesiton()
35
  return {
36
  "run_id": self.run_id,
 
44
 
45
  with callbacks.collect_runs() as cb:
46
  llm_response = chain.invoke({
47
+ "course": self.course, "module": self.module, "concepts": "* " + ("\n* ".join(self.concepts)),
48
  "format_instructions": parser.get_format_instructions(),
49
  "learning_outcome": self.learning_outcome
50
  })
app/workflows/courses/suggest_expectations.py CHANGED
@@ -27,7 +27,7 @@ class Response(BaseModel):
27
  class Inputs(BaseModel):
28
  course: str
29
  module: str
30
- tasks: List[str]
31
  existing_expectations: Optional[List[Expectation]]
32
 
33
 
@@ -36,7 +36,7 @@ class SuggestExpectations:
36
  self.course = inputs["course"]
37
  self.module = inputs["module"]
38
  self.existing_expectations = inputs["existing_expectations"]
39
- self.tasks = inputs["tasks"]
40
  llm_response = self._get_suggestions()
41
  return {
42
  "run_id": self.run_id,
@@ -63,7 +63,7 @@ class SuggestExpectations:
63
 
64
  with callbacks.collect_runs() as cb:
65
  llm_response = chain.invoke({
66
- "course": self.course, "module": self.module, "tasks": "* " + ("\n* ".join(self.tasks)),
67
  "format_instructions": parser.get_format_instructions(),
68
  "existing_expectations": existing_expectations_str
69
  })
@@ -73,7 +73,7 @@ class SuggestExpectations:
73
 
74
  def _build_chain(self):
75
  parser = JsonOutputParser(pydantic_object=Expectations)
76
- prompt = hub.pull("course_learn_suggest_expectations_from_learner")
77
  llm = ChatOpenAI(model=os.environ['OPENAI_MODEL'], temperature=0.2)
78
  chain = (prompt | llm | parser).with_config({
79
  "tags": ["course_learn", "suggest_expectations"], "run_name": "Suggest Module Expectations",
@@ -93,7 +93,7 @@ class SuggestExpectations:
93
  # response = suggester.kickoff(inputs={
94
  # "course": "SQL",
95
  # "module": "Query Optimization Techniques",
96
- # "tasks": [
97
  # "Watch this video https://youtu.be/BHwzDmr6d7s?si=sfFYnd73y9w0EjGB to understand SQL execution order and some optimization techniques.",
98
  # "Watch this video https://youtu.be/FoznjTU929c?si=6M3xUIUwAxE6EbKS to understand SQL explain command usage.",
99
  # "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."
 
27
  class Inputs(BaseModel):
28
  course: str
29
  module: str
30
+ concepts: List[str]
31
  existing_expectations: Optional[List[Expectation]]
32
 
33
 
 
36
  self.course = inputs["course"]
37
  self.module = inputs["module"]
38
  self.existing_expectations = inputs["existing_expectations"]
39
+ self.concepts = inputs["concepts"]
40
  llm_response = self._get_suggestions()
41
  return {
42
  "run_id": self.run_id,
 
63
 
64
  with callbacks.collect_runs() as cb:
65
  llm_response = chain.invoke({
66
+ "course": self.course, "module": self.module, "concepts": "* " + ("\n* ".join(self.concepts)),
67
  "format_instructions": parser.get_format_instructions(),
68
  "existing_expectations": existing_expectations_str
69
  })
 
73
 
74
  def _build_chain(self):
75
  parser = JsonOutputParser(pydantic_object=Expectations)
76
+ prompt = hub.pull("course_learn_suggest_expectations")
77
  llm = ChatOpenAI(model=os.environ['OPENAI_MODEL'], temperature=0.2)
78
  chain = (prompt | llm | parser).with_config({
79
  "tags": ["course_learn", "suggest_expectations"], "run_name": "Suggest Module Expectations",
 
93
  # response = suggester.kickoff(inputs={
94
  # "course": "SQL",
95
  # "module": "Query Optimization Techniques",
96
+ # "concepts": [
97
  # "Watch this video https://youtu.be/BHwzDmr6d7s?si=sfFYnd73y9w0EjGB to understand SQL execution order and some optimization techniques.",
98
  # "Watch this video https://youtu.be/FoznjTU929c?si=6M3xUIUwAxE6EbKS to understand SQL explain command usage.",
99
  # "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."
ui_main.py CHANGED
@@ -23,7 +23,7 @@ def common_sidebar():
23
  st.sidebar.markdown("### Pages")
24
  st.sidebar.button("Home", on_click=lambda: router.redirect(*router.build("show_main_page")))
25
  st.sidebar.button("TIL Feedback", on_click=lambda: router.redirect(*router.build("feedback_main_wrapper")))
26
- st.sidebar.button("Course Suggester", on_click=lambda: router.redirect(*router.build("course_suggester_main_wrapper")))
27
 
28
 
29
 
@@ -57,7 +57,7 @@ def show_main_page():
57
 
58
  card_info = [
59
  {"title": "TIL Feedback", "description": "Provide your valuable feedback.", "key": "feedback_main_wrapper", "image": "๐Ÿ“"},
60
- {"title": "Course Suggester", "description": "Get suggestions for courses", "key": "course_suggester_main_wrapper", "image": "๐Ÿ“š"},
61
 
62
  ]
63
 
@@ -139,7 +139,7 @@ def feedback_main_wrapper():
139
  common_sidebar()
140
  feedback_main()
141
 
142
- def course_suggester_main_wrapper():
143
  common_sidebar()
144
  course_suggester_main()
145
 
@@ -149,7 +149,7 @@ router = sr.StreamlitRouter()
149
 
150
  router.register(show_main_page, '/')
151
  router.register(feedback_main_wrapper, '/feedback', methods=['GET'])
152
- router.register(course_suggester_main_wrapper, '/course_suggester')
153
 
154
 
155
  router.serve()
 
23
  st.sidebar.markdown("### Pages")
24
  st.sidebar.button("Home", on_click=lambda: router.redirect(*router.build("show_main_page")))
25
  st.sidebar.button("TIL Feedback", on_click=lambda: router.redirect(*router.build("feedback_main_wrapper")))
26
+ st.sidebar.button("Course Suggester", on_click=lambda: router.redirect(*router.build("course_builder_main_wrapper")))
27
 
28
 
29
 
 
57
 
58
  card_info = [
59
  {"title": "TIL Feedback", "description": "Provide your valuable feedback.", "key": "feedback_main_wrapper", "image": "๐Ÿ“"},
60
+ {"title": "Course Builder", "description": "Get suggestions for building courses", "key": "course_builder_main_wrapper", "image": "๐Ÿ“š"},
61
 
62
  ]
63
 
 
139
  common_sidebar()
140
  feedback_main()
141
 
142
+ def course_builder_main_wrapper():
143
  common_sidebar()
144
  course_suggester_main()
145
 
 
149
 
150
  router.register(show_main_page, '/')
151
  router.register(feedback_main_wrapper, '/feedback', methods=['GET'])
152
+ router.register(course_builder_main_wrapper, '/course_builder')
153
 
154
 
155
  router.serve()