Spaces:
Running
Running
Commit
·
aad5bbc
1
Parent(s):
2452397
111
Browse files
app.py
CHANGED
@@ -175,20 +175,20 @@ def generateCourse(topic, materials, language, style_options):
|
|
175 |
system_message = 'You are a great AI teacher and linguist, skilled at writing informative and easy-to-understand course script based on given lesson topic and knowledge materials.'
|
176 |
|
177 |
user_message = f"""You are a great AI teacher and linguist,
|
178 |
-
skilled at writing informative and easy-to-understand course script based on given lesson topic and knowledge materials
|
179 |
-
You should write a course for new hands, they need detailed and vivid explaination to understand the topic.
|
180 |
-
A high-quality course should meet requirements below
|
181 |
-
(1) Contains enough facts, data and figures to be convincing
|
182 |
-
(2) The internal narrative is layered and logical, not a simple pile of items
|
183 |
-
Make sure all these requirements are considered when writing the lesson script content
|
184 |
-
Please follow this procedure step-by-step when disgning the course
|
185 |
-
Step 1. Write down the teaching purpose of the lesson initially in the script.
|
186 |
-
Step 2. Write down the outline of this lesson (outline is aligned to the teaching purpose), then follow the outline to write the content. Make sure every concept in the outline is explined adequately in the course.
|
187 |
-
Your lesson topic and abstract is within the 「」 quotes, and the knowledge materials are within the 【】 brackets.
|
188 |
-
lesson topic and abstract: 「{topic}」,
|
189 |
-
knowledge materials related to this lesson:【{materials} 】
|
190 |
-
the script should be witten in {language}, and mathematical symbols should be written in markdown form.
|
191 |
-
{style_options}
|
192 |
Start writting the script of this lesson now.
|
193 |
"""
|
194 |
|
@@ -251,14 +251,14 @@ def initialize_outline(temp_file_paths, num_lessons, language):
|
|
251 |
|
252 |
return course_outline_list
|
253 |
|
254 |
-
def initialize_content(course_outline_list, embeddings_df, faiss_index, language):
|
255 |
count_generating_content = 0
|
256 |
course_content_list = []
|
257 |
for lesson in course_outline_list:
|
258 |
count_generating_content += 1
|
259 |
with st.spinner(f"Writing content for lesson {count_generating_content}..."):
|
260 |
retrievedChunksList = searchVDB(lesson, embeddings_df, faiss_index)
|
261 |
-
courseContent = generateCourse(lesson, retrievedChunksList, language)
|
262 |
course_content_list.append(courseContent)
|
263 |
st.success(f"Writing content for lesson {count_generating_content}...Done")
|
264 |
with st.expander(f"Learn the lesson {count_generating_content} ", expanded=False):
|
@@ -382,8 +382,8 @@ def app():
|
|
382 |
#initialize app
|
383 |
temp_file_paths = initialize_file(added_files)
|
384 |
st.session_state.embeddings_df, st.session_state.faiss_index = initialize_vdb(temp_file_paths)
|
385 |
-
st.session_state.course_outline_list = initialize_outline(temp_file_paths, num_lessons, language
|
386 |
-
st.session_state.course_content_list = initialize_content(st.session_state.course_outline_list, st.session_state.embeddings_df, st.session_state.faiss_index, language)
|
387 |
|
388 |
st.markdown('''
|
389 |
> 🤔 <font color = 'grey'> **Not satisfied with this course?** Simply click "Generate my course!" button to regenerate a new one! </font>
|
|
|
175 |
system_message = 'You are a great AI teacher and linguist, skilled at writing informative and easy-to-understand course script based on given lesson topic and knowledge materials.'
|
176 |
|
177 |
user_message = f"""You are a great AI teacher and linguist,
|
178 |
+
skilled at writing informative and easy-to-understand course script based on given lesson topic and knowledge materials.\n
|
179 |
+
You should write a course for new hands, they need detailed and vivid explaination to understand the topic. \n
|
180 |
+
A high-quality course should meet requirements below:\n
|
181 |
+
(1) Contains enough facts, data and figures to be convincing\n
|
182 |
+
(2) The internal narrative is layered and logical, not a simple pile of items\n
|
183 |
+
Make sure all these requirements are considered when writing the lesson script content.\n
|
184 |
+
Please follow this procedure step-by-step when disgning the course:\n
|
185 |
+
Step 1. Write down the teaching purpose of the lesson initially in the script. \n
|
186 |
+
Step 2. Write down the outline of this lesson (outline is aligned to the teaching purpose), then follow the outline to write the content. Make sure every concept in the outline is explined adequately in the course. \n
|
187 |
+
Your lesson topic and abstract is within the 「」 quotes, and the knowledge materials are within the 【】 brackets. \n
|
188 |
+
lesson topic and abstract: 「{topic}」, \n
|
189 |
+
knowledge materials related to this lesson:【{materials} 】 \n
|
190 |
+
the script should be witten in {language}, and mathematical symbols should be written in markdown form. \n
|
191 |
+
{style_options} \n
|
192 |
Start writting the script of this lesson now.
|
193 |
"""
|
194 |
|
|
|
251 |
|
252 |
return course_outline_list
|
253 |
|
254 |
+
def initialize_content(course_outline_list, embeddings_df, faiss_index, language, style_options):
|
255 |
count_generating_content = 0
|
256 |
course_content_list = []
|
257 |
for lesson in course_outline_list:
|
258 |
count_generating_content += 1
|
259 |
with st.spinner(f"Writing content for lesson {count_generating_content}..."):
|
260 |
retrievedChunksList = searchVDB(lesson, embeddings_df, faiss_index)
|
261 |
+
courseContent = generateCourse(lesson, retrievedChunksList, language, style_options)
|
262 |
course_content_list.append(courseContent)
|
263 |
st.success(f"Writing content for lesson {count_generating_content}...Done")
|
264 |
with st.expander(f"Learn the lesson {count_generating_content} ", expanded=False):
|
|
|
382 |
#initialize app
|
383 |
temp_file_paths = initialize_file(added_files)
|
384 |
st.session_state.embeddings_df, st.session_state.faiss_index = initialize_vdb(temp_file_paths)
|
385 |
+
st.session_state.course_outline_list = initialize_outline(temp_file_paths, num_lessons, language)
|
386 |
+
st.session_state.course_content_list = initialize_content(st.session_state.course_outline_list, st.session_state.embeddings_df, st.session_state.faiss_index, language, style_options)
|
387 |
|
388 |
st.markdown('''
|
389 |
> 🤔 <font color = 'grey'> **Not satisfied with this course?** Simply click "Generate my course!" button to regenerate a new one! </font>
|