theRealNG commited on
Commit
e25475d
·
1 Parent(s): 5bbcaf1

workflows(course_learn): Add support for existing expectations

Browse files
endpoints.py CHANGED
@@ -1,14 +1,15 @@
1
  from dotenv import load_dotenv
2
- import uvicorn
3
- from fastapi import FastAPI, Query
4
- from .workflows.til import TilCrew, TilFeedbackResponse
5
- from .workflows.courses.suggest_expectations import SuggestExpectations, Inputs as SuggestExpectationsInputs, Expectations, Expectation
6
  from .workflows.courses.expectation_revision import ExpectationRevision, Inputs as ExpectationRevisionInputs
 
 
7
  from .workflows.utils.feedback import Feedback
 
8
  from fastapi.middleware.cors import CORSMiddleware
9
- from typing import List, Optional
10
  from pydantic import UUID4, BaseModel
11
- load_dotenv()
 
12
 
13
  description = """
14
  API helps you do awesome stuff. 🚀
@@ -65,6 +66,7 @@ async def course_learn_suggest_expectations(inputs: SuggestExpectationsInputs) -
65
  "course": inputs.course,
66
  "module": inputs.module,
67
  "tasks": inputs.tasks,
 
68
  })
69
  return result
70
 
 
1
  from dotenv import load_dotenv
2
+ load_dotenv()
3
+
 
 
4
  from .workflows.courses.expectation_revision import ExpectationRevision, Inputs as ExpectationRevisionInputs
5
+ from .workflows.courses.suggest_expectations import SuggestExpectations, Inputs as SuggestExpectationsInputs, Expectations, Expectation
6
+ from .workflows.til import TilCrew, TilFeedbackResponse
7
  from .workflows.utils.feedback import Feedback
8
+ from fastapi import FastAPI, Query
9
  from fastapi.middleware.cors import CORSMiddleware
 
10
  from pydantic import UUID4, BaseModel
11
+ from typing import List, Optional
12
+ import uvicorn
13
 
14
  description = """
15
  API helps you do awesome stuff. 🚀
 
66
  "course": inputs.course,
67
  "module": inputs.module,
68
  "tasks": inputs.tasks,
69
+ "existing_expectations": inputs.existing_expectations,
70
  })
71
  return result
72
 
ui/course_learn_suggest_expectations.py CHANGED
@@ -1,5 +1,5 @@
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
 
@@ -64,7 +64,9 @@ def main():
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
@@ -78,10 +80,22 @@ def main():
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)
 
1
  import streamlit as st
2
+ from workflows.courses.suggest_expectations import SuggestExpectations, Inputs as ExpectationsInputs, Expectation
3
  from streamlit_extras.stylable_container import stylable_container
4
  from workflows.courses.expectation_revision import ExpectationRevision
5
 
 
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
+ "expectation": "Should understand the importance of indexing in query optimization.",
69
+ "check_question": "How does indexing improve query performance?"
70
  }
71
 
72
  st.session_state_inputs = st.session_state_inputs if 'session_state' in st.session_state else default_content
 
80
  help="Enter the name of the module", value=st.session_state_inputs["module"])
81
  tasks = st.text_area("##### Tasks", key="tasks", value="\n".join(
82
  st.session_state_inputs["tasks"]), help="Enter the tasks to be covered in the module")
83
+ existing_expectation = st.text_input(
84
+ "##### Existing Expectation", key="existing_expectation", value=st.session_state_inputs["expectation"])
85
+ existing_check_question = st.text_input(
86
+ "##### Existing Check Question", key="existing_check_question", value=st.session_state_inputs["check_question"])
87
 
88
  suggester = SuggestExpectations()
89
+ inputs = {
90
+ "course": course, "module": module,
91
+ "tasks": tasks.split('\n'),
92
+ "existing_expectations": [
93
+ Expectation(
94
+ expectation=existing_expectation,
95
+ check_question=existing_check_question
96
+ )
97
+ ]
98
+ }
99
 
100
  if st.button("Get Suggestions", key="suggestions", help="Click to get suggestions"):
