dbaduck commited on
Commit
0344d32
·
verified ·
1 Parent(s): ab20ef0

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +152 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import hf_hub_download
3
+ from llama_cpp import Llama
4
+ import os
5
+
6
+ # Model configuration
7
+ MODEL_REPO = "tiiuae/Falcon3-1B-Instruct-GGUF"
8
+ MODEL_FILE = "falcon3-1b-instruct-q4_k_m.gguf"
9
+
10
+ # Download and load model
11
+ print("Downloading model...")
12
+ model_path = hf_hub_download(
13
+ repo_id=MODEL_REPO,
14
+ filename=MODEL_FILE,
15
+ cache_dir="./models"
16
+ )
17
+
18
+ print("Loading model...")
19
+ llm = Llama(
20
+ model_path=model_path,
21
+ n_ctx=2048,
22
+ n_threads=4,
23
+ n_gpu_layers=0 # Set to higher value if GPU available
24
+ )
25
+
26
+ def generate_ppt_script(topic, num_slides=5, temperature=0.7, max_tokens=1500):
27
+ """Generate a PowerPoint presentation script for the given topic."""
28
+
29
+ prompt = f"""You are a professional presentation writer. Create a detailed PowerPoint presentation script for the topic: "{topic}"
30
+
31
+ Generate a script with {num_slides} slides. For each slide, provide:
32
+ 1. Slide number and title
33
+ 2. Key points to include (3-5 bullet points)
34
+ 3. Speaker notes/talking points
35
+
36
+ Format the output clearly with slide numbers and sections.
37
+
38
+ Presentation Script:"""
39
+
40
+ # Generate response
41
+ output = llm(
42
+ prompt,
43
+ max_tokens=max_tokens,
44
+ temperature=temperature,
45
+ top_p=0.9,
46
+ repeat_penalty=1.1,
47
+ stop=["</s>", "User:", "Human:"],
48
+ echo=False
49
+ )
50
+
51
+ response = output['choices'][0]['text'].strip()
52
+ return response
53
+
54
+ def create_interface():
55
+ """Create the Gradio interface."""
56
+
57
+ with gr.Blocks(theme=gr.themes.Soft(), title="PPT Script Generator") as demo:
58
+ gr.Markdown(
59
+ """
60
+ # 📊 PowerPoint Script Generator
61
+ ### Powered by Falcon3-1B-Instruct
62
+
63
+ Generate professional presentation scripts for any topic using AI.
64
+ Simply enter your topic and get a complete slide-by-slide script!
65
+ """
66
+ )
67
+
68
+ with gr.Row():
69
+ with gr.Column(scale=1):
70
+ topic_input = gr.Textbox(
71
+ label="Presentation Topic",
72
+ placeholder="e.g., 'Introduction to Artificial Intelligence', 'Climate Change Solutions', 'Digital Marketing Strategies'",
73
+ lines=2
74
+ )
75
+
76
+ with gr.Row():
77
+ num_slides = gr.Slider(
78
+ minimum=3,
79
+ maximum=10,
80
+ value=5,
81
+ step=1,
82
+ label="Number of Slides"
83
+ )
84
+
85
+ temperature = gr.Slider(
86
+ minimum=0.1,
87
+ maximum=1.0,
88
+ value=0.7,
89
+ step=0.1,
90
+ label="Creativity (Temperature)"
91
+ )
92
+
93
+ max_tokens = gr.Slider(
94
+ minimum=500,
95
+ maximum=3000,
96
+ value=1500,
97
+ step=100,
98
+ label="Maximum Length (tokens)"
99
+ )
100
+
101
+ generate_btn = gr.Button("🎯 Generate Script", variant="primary", size="lg")
102
+
103
+ gr.Markdown(
104
+ """
105
+ ### Tips:
106
+ - Be specific with your topic for better results
107
+ - Use 5-7 slides for standard presentations
108
+ - Higher temperature = more creative output
109
+ - Adjust max tokens if output is cut off
110
+ """
111
+ )
112
+
113
+ with gr.Column(scale=2):
114
+ output = gr.Textbox(
115
+ label="Generated Presentation Script",
116
+ lines=25,
117
+ show_copy_button=True
118
+ )
119
+
120
+ # Examples
121
+ gr.Examples(
122
+ examples=[
123
+ ["Introduction to Machine Learning", 5, 0.7, 1500],
124
+ ["The Future of Renewable Energy", 6, 0.8, 1800],
125
+ ["Effective Team Management Strategies", 5, 0.7, 1500],
126
+ ["Blockchain Technology Explained", 7, 0.7, 2000],
127
+ ["Mental Health in the Workplace", 5, 0.6, 1500],
128
+ ],
129
+ inputs=[topic_input, num_slides, temperature, max_tokens],
130
+ label="Example Topics"
131
+ )
132
+
133
+ # Connect the button to the function
134
+ generate_btn.click(
135
+ fn=generate_ppt_script,
136
+ inputs=[topic_input, num_slides, temperature, max_tokens],
137
+ outputs=output
138
+ )
139
+
140
+ gr.Markdown(
141
+ """
142
+ ---
143
+ **Note:** This app uses the Falcon3-1B-Instruct model in GGUF format for efficient CPU inference.
144
+ Generation may take 30-60 seconds depending on the length requested.
145
+ """
146
+ )
147
+
148
+ return demo
149
+
150
+ if __name__ == "__main__":
151
+ demo = create_interface()
152
+ demo.launch(server_name="0.0.0.0", server_port=7860)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio>=4.0.0
2
+ llama-cpp-python==0.2.90
3
+ huggingface-hub>=0.19.0