File size: 2,361 Bytes
6dad88d
 
2ea5ec0
6dad88d
 
 
 
8c04b69
954adda
9cc92d3
 
1d1ee01
9cc92d3
8c04b69
 
 
 
 
 
9cc92d3
8c04b69
 
 
6dad88d
8c04b69
37a1ea2
8c04b69
 
 
 
b2bf675
8c04b69
 
 
 
 
 
 
72c943d
b2bf675
8c04b69
6dad88d
8c04b69
 
 
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
50
import gradio as gr
import openai
import os

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

def generate_pptx(lesson_topic):
    prompt = (
        "Create PowerPoint slides for a lesson plan. The slides should be visually engaging, include concise headings and bullet points, and have relevant images or icons when necessary. Limit each slide to a maximum of 4 sub-points and a single image or icon when relevant. Divide the same heading into multiple slides if required to make the points more clear."
        "\n\nFor the first slide, include the lesson title and relevant sub-points. 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\nLesson Plan:\n{lesson_topic}"
        "\n\nFor 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'\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."
        .format(lesson_topic=lesson_topic)
    )

    response = openai.ChatCompletion.create(
        model="gpt-4",
        messages=[
            {
                "role": "system",
                "content": (
                    "You are a helpful assistant capable of creating clear and concise PowerPoint slide outlines used by teachers during their lessons based on a given lesson plan."
                ),
            },
            {"role": "user", "content": prompt},
        ],
        max_tokens=1000,
        n=1,
        stop=None,
        temperature=0.7,
 #       top_p=0.9,
    )

    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()