Spaces:
Sleeping
Sleeping
def _build_user_content(self):
Browse files- educational_material.py +30 -28
educational_material.py
CHANGED
|
@@ -34,7 +34,7 @@ class EducationalMaterial:
|
|
| 34 |
|
| 35 |
def get_ai_content(self, AI_Client ,ai_type="openai"):
|
| 36 |
system_content = self.system_content
|
| 37 |
-
user_content = self.
|
| 38 |
if ai_type.lower() == "openai":
|
| 39 |
return self.send_openai_request(AI_Client, system_content, user_content)
|
| 40 |
elif ai_type.lower() == "bedrock":
|
|
@@ -42,6 +42,34 @@ class EducationalMaterial:
|
|
| 42 |
else:
|
| 43 |
raise ValueError("Unsupported AI type. Please choose 'openai' or 'redrock'.")
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
def get_fine_tuned_ai_content(self, ai_client, ai_type, original_prompt, result, fine_tune_prompt):
|
| 46 |
system_content = self.system_content
|
| 47 |
user_content = self._build_fine_tune_user_content(original_prompt, result, fine_tune_prompt)
|
|
@@ -501,32 +529,6 @@ class EducationalMaterial:
|
|
| 501 |
"""
|
| 502 |
return exit_ticket_prompt
|
| 503 |
|
| 504 |
-
|
| 505 |
-
if self.content_type == 'worksheet':
|
| 506 |
-
specific_feature_text = f"理論模型: {self.specific_feature}"
|
| 507 |
-
elif self.content_type == 'lesson_plan':
|
| 508 |
-
specific_feature_text = f"時間: {self.specific_feature} 分鐘"
|
| 509 |
-
elif self.content_type == 'exit_ticket':
|
| 510 |
-
specific_feature_text = f"時間: {self.specific_feature} 分鐘"
|
| 511 |
-
|
| 512 |
-
# 根据属性构建用户内容
|
| 513 |
-
user_content = f"""
|
| 514 |
-
課程脈絡 or 逐字稿:{self.context}
|
| 515 |
-
主題:{self.topic}
|
| 516 |
-
年級:{self.grade}
|
| 517 |
-
難度:{self.level}
|
| 518 |
-
{specific_feature_text}
|
| 519 |
-
|
| 520 |
-
請根據逐字稿進行以下工作:
|
| 521 |
-
- 不要提到 【逐字稿】 這個詞,直接給出內容即可
|
| 522 |
-
- 遇到數學符號或是敘述請用 Latex 語法($...$),例如:$x^2$。
|
| 523 |
-
- 如果是中文素材,請嚴格使用 zh-TW
|
| 524 |
-
- 請用 {self.grade} 年級的口吻,不要用太難的詞彙
|
| 525 |
-
- {self.generate_content_prompt()}
|
| 526 |
-
"""
|
| 527 |
-
print("====User content====")
|
| 528 |
-
print(user_content)
|
| 529 |
-
print("====User content====")
|
| 530 |
-
return user_content
|
| 531 |
|
| 532 |
|
|
|
|
| 34 |
|
| 35 |
def get_ai_content(self, AI_Client ,ai_type="openai"):
|
| 36 |
system_content = self.system_content
|
| 37 |
+
user_content = self._build_user_content()
|
| 38 |
if ai_type.lower() == "openai":
|
| 39 |
return self.send_openai_request(AI_Client, system_content, user_content)
|
| 40 |
elif ai_type.lower() == "bedrock":
|
|
|
|
| 42 |
else:
|
| 43 |
raise ValueError("Unsupported AI type. Please choose 'openai' or 'redrock'.")
|
| 44 |
|
| 45 |
+
def _build_user_content(self):
|
| 46 |
+
if self.content_type == 'worksheet':
|
| 47 |
+
specific_feature_text = f"理論模型: {self.specific_feature}"
|
| 48 |
+
elif self.content_type == 'lesson_plan':
|
| 49 |
+
specific_feature_text = f"時間: {self.specific_feature} 分鐘"
|
| 50 |
+
elif self.content_type == 'exit_ticket':
|
| 51 |
+
specific_feature_text = f"時間: {self.specific_feature} 分鐘"
|
| 52 |
+
|
| 53 |
+
# 根据属性构建用户内容
|
| 54 |
+
user_content = f"""
|
| 55 |
+
課程脈絡 or 逐字稿:{self.context}
|
| 56 |
+
主題:{self.topic}
|
| 57 |
+
年級:{self.grade}
|
| 58 |
+
難度:{self.level}
|
| 59 |
+
{specific_feature_text}
|
| 60 |
+
|
| 61 |
+
請根據逐字稿進行以下工作:
|
| 62 |
+
- 不要提到 【逐字稿】 這個詞,直接給出內容即可
|
| 63 |
+
- 遇到數學符號或是敘述請用 Latex 語法($...$),例如:$x^2$。
|
| 64 |
+
- 如果是中文素材,請嚴格使用 zh-TW
|
| 65 |
+
- 請用 {self.grade} 年級的口吻,不要用太難的詞彙
|
| 66 |
+
- {self.generate_content_prompt()}
|
| 67 |
+
"""
|
| 68 |
+
print("====User content====")
|
| 69 |
+
print(user_content)
|
| 70 |
+
print("====User content====")
|
| 71 |
+
return user_content
|
| 72 |
+
|
| 73 |
def get_fine_tuned_ai_content(self, ai_client, ai_type, original_prompt, result, fine_tune_prompt):
|
| 74 |
system_content = self.system_content
|
| 75 |
user_content = self._build_fine_tune_user_content(original_prompt, result, fine_tune_prompt)
|
|
|
|
| 529 |
"""
|
| 530 |
return exit_ticket_prompt
|
| 531 |
|
| 532 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
|
| 534 |
|