File size: 2,686 Bytes
6dad88d
 
2ea5ec0
6dad88d
 
 
 
 
f55edda
b88bca6
 
4054c88
b88bca6
 
 
 
 
 
 
 
08430ae
6dad88d
 
 
 
 
 
 
 
adf1477
6dad88d
 
 
 
 
 
 
b88bca6
08430ae
6dad88d
 
567db67
6dad88d
 
 
 
 
 
 
1
2
3
4
5
6
7
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
43
44
45
46
47
48
49
import gradio as gr
import openai
import os

openai.api_key = os.environ["OPENAI_API_KEY"]

def generate_pptx(lesson_topic):
	prompt = (
	"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."
    "\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."
    "\n\nThe output should be suitable for use with the python-pptx library to create a PowerPoint presentation.\n\n"
    "Lesson Plan: {lesson_topic}\n\n"
    "For each slide, provide this information:\n\n"
    "#. Slide (slide_title):\n"
    "Heading: concise_heading\n"
    "Sub-point 1:\n"
    "Sub-point 2:\n"
    "...\n"
    "If an image is relevant, include: 'Image: short_description_of_image'\n"
    "If an icon is relevant, include: 'Icon: font_awesome_icon_code the python library will understand without anything else'\n\n"
    "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."
	)

	response = openai.ChatCompletion.create(
    	model="gpt-3.5-turbo",
    	messages=[
        	{
            	"role": "system",
            	"content": (
                	"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."
            	),
        	},
        	{"role": "user", "content": prompt},
    	],
    	max_tokens=1000,
    	n=1,
    	stop=None,
    	temperature=0.7,
    	top_p=0.8,
	)
	
	output = response.choices[0]['message']['content']

	return output

inputs = gr.inputs.Textbox(label="Lesson topic")
outputs = gr.outputs.Textbox(label="Generated text")

gr.Interface(fn=generate_pptx, inputs=inputs, outputs=outputs).launch()