kshitij10000 commited on
Commit
84ec5f5
Β·
1 Parent(s): a80a9c2

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -120
app.py DELETED
@@ -1,120 +0,0 @@
1
- import openai
2
- import json
3
- from pptx import Presentation
4
- import streamlit as st
5
- import os
6
-
7
- # Suppress all warnings
8
- import warnings
9
- warnings.filterwarnings("ignore")
10
-
11
- # Set your OpenAI API key
12
- openai.api_key = "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"
13
-
14
- # Streamlit app title and header
15
- st.title("🌟 PowerPoint Presentation Generator 🌟")
16
- st.header("Welcome to the Future of Presentation Creation!")
17
-
18
- # Introduction
19
- st.markdown(
20
- """
21
- Creating presentations has never been this easy and exciting! With our AI-powered model, you can quickly generate presentation content, while the design remains your creative canvas. 🎨
22
-
23
- Here's what we do:
24
- - **You provide the presentation topic**, and we add captivating content.
25
- - Our AI ensures **each slide has the perfect balance of information**.
26
- - Stay tuned for **exciting future features** that will enhance your presentation experience. πŸš€
27
- """
28
- )
29
-
30
- # Presentation Limits
31
- st.subheader("πŸ“Š Presentation Limits (for now, subject to change in future updates) πŸ“Š")
32
- st.write("✨ You can create a minimum of 3 and a maximum of 8 slides per presentation.")
33
- st.write("✨ Each slide should have between 3 and 7 points of content.")
34
- st.write("✨ Minimum 3 points, maximum 7 points. ⚠️")
35
-
36
- # Important Notice
37
- st.warning("⚠️ Important Notice: Occasional download issues? Try re-downloading or reach out to us for assistance. We apologize for any inconvenience.")
38
-
39
- # Contact and Feedback
40
- st.subheader("πŸ“ž Contact and Feedback πŸ“ž")
41
- st.write("Have questions, ideas, or cool suggestions for future enhancements? We're all ears!")
42
- st.write("Your feedback is invaluable in making your experience the best it can be! 🌟")
43
-
44
- # Input for presentation topic
45
- presentation_title = st.text_input("πŸ“ Enter your presentation topic:")
46
- no_of_pages = st.number_input("πŸ“Š Number of slides you want (3-8)", min_value=3, max_value=8, value=3)
47
- least_c = st.number_input("πŸ“Š Minimum points in each slide (3-7)", min_value=3, max_value=7, value=3)
48
- max_c = st.number_input("πŸ“Š Maximum points in each slide (4-7)", min_value=4, max_value=7, value=7)
49
-
50
- # Check if any input values are out of range
51
- if no_of_pages > 8 or no_of_pages < 3 or least_c > 7 or least_c < 3 or max_c > 7 or max_c < 4:
52
- st.warning("Invalid input values. Please ensure that your inputs are within the specified limits.")
53
- else:
54
- if st.button("Generate Presentation"):
55
- # Check if the user has entered a topic
56
- if presentation_title:
57
- question = (
58
- f"generate a {no_of_pages} slide presentation for the topic {presentation_title}."
59
- f" Each slide should have {{header}}, {{content}}, should have at least {least_c} points and max {max_c} points in content. Return as JSON"
60
- )
61
-
62
- query_json = {
63
- "input_text": question,
64
- "output_format": "json",
65
- "json_structure": {"slides": "{{presentation_slides}}"},
66
- }
67
-
68
- # Send the query to OpenAI
69
- completion = openai.ChatCompletion.create(
70
- model="gpt-3.5-turbo",
71
- messages=[{"role": "user", "content": json.dumps(query_json)}],
72
- )
73
-
74
- try:
75
- response = json.loads(completion.choices[0].message.content)
76
-
77
- slide_data = response["slides"]
78
-
79
- prs = Presentation()
80
-
81
- from pptx.util import Pt
82
- from pptx.enum.text import PP_ALIGN
83
-
84
- for slide in slide_data:
85
- slide_layout = prs.slide_layouts[1]
86
- new_slide = prs.slides.add_slide(slide_layout)
87
-
88
- if slide["header"]:
89
- title = new_slide.shapes.title
90
- title.text = slide["header"]
91
-
92
- if slide["content"]:
93
- shapes = new_slide.shapes
94
- body_shape = shapes.placeholders[1]
95
- tf = body_shape.text_frame
96
-
97
- content_text = "\n".join(slide["content"])
98
-
99
- p = tf.add_paragraph()
100
- p.text = content_text
101
-
102
- p.space_after = Pt(14)
103
- p.alignment = PP_ALIGN.LEFT
104
-
105
- presentation_filename = f"{presentation_title}.pptx"
106
- prs.save(presentation_filename)
107
-
108
- with open(presentation_filename, "rb") as file:
109
- st.download_button(
110
- label=f"πŸ“₯ Download {presentation_title}",
111
- data=file.read(),
112
- key=presentation_filename,
113
- file_name=presentation_filename
114
- )
115
-
116
- os.remove(presentation_filename)
117
- except json.JSONDecodeError as e:
118
- st.error("Error parsing JSON response from OpenAI.")
119
- else:
120
- st.warning("Please enter a presentation topic.")