swcrazyfan commited on
Commit
8c04b69
1 Parent(s): 4054c88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -35
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
- prompt = (
9
- "I need you to 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 the python library will understand without anything else'\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
- )
 
23
 
24
- response = openai.ChatCompletion.create(
25
- model="gpt-3.5-turbo",
26
- messages=[
27
- {
28
- "role": "system",
29
- "content": (
30
- "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."
31
- ),
32
- },
33
- {"role": "user", "content": prompt},
34
- ],
35
- max_tokens=1000,
36
- n=1,
37
- stop=None,
38
- temperature=0.7,
39
- top_p=0.8,
40
- )
41
-
42
- output = response.choices[0]['message']['content']
43
 
44
- return output
 
 
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")