Spaces:
Runtime error
Runtime error
workflows(expectation_revision): Refactor to support new prompt
Browse files
ui/course_learn_suggest_expectations.py
CHANGED
|
@@ -136,7 +136,10 @@ def main():
|
|
| 136 |
if st.button("Reload suggestions", key=f"reload_{response['expectation']}"):
|
| 137 |
rework = ExpectationRevision()
|
| 138 |
feedback_inputs = {
|
| 139 |
-
"expectation": response["expectation"], "check_question": response["check_question"], "request": feedback
|
|
|
|
|
|
|
|
|
|
| 140 |
suggestions = rework.kickoff(
|
| 141 |
inputs=feedback_inputs)
|
| 142 |
st.write(suggestions)
|
|
|
|
| 136 |
if st.button("Reload suggestions", key=f"reload_{response['expectation']}"):
|
| 137 |
rework = ExpectationRevision()
|
| 138 |
feedback_inputs = {
|
| 139 |
+
"expectation": response["expectation"], "check_question": response["check_question"], "request": feedback,
|
| 140 |
+
"course": course, "module": module,
|
| 141 |
+
"tasks": tasks.split('\n'),
|
| 142 |
+
}
|
| 143 |
suggestions = rework.kickoff(
|
| 144 |
inputs=feedback_inputs)
|
| 145 |
st.write(suggestions)
|
workflows/courses/expectation_revision.py
CHANGED
|
@@ -3,9 +3,13 @@ from langchain_core.output_parsers import JsonOutputParser
|
|
| 3 |
from langchain_openai import ChatOpenAI
|
| 4 |
from pydantic import BaseModel, UUID4
|
| 5 |
from .suggest_expectations import Expectation
|
|
|
|
| 6 |
import os
|
| 7 |
|
| 8 |
class Inputs(BaseModel):
|
|
|
|
|
|
|
|
|
|
| 9 |
expectation: str
|
| 10 |
check_question: str
|
| 11 |
request: str
|
|
@@ -20,6 +24,9 @@ class ExpectationRevision:
|
|
| 20 |
self.learning_outcome = inputs["expectation"]
|
| 21 |
self.check_question = inputs["check_question"]
|
| 22 |
self.request = inputs["request"]
|
|
|
|
|
|
|
|
|
|
| 23 |
llm_response = self._get_suggestion()
|
| 24 |
return {
|
| 25 |
"run_id": self.run_id,
|
|
@@ -44,6 +51,7 @@ class ExpectationRevision:
|
|
| 44 |
with callbacks.collect_runs() as cb:
|
| 45 |
response = chain.invoke({
|
| 46 |
"learning_outcome": self.learning_outcome, "check_question": self.check_question, "request": self.request,
|
|
|
|
| 47 |
"format_instructions": parser.get_format_instructions()
|
| 48 |
})
|
| 49 |
self.run_id = cb.traced_runs[0].id
|
|
|
|
| 3 |
from langchain_openai import ChatOpenAI
|
| 4 |
from pydantic import BaseModel, UUID4
|
| 5 |
from .suggest_expectations import Expectation
|
| 6 |
+
from typing import List
|
| 7 |
import os
|
| 8 |
|
| 9 |
class Inputs(BaseModel):
|
| 10 |
+
course: str
|
| 11 |
+
module: str
|
| 12 |
+
tasks: List[str]
|
| 13 |
expectation: str
|
| 14 |
check_question: str
|
| 15 |
request: str
|
|
|
|
| 24 |
self.learning_outcome = inputs["expectation"]
|
| 25 |
self.check_question = inputs["check_question"]
|
| 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 |
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
|