Spaces:
Runtime error
Runtime error
workflows(course_learn): Add support for existing expectations
Browse filesFiles changed (3)
123456789101112131450 unmodified lines656667686970from dotenv import load_dotenvimport uvicornfrom fastapi import FastAPI, Queryfrom .workflows.til import TilCrew, TilFeedbackResponsefrom .workflows.courses.suggest_expectations import SuggestExpectations, Inputs as SuggestExpectationsInputs, Expectations, Expectationfrom .workflows.courses.expectation_revision import ExpectationRevision, Inputs as ExpectationRevisionInputsfrom .workflows.utils.feedback import Feedbackfrom fastapi.middleware.cors import CORSMiddlewarefrom typing import List, Optionalfrom pydantic import UUID4, BaseModelload_dotenv()description = """API helps you do awesome stuff. 🚀50 unmodified lines"course": inputs.course,"module": inputs.module,"tasks": inputs.tasks,})return result12345678910111213141550 unmodified lines66676869707172from dotenv import load_dotenvload_dotenv()from .workflows.courses.expectation_revision import ExpectationRevision, Inputs as ExpectationRevisionInputsfrom .workflows.courses.suggest_expectations import SuggestExpectations, Inputs as SuggestExpectationsInputs, Expectations, Expectationfrom .workflows.til import TilCrew, TilFeedbackResponsefrom .workflows.utils.feedback import Feedbackfrom fastapi import FastAPI, Queryfrom fastapi.middleware.cors import CORSMiddlewarefrom pydantic import UUID4, BaseModelfrom typing import List, Optionalimport uvicorndescription = """API helps you do awesome stuff. 🚀50 unmodified lines"course": inputs.course,"module": inputs.module,"tasks": inputs.tasks,"existing_expectations": inputs.existing_expectations,})return result
1234558 unmodified lines646566676869707 unmodified lines78798081828384858687import streamlit as stfrom workflows.courses.suggest_expectations import SuggestExpectationsfrom streamlit_extras.stylable_container import stylable_containerfrom workflows.courses.expectation_revision import ExpectationRevision58 unmodified lines"Watch this video https://youtu.be/BHwzDmr6d7s?si=sfFYnd73y9w0EjGB to understand SQL execution order and some optimization techniques.","Watch this video https://youtu.be/FoznjTU929c?si=6M3xUIUwAxE6EbKS to understand SQL explain command usage.","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."]}st.session_state_inputs = st.session_state_inputs if 'session_state' in st.session_state else default_content7 unmodified lineshelp="Enter the name of the module", value=st.session_state_inputs["module"])tasks = st.text_area("##### Tasks", key="tasks", value="\n".join(st.session_state_inputs["tasks"]), help="Enter the tasks to be covered in the module")suggester = SuggestExpectations()inputs = {"course": course, "module": module,"tasks": tasks.split('\n')}if st.button("Get Suggestions", key="suggestions", help="Click to get suggestions"):responses = suggester.kickoff(inputs=inputs)1234558 unmodified lines6465666768697071727 unmodified lines8081828384858687888990919293949596979899100101import streamlit as stfrom workflows.courses.suggest_expectations import SuggestExpectations, Inputs as ExpectationsInputs, Expectationfrom streamlit_extras.stylable_container import stylable_containerfrom workflows.courses.expectation_revision import ExpectationRevision58 unmodified lines"Watch this video https://youtu.be/BHwzDmr6d7s?si=sfFYnd73y9w0EjGB to understand SQL execution order and some optimization techniques.","Watch this video https://youtu.be/FoznjTU929c?si=6M3xUIUwAxE6EbKS to understand SQL explain command usage.","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."],"expectation": "Should understand the importance of indexing in query optimization.","check_question": "How does indexing improve query performance?"}st.session_state_inputs = st.session_state_inputs if 'session_state' in st.session_state else default_content7 unmodified lineshelp="Enter the name of the module", value=st.session_state_inputs["module"])tasks = st.text_area("##### Tasks", key="tasks", value="\n".join(st.session_state_inputs["tasks"]), help="Enter the tasks to be covered in the module")existing_expectation = st.text_input("##### Existing Expectation", key="existing_expectation", value=st.session_state_inputs["expectation"])existing_check_question = st.text_input("##### Existing Check Question", key="existing_check_question", value=st.session_state_inputs["check_question"])suggester = SuggestExpectations()inputs = {"course": course, "module": module,"tasks": tasks.split('\n'),"existing_expectations": [Expectation(expectation=existing_expectation,check_question=existing_check_question)]}if st.button("Get Suggestions", key="suggestions", help="Click to get suggestions"):responses = suggester.kickoff(inputs=inputs)
6 unmodified lines78910111213141516171819202122232425262728293 unmodified lines333435363738391 unmodified line414243444546474849506 unmodified linesfrom typing import List, Optionalimport osclass Expectation(BaseModel):expectation: str = Field(description="The learning outcome that the course designer has identified for the learner to demonstrate upon successful completion of the module.")check_question: str = Field(description="Targeted question that the course designer have developed to assess the learner's understanding of the learning outcomes.")class Expectations(BaseModel):expectations: List[Expectation]class Inputs(BaseModel):course: strmodule: strtasks: List[str]class SuggestExpectations:def kickoff(self, inputs={}):self.course = inputs["course"]self.module = inputs["module"]self.tasks = inputs["tasks"]return self._get_suggestions()3 unmodified linesllm = ChatOpenAI(model=os.environ['OPENAI_MODEL'], temperature=0.2)chain = (prompt | llm | parser).with_config({"tags": ["course_learn", "suggest_expectations"], "run_name": "Suggest Module Expectations","metadata" : {"versoin": "v1.0.0","growth_activity": "course_learn","env": os.environ["ENV"],1 unmodified line}})response = chain.invoke({"course": self.course, "module": self.module, "tasks": "* " + ("\n* ".join(self.tasks)),"format_instructions": parser.get_format_instructions()})return response6 unmodified lines7891011121314151617181920212223242526272829303132333435363 unmodified lines404142434445461 unmodified line484950515253545556575859606162636465666 unmodified linesfrom typing import List, Optionalimport osclass Expectation(BaseModel):expectation: str = Field(description="The learning outcome that the course designer has identified for the learner to demonstrate upon successful completion of the module.")check_question: str = Field(description="Targeted question that the course designer have developed to assess the learner's understanding of the learning outcomes.")class Expectations(BaseModel):expectations: List[Expectation]class Inputs(BaseModel):course: strmodule: strtasks: List[str]existing_expectations: Optional[List[Expectation]]class SuggestExpectations:def kickoff(self, inputs={}):self.course = inputs["course"]self.module = inputs["module"]self.existing_expectations = inputs["existing_expectations"]self.tasks = inputs["tasks"]return self._get_suggestions()3 unmodified linesllm = ChatOpenAI(model=os.environ['OPENAI_MODEL'], temperature=0.2)chain = (prompt | llm | parser).with_config({"tags": ["course_learn", "suggest_expectations"], "run_name": "Suggest Module Expectations","metadata": {"versoin": "v1.0.0","growth_activity": "course_learn","env": os.environ["ENV"],1 unmodified line}})# Existing Expectationsexisting_expectations = []for expectation in self.existing_expectations:existing_expectations.append(f"""Learning Outcome: {expectation.expectation}Check Question: {expectation.check_question}""")response = chain.invoke({"course": self.course, "module": self.module, "tasks": "* " + ("\n* ".join(self.tasks)),"format_instructions": parser.get_format_instructions(),"existing_expectations": "\n".join(existing_expectations)})return response
endpoints.py+8-6
ui/course_learn_suggest_expectations.py+18-4
workflows/courses/suggest_expectations.py+21-5