101
  responses = suggester.kickoff(inputs=inputs)
workflows/courses/suggest_expectations.py CHANGED
@@ -7,23 +7,30 @@ from pydantic import BaseModel
7
  from typing import List, Optional
8
  import os
9
 
 
10
  class Expectation(BaseModel):
11
- expectation: str = Field(description="The learning outcome that the course designer has identified for the learner to demonstrate upon successful completion of the module.")
12
- check_question: str = Field(description="Targeted question that the course designer have developed to assess the learner's understanding of the learning outcomes.")
 
 
 
13
 
14
  class Expectations(BaseModel):
15
  expectations: List[Expectation]
16
 
 
17
  class Inputs(BaseModel):
18
  course: str
19
  module: str
20
  tasks: List[str]
 
21
 
22
 
23
  class SuggestExpectations:
24
  def kickoff(self, inputs={}):
25
  self.course = inputs["course"]
26
  self.module = inputs["module"]
 
27
  self.tasks = inputs["tasks"]
28
  return self._get_suggestions()
29
 
@@ -33,7 +40,7 @@ class SuggestExpectations:
33
  llm = ChatOpenAI(model=os.environ['OPENAI_MODEL'], temperature=0.2)
34
  chain = (prompt | llm | parser).with_config({
35
  "tags": ["course_learn", "suggest_expectations"], "run_name": "Suggest Module Expectations",
36
- "metadata" : {
37
  "versoin": "v1.0.0",
38
  "growth_activity": "course_learn",
39
  "env": os.environ["ENV"],
@@ -41,10 +48,19 @@ class SuggestExpectations:
41
  }
42
  })
43
 
 
 
 
 
 
 
 
 
44
  response = chain.invoke({
45
  "course": self.course, "module": self.module, "tasks": "* " + ("\n* ".join(self.tasks)),
46
- "format_instructions": parser.get_format_instructions()
47
- })
 
48
 
49
  return response
50
 
 
7
  from typing import List, Optional
8
  import os
9
 
10
+
11
  class Expectation(BaseModel):
12
+ expectation: str = Field(
13
+ description="The learning outcome that the course designer has identified for the learner to demonstrate upon successful completion of the module.")
14
+ check_question: str = Field(
15
+ description="Targeted question that the course designer have developed to assess the learner's understanding of the learning outcomes.")
16
+
17
 
18
  class Expectations(BaseModel):
19
  expectations: List[Expectation]
20
 
21
+
22
  class Inputs(BaseModel):
23
  course: str
24
  module: str
25
  tasks: List[str]
26
+ existing_expectations: Optional[List[Expectation]]
27
 
28
 
29
  class SuggestExpectations:
30
  def kickoff(self, inputs={}):
31
  self.course = inputs["course"]
32
  self.module = inputs["module"]
33
+ self.existing_expectations = inputs["existing_expectations"]
34
  self.tasks = inputs["tasks"]
35
  return self._get_suggestions()
36
 
 
40
  llm = ChatOpenAI(model=os.environ['OPENAI_MODEL'], temperature=0.2)
41
  chain = (prompt | llm | parser).with_config({
42
  "tags": ["course_learn", "suggest_expectations"], "run_name": "Suggest Module Expectations",
43
+ "metadata": {
44
  "versoin": "v1.0.0",
45
  "growth_activity": "course_learn",
46
  "env": os.environ["ENV"],
 
48
  }
49
  })
50
 
51
+ # Existing Expectations
52
+ existing_expectations = []
53
+ for expectation in self.existing_expectations:
54
+ existing_expectations.append(f"""
55
+ Learning Outcome: {expectation.expectation}
56
+ Check Question: {expectation.check_question}
57
+ """)
58
+
59
  response = chain.invoke({
60
  "course": self.course, "module": self.module, "tasks": "* " + ("\n* ".join(self.tasks)),
61
+ "format_instructions": parser.get_format_instructions(),
62
+ "existing_expectations": "\n".join(existing_expectations)
63
+ })
64
 
65
  return response
66