Spaces:
Build error
Build error
Commit
•
8c04b69
1
Parent(s):
4054c88
Update app.py
Browse files
app.py
CHANGED
@@ -5,43 +5,44 @@ import os
|
|
5 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
6 |
|
7 |
def generate_pptx(lesson_topic):
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
output = response.choices[0]['message']['content']
|
43 |
|
44 |
-
|
|
|
|
|
45 |
|
46 |
inputs = gr.inputs.Textbox(label="Lesson topic")
|
47 |
outputs = gr.outputs.Textbox(label="Generated text")
|
|
|
5 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
6 |
|
7 |
def generate_pptx(lesson_topic):
|
8 |
+
prompt = (
|
9 |
+
"Create a set of engaging PowerPoint slides that will help teachers summarize and emphasize key points for their students during a lesson. The slides should be visually engaging and include concise headings, bullet points, and relevant images or icons. Make sure to provide any necessary information, such as activity steps or reflection questions. Limit each slide to a maximum of 3-4 sub-points and a single image or icon when relevant. If necessary, divide the same heading into multiple slides to make the points more clear."
|
10 |
+
"\n\nFor the first slide, include the lesson title and any relevant sub-points such as. Also, include a closing slide with takeaways from the lesson. Choose a PowerPoint theme from these options: dark, light, corporate, or playful, depending on the lesson's context."
|
11 |
+
"\n\nThe output should be suitable for use with the python-pptx library to create a PowerPoint presentation.\n\n"
|
12 |
+
"Lesson Plan: {lesson_topic}\n\n"
|
13 |
+
"For each slide, provide this information:\n\n"
|
14 |
+
"#. Slide (slide_title):\n"
|
15 |
+
"Heading: concise_heading\n"
|
16 |
+
"Sub-point 1:\n"
|
17 |
+
"Sub-point 2:\n"
|
18 |
+
"...\n"
|
19 |
+
"If an image is relevant, include: 'Image: short_description_of_image'\n"
|
20 |
+
"If an icon is relevant, include: 'Icon: font_awesome_icon_code'\n\n"
|
21 |
+
"When creating the slides, remember to use clear and concise language, write the slides for the students to understand, and use appropriate images or icons, and choose a suitable theme for the PowerPoint presentation."
|
22 |
+
.format(lesson_topic=lesson_topic)
|
23 |
+
)
|
24 |
|
25 |
+
response = openai.ChatCompletion.create(
|
26 |
+
model="gpt-3.5-turbo",
|
27 |
+
messages=[
|
28 |
+
{
|
29 |
+
"role": "system",
|
30 |
+
"content": (
|
31 |
+
"You are a helpful assistant capable of creating clear and concise PowerPoint slide outlines based on a given lesson plan. Ensure that the slides include concise headings, bullet points, relevant images or icons, and any necessary information such as activity steps or reflection questions. Limit each slide to a maximum of 3-4 sub-points and a single image or icon when relevant."
|
32 |
+
),
|
33 |
+
},
|
34 |
+
{"role": "user", "content": prompt},
|
35 |
+
],
|
36 |
+
max_tokens=1000,
|
37 |
+
n=1,
|
38 |
+
stop=None,
|
39 |
+
temperature=0.5,
|
40 |
+
top_p=0.9,
|
41 |
+
)
|
|
|
|
|
42 |
|
43 |
+
output = response.choices[0]['message']['content']
|
44 |
+
|
45 |
+
return output
|
46 |
|
47 |
inputs = gr.inputs.Textbox(label="Lesson topic")
|
48 |
outputs = gr.outputs.Textbox(label="Generated text")
|