swcrazyfan commited on
Commit
6dad88d
1 Parent(s): 789a97f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+
4
+ openai.api_key = os.environ["OPENAI_API_KEY"]
5
+
6
+ def generate_pptx(lesson_topic):
7
+ prompt = (
8
+ "I need you to create PowerPoint slides based on a given lesson plan. Create a set of PowerPoint slides to help a teacher effectively teach the lesson described in the given lesson plan:\n"
9
+ f"{lesson_topic}\n\n"
10
+ "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."
11
+ "For the first slide, include the lesson title and any relevant sub-points. Choose a PowerPoint theme from these options: dark, light, corporate, or playful, depending on the lesson's context."
12
+ "The output should be suitable for use with the python-pptx library to create a PowerPoint presentation.\n\n"
13
+ "Lesson Plan:\n\n"
14
+ "lesson_plan_content\n\n"
15
+ "For each slide, provide this information:\n\n"
16
+ "#. Slide (slide_title):\n"
17
+ "Heading: concise_heading\n"
18
+ "Sub-point 1:\n"
19
+ "Sub-point 2:\n"
20
+ "...\n"
21
+ "If an image is relevant, include: 'Image: short_description_of_image'\n"
22
+ "If an icon is relevant, include: 'Icon: font_awesome_icon_code_for_python_library'\n\n"
23
+ "When creating the slides, remember to use clear and concise language, appropriate images or icons, and choose a suitable theme for the PowerPoint presentation."
24
+ )
25
+
26
+ response = openai.ChatCompletion.create(
27
+ model="gpt-3.5-turbo",
28
+ messages=[
29
+ {
30
+ "role": "system",
31
+ "content": (
32
+ "You are a helpful assistant capable of creating 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."
33
+ ),
34
+ },
35
+ {"role": "user", "content": prompt},
36
+ ],
37
+ max_tokens=1000,
38
+ n=1,
39
+ stop=None,
40
+ temperature=0.8,
41
+ top_p=0.9,
42
+ )
43
+
44
+ output = response.choices[0].text.strip()
45
+
46
+ return output
47
+
48
+ inputs = gr.inputs.Textbox(label="Lesson topic")
49
+ outputs = gr.outputs.Textbox(label="Generated text")
50
+
51
+ gr.Interface(fn=generate_pptx, inputs=inputs, outputs=outputs).launch()