Spaces:
Sleeping
Sleeping
Update learning_platform.py
Browse files- learning_platform.py +9 -1
learning_platform.py
CHANGED
|
@@ -88,6 +88,11 @@ class CourseBuilder:
|
|
| 88 |
async def plan_course(self, topic: str, difficulty: str) -> Dict[str, Any]:
|
| 89 |
prompt = self.prompts.course_planning_prompt().format(topic=topic, difficulty=difficulty)
|
| 90 |
response = await self.llm.apredict(prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
if not response:
|
| 93 |
raise ValueError("Empty response from API")
|
|
@@ -112,7 +117,10 @@ class CourseBuilder:
|
|
| 112 |
if not response:
|
| 113 |
raise ValueError("Empty response from API")
|
| 114 |
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
| 116 |
sections = [Section(**section) for section in content_json.get("sections", [])]
|
| 117 |
|
| 118 |
# Store embeddings for module content
|
|
|
|
| 88 |
async def plan_course(self, topic: str, difficulty: str) -> Dict[str, Any]:
|
| 89 |
prompt = self.prompts.course_planning_prompt().format(topic=topic, difficulty=difficulty)
|
| 90 |
response = await self.llm.apredict(prompt)
|
| 91 |
+
|
| 92 |
+
try:
|
| 93 |
+
course_plan = json.loads(response)
|
| 94 |
+
except json.JSONDecodeError as e:
|
| 95 |
+
raise ValueError(f"Invalid JSON response from API: {str(e)}")
|
| 96 |
|
| 97 |
if not response:
|
| 98 |
raise ValueError("Empty response from API")
|
|
|
|
| 117 |
if not response:
|
| 118 |
raise ValueError("Empty response from API")
|
| 119 |
|
| 120 |
+
try:
|
| 121 |
+
content_json = json.loads(response)
|
| 122 |
+
except json.JSONDecodeError as e:
|
| 123 |
+
raise ValueError(f"Invalid JSON response from API: {str(e)}")
|
| 124 |
sections = [Section(**section) for section in content_json.get("sections", [])]
|
| 125 |
|
| 126 |
# Store embeddings for module content
|