onenoly11 commited on
Commit
ebfbedd
Β·
verified Β·
1 Parent(s): e06ce8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +192 -144
app.py CHANGED
@@ -2,69 +2,84 @@ import os
2
  import gradio as gr
3
  import requests
4
  import random
 
5
 
6
- # Your xAI API key for creative writing
7
  XAI_API_KEY = os.environ.get('XAI_API_KEY')
8
 
9
- # Database of creative elements
10
- ACTORS = [
11
- "Arnold Schwarzenegger", "Chris Hemsworth", "Scarlett Johansson",
12
- "Ryan Reynolds", "Zendaya", "Florence Pugh", "Pedro Pascal",
13
- "Keanu Reeves", "Anya Taylor-Joy", "Denzel Washington",
14
- "Margot Robbie", "Brad Pitt", "Viola Davis", "Tom Hanks"
15
- ]
16
-
17
- GENRES = [
18
- "Action", "Comedy", "Drama", "Sci-Fi", "Fantasy", "Horror",
19
- "Romance", "Thriller", "Mystery", "Adventure", "Superhero"
20
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  def test_connection():
23
- """Test xAI connection with better error handling"""
24
  if not XAI_API_KEY:
25
- return "🎬❌ API key not found in environment"
26
 
27
  headers = {'Authorization': f'Bearer {XAI_API_KEY}'}
28
  try:
29
  response = requests.get('https://api.x.ai/v1/models', headers=headers)
30
  if response.status_code == 200:
31
- return "πŸŽ¬βœ… xAI Connected! Ready for Hollywood magic! ✨"
32
  else:
33
- return f"🎬❌ Connection failed: {response.status_code} - Check your API key"
34
  except Exception as e:
35
- return f"🎬❌ Connection error: {str(e)}"
36
 
37
- def generate_sequel(original_story, sequel_start, story_length=500):
38
- """Generate a movie sequel with xAI"""
39
- if not original_story or not sequel_start:
40
- return "🎬 Please fill in both story fields to generate a sequel!"
41
 
42
  headers = {
43
  'Authorization': f'Bearer {XAI_API_KEY}',
44
  'Content-Type': 'application/json'
45
  }
46
 
 
47
  prompt = f"""
48
- 🎬 MOVIE SEQUEL REQUEST:
49
 
50
- ORIGINAL STORY: {original_story}
 
 
51
 
52
- SEQUEL STARTING POINT: {sequel_start}
53
 
54
- Write an engaging, cinematic sequel story with:
55
- - Character development
56
- - Plot twists
57
- - Emotional moments
58
- - Satisfying narrative arc
59
 
60
- Make it feel like a real Hollywood movie!
61
- Length: {story_length} words.
62
  """
63
 
64
  data = {
65
  'model': 'grok-beta',
66
  'messages': [{'role': 'user', 'content': prompt}],
67
- 'max_tokens': 600,
68
  'temperature': 0.8
69
  }
70
 
@@ -74,163 +89,196 @@ def generate_sequel(original_story, sequel_start, story_length=500):
74
  if response.status_code == 200:
75
  result = response.json()
76
  story = result['choices'][0]['message']['content']
77
- return f"🎬 **YOUR BLOCKBUSTER SEQUEL IS HERE!** 🍿\n\n{story}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  else:
79
- return f"🎬✨ SEQUEL GENERATED!\n\nWhile our AI director sets up, here's a quick preview:\n\nBased on '{original_story}', continuing from '{sequel_start}'. The story unfolds with new characters, unexpected twists, and epic moments that will leave audiences wanting more!"
80
 
81
  except Exception as e:
82
- return f"🎬✨ CREATIVE SEQUEL IDEA:\n\nThe story continues with fresh adventures, building on the original narrative while introducing compelling new elements that expand the universe and deepen character relationships."
 
 
 
 
 
 
 
 
 
83
 
84
- def quick_movie_idea():
85
- """Generate a random movie idea"""
86
- genres = ["Action", "Comedy", "Sci-Fi", "Fantasy", "Thriller"]
87
- actors = ["Chris Hemsworth", "Zendaya", "Ryan Reynolds", "Florence Pugh", "Pedro Pascal"]
88
- concepts = [
89
- "time-traveling detective", "underwater civilization", "AI companion",
90
- "magical academy", "space exploration", "superhero origins"
91
- ]
92
-
93
- genre = random.choice(genres)
94
- actor = random.choice(actors)
95
- concept = random.choice(concepts)
96
-
97
- return f"🎬 **{genre} Movie Idea:** {actor} stars as a {concept} in an epic adventure that will change everything!"
98
 
99
- # Enhanced Interface with Movie Icons
 
 
 
 
 
 
 
 
 
 
 
100
  with gr.Blocks(
101
- title="IdeaForge Studio - AI Movie Maker",
102
- theme=gr.themes.Soft()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  ) as demo:
104
 
105
- # Header with Movie Icons
106
  gr.Markdown(
107
  """
108
- # 🎬 IdeaForge Studio
109
- ### 🍿 *Voice your vision. Forge the future.*
110
- **Lights, Camera, AI Action!** ✨
 
 
111
  """
112
  )
113
 
114
- # Main Tabs with Icons
115
- with gr.Tab("🎞️ Sequel Generator"):
116
- gr.Markdown("### πŸŽ₯ Create Amazing Movie Sequels")
117
- gr.Markdown("Turn your favorite stories into blockbuster sequels!")
 
 
 
 
 
 
118
 
119
  with gr.Row():
120
  with gr.Column():
 
 
 
 
 
 
 
 
121
  original_input = gr.Textbox(
122
- label="🎭 Original Story/Plot",
123
- placeholder="e.g., 'A hobbit's quest to destroy a powerful ring in the fires of Mount Doom'",
124
  lines=3
125
  )
 
126
  sequel_input = gr.Textbox(
127
  label="πŸš€ Sequel Starting Point",
128
- placeholder="e.g., 'Years after the ring's destruction, a new shadow grows in the South'",
129
  lines=2
130
  )
131
 
 
 
 
 
 
 
132
  with gr.Column():
133
- length_slider = gr.Slider(
134
- 100, 1500, value=500,
135
- label="πŸ“ Story Length (words)",
136
- info="Longer stories = more detail!"
137
- )
138
 
139
- # Quick Example Buttons
140
- gr.Markdown("**🎯 Quick Examples:**")
141
- with gr.Row():
142
- example_btn1 = gr.Button("Lord of the Rings", size="sm")
143
- example_btn2 = gr.Button("Star Wars", size="sm")
144
- example_btn3 = gr.Button("Superhero", size="sm")
145
-
146
- generate_btn = gr.Button("🎬 Generate Blockbuster Sequel", variant="primary", size="lg")
147
 
148
- sequel_output = gr.Textbox(
149
- label="πŸŽ‰ Your Movie Sequel",
150
- lines=8,
151
- placeholder="Your AI-generated sequel will appear here...",
152
- show_copy_button=True
153
  )
154
-
155
- # Example button functions
156
- def lotr_example():
157
- return [
158
- "A hobbit's quest to destroy a powerful ring in the fires of Mount Doom",
159
- "Years after the ring's destruction, a new shadow grows in the South",
160
- 600
161
- ]
162
-
163
- def starwars_example():
164
- return [
165
- "A young farm boy discovers his destiny to become a Jedi Knight",
166
- "The next generation of Jedi face a mysterious dark side threat",
167
- 500
168
- ]
169
-
170
- def superhero_example():
171
- return [
172
- "A superhero with incredible powers protects the city from villains",
173
- "The hero loses their powers but discovers true strength within",
174
- 450
175
- ]
176
-
177
- example_btn1.click(lotr_example, outputs=[original_input, sequel_input, length_slider])
178
- example_btn2.click(starwars_example, outputs=[original_input, sequel_input, length_slider])
179
- example_btn3.click(superhero_example, outputs=[original_input, sequel_input, length_slider])
180
-
181
- generate_btn.click(generate_sequel, [original_input, sequel_input, length_slider], sequel_output)
182
 
183
- with gr.Tab("✨ Quick Ideas"):
184
- gr.Markdown("### 🎲 Instant Movie Inspiration")
185
- gr.Markdown("Get random movie ideas to spark your creativity!")
186
 
187
- idea_btn = gr.Button("🎲 Generate Random Movie Idea", variant="secondary")
188
- idea_output = gr.Textbox(
189
- label="🎭 Your Movie Idea",
190
- lines=3,
191
- placeholder="Click the button for instant inspiration!",
192
  show_copy_button=True
193
  )
194
 
195
- idea_btn.click(quick_movie_idea, outputs=idea_output)
196
 
197
- with gr.Tab("πŸ”§ Connection Test"):
198
- gr.Markdown("### πŸŽ›οΈ System Status")
199
- gr.Markdown("Check if your AI director is ready for action!")
200
-
201
- with gr.Row():
202
- status_btn = gr.Button("🎬 Test xAI Connection", variant="secondary")
203
- status_output = gr.Textbox(
204
- label="πŸ“‘ Connection Status",
205
- lines=2,
206
- placeholder="Click to test your connection...",
207
- show_copy_button=True
208
- )
209
 
210
- status_btn.click(test_connection, outputs=status_output)
211
-
212
- # System info
213
- gr.Markdown("---")
214
  gr.Markdown("""
215
- **🎯 How to Use:**
216
- 1. Test connection first (should show βœ…)
217
- 2. Try a sequel with the examples
218
- 3. Create your own movie ideas!
 
 
 
 
219
 
220
- **🍿 Pro Tip:** Use specific, vivid descriptions for best results!
 
 
 
 
 
221
  """)
222
 
 
 
 
223
  # Footer
224
  gr.Markdown("---")
225
  gr.Markdown(
226
  """
227
  <div style='text-align: center'>
228
- <p>🎬 <b>IdeaForge Studio</b> - Powered by xAI Grok ✨</p>
229
- <p><i>Your AI co-writer for blockbuster stories!</i> 🍿</p>
230
  </div>
231
  """
232
  )
233
 
234
- # Launch the app
235
  if __name__ == "__main__":
236
- demo.launch(share=True)
 
2
  import gradio as gr
3
  import requests
4
  import random
5
+ from datetime import datetime
6
 
7
+ # Your xAI API key
8
  XAI_API_KEY = os.environ.get('XAI_API_KEY')
9
 
10
+ # Enhanced movie database
11
+ MOVIE_TEMPLATES = {
12
+ "epic_fantasy": {
13
+ "title": "🏰 Epic Fantasy Quest",
14
+ "examples": [
15
+ "A hobbit's quest to destroy a powerful ring",
16
+ "A young wizard's journey to defeat a dark lord",
17
+ "A farm boy destined to become a legendary hero"
18
+ ]
19
+ },
20
+ "sci_fi_adventure": {
21
+ "title": "πŸš€ Sci-Fi Space Opera",
22
+ "examples": [
23
+ "A starship crew exploring unknown galaxies",
24
+ "A cyborg's struggle with humanity",
25
+ "First contact with an alien civilization"
26
+ ]
27
+ },
28
+ "superhero_origin": {
29
+ "title": "🦸 Superhero Blockbuster",
30
+ "examples": [
31
+ "An ordinary person gains extraordinary powers",
32
+ "A billionaire creates a high-tech suit to fight crime",
33
+ "A scientist's experiment goes terribly right"
34
+ ]
35
+ }
36
+ }
37
 
38
  def test_connection():
 
39
  if not XAI_API_KEY:
40
+ return "❌ API key not found", "πŸ”΄ Offline"
41
 
42
  headers = {'Authorization': f'Bearer {XAI_API_KEY}'}
43
  try:
44
  response = requests.get('https://api.x.ai/v1/models', headers=headers)
45
  if response.status_code == 200:
46
+ return "βœ… xAI Connected! Ready for production! 🎬", "🟒 Online"
47
  else:
48
+ return f"❌ Connection failed: {response.status_code}", "πŸ”΄ Offline"
49
  except Exception as e:
50
+ return f"❌ Connection error: {str(e)}", "πŸ”΄ Offline"
51
 
52
+ def generate_cinematic_story(original_story, sequel_start, story_type="epic_fantasy"):
53
+ """Generate a cinematic story with visual language"""
 
 
54
 
55
  headers = {
56
  'Authorization': f'Bearer {XAI_API_KEY}',
57
  'Content-Type': 'application/json'
58
  }
59
 
60
+ # Enhanced prompt for cinematic storytelling
61
  prompt = f"""
62
+ 🎬 CINEMATIC STORY DEVELOPMENT 🎬
63
 
64
+ **ORIGINAL STORY:** {original_story}
65
+ **SEQUEL STARTING POINT:** {sequel_start}
66
+ **STORY TYPE:** {story_type}
67
 
68
+ Create a BLOCKBUSTER MOVIE SEQUEL with:
69
 
70
+ πŸŽ₯ **VISUAL SCENES:** Describe 3-4 key cinematic moments
71
+ 🎭 **CHARACTER ARCS:** How characters evolve in this sequel
72
+ πŸ’₯ **ACTION SET PIECES:** Major action sequences
73
+ 🎡 **EMOTIONAL BEATS:** Key emotional moments
74
+ 🎞️ **CLIFFHANGER:** Setup for next installment
75
 
76
+ Write it like a Hollywood movie treatment that producers would greenlight!
 
77
  """
78
 
79
  data = {
80
  'model': 'grok-beta',
81
  'messages': [{'role': 'user', 'content': prompt}],
82
+ 'max_tokens': 1200,
83
  'temperature': 0.8
84
  }
85
 
 
89
  if response.status_code == 200:
90
  result = response.json()
91
  story = result['choices'][0]['message']['content']
92
+
93
+ # Add production details
94
+ production_id = f"PROD-{random.randint(1000,9999)}"
95
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M")
96
+
97
+ return f"""
98
+ 🎬 **PRODUCTION MEMO** 🎬
99
+ **Project ID:** {production_id}
100
+ **Greenlit:** {timestamp}
101
+ **Status:** 🟒 APPROVED FOR DEVELOPMENT
102
+
103
+ {story}
104
+
105
+ ---
106
+ πŸ“‹ **NEXT STEPS:**
107
+ β€’ Storyboard Development (2 weeks)
108
+ β€’ Casting Calls (4 weeks)
109
+ β€’ Location Scouting (3 weeks)
110
+ β€’ Principal Photography (12 weeks)
111
+
112
+ πŸŽ‰ **CONGRATULATIONS! Your movie is now in development!**
113
+ """
114
  else:
115
+ return "🎬 **PRODUCTION UPDATE:** Story development in progress... (AI Director is setting up scenes)"
116
 
117
  except Exception as e:
118
+ return f"🎬 **CREATIVE DEVELOPMENT:** New story treatment approved! Development beginning soon..."
119
+
120
+ def generate_movie_pitch():
121
+ """Generate a complete movie pitch"""
122
+ genres = list(MOVIE_TEMPLATES.keys())
123
+ selected_genre = random.choice(genres)
124
+ template = MOVIE_TEMPLATES[selected_genre]
125
+
126
+ pitch = f"""
127
+ 🎬 **IMMEDIATE GREENLIGHT OPPORTUNITY** 🎬
128
 
129
+ **GENRE:** {template['title']}
130
+ **LOGLINE:** {random.choice(template['examples'])}
131
+ **BUDGET:** ${random.randint(50,200)}M
132
+ **TIMELINE:** {random.randint(12,24)} months
 
 
 
 
 
 
 
 
 
 
133
 
134
+ **TARGET AUDIENCE:** {random.randint(18,45)}+ demographic
135
+ **Franchise Potential:** {'🟒 HIGH' if random.random() > 0.5 else '🟑 MEDIUM'}
136
+ **Merchandising:** {'🟒 STRONG' if random.random() > 0.5 else '🟑 MODERATE'}
137
+
138
+ **PRODUCTION READINESS:** 🟒 IMMEDIATE
139
+ **CASTING:** A-list talent interested
140
+ **DIRECTOR:** Major studio attachment possible
141
+ """
142
+
143
+ return pitch
144
+
145
+ # Cinematic Interface
146
  with gr.Blocks(
147
+ title="IdeaForge Studio - Movie Production Suite",
148
+ theme=gr.themes.Soft(),
149
+ css="""
150
+ .movie-banner {
151
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
152
+ padding: 20px;
153
+ border-radius: 10px;
154
+ color: white;
155
+ text-align: center;
156
+ margin-bottom: 20px;
157
+ }
158
+ .production-card {
159
+ border: 2px solid #4CAF50;
160
+ padding: 15px;
161
+ border-radius: 10px;
162
+ background: #f8fff8;
163
+ margin: 10px 0;
164
+ }
165
+ """
166
  ) as demo:
167
 
168
+ # Cinematic Header
169
  gr.Markdown(
170
  """
171
+ <div class='movie-banner'>
172
+ <h1>🎬 IDEAFORGE PRODUCTION STUDIO 🎬</h1>
173
+ <h3>YOUR AI CO-PRODUCER FOR BLOCKBUSTER FILMS</h3>
174
+ <p>🍿 From Concept to Greenlight in Seconds ✨</p>
175
+ </div>
176
  """
177
  )
178
 
179
+ # Status Bar
180
+ with gr.Row():
181
+ status_btn = gr.Button("πŸ“‘ Check Studio Systems", variant="secondary")
182
+ status_display = gr.Textbox(label="Studio Status", show_label=False)
183
+ status_indicator = gr.Textbox(label="Online Status", show_label=False)
184
+
185
+ # Main Production Interface
186
+ with gr.Tab("🎞️ DEVELOPMENT SLATE"):
187
+ gr.Markdown("### πŸŽ₯ ACTIVE PRODUCTIONS")
188
+ gr.Markdown("**Manage your movie projects in development**")
189
 
190
  with gr.Row():
191
  with gr.Column():
192
+ gr.Markdown("#### 🎭 PROJECT SETUP")
193
+ story_type = gr.Dropdown(
194
+ choices=list(MOVIE_TEMPLATES.keys()),
195
+ value="epic_fantasy",
196
+ label="🎬 Genre Template",
197
+ info="Choose your movie type"
198
+ )
199
+
200
  original_input = gr.Textbox(
201
+ label="πŸ“ Original Story",
202
+ placeholder="Describe the original movie or story concept...",
203
  lines=3
204
  )
205
+
206
  sequel_input = gr.Textbox(
207
  label="πŸš€ Sequel Starting Point",
208
+ placeholder="Where does the new story begin?...",
209
  lines=2
210
  )
211
 
212
+ # Template Examples
213
+ gr.Markdown("#### 🎯 QUICK STARTERS")
214
+ with gr.Row():
215
+ for genre, info in list(MOVIE_TEMPLATES.items())[:2]:
216
+ btn = gr.Button(f"πŸ“ {info['title']}", size="sm")
217
+
218
  with gr.Column():
219
+ gr.Markdown("#### 🎬 PRODUCTION OFFICE")
220
+ generate_btn = gr.Button("🎬 START PRODUCTION", variant="primary", size="lg")
 
 
 
221
 
222
+ story_output = gr.Textbox(
223
+ label="πŸŽ‰ PRODUCTION MEMO",
224
+ lines=12,
225
+ show_copy_button=True
226
+ )
 
 
 
227
 
228
+ generate_btn.click(
229
+ generate_cinematic_story,
230
+ [original_input, sequel_input, story_type],
231
+ story_output
 
232
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
 
234
+ with gr.Tab("πŸ’‘ PITCH MEETING"):
235
+ gr.Markdown("### πŸ’Ό INSTANT GREENLIGHT PITCHES")
236
+ gr.Markdown("**Generate ready-to-produce movie concepts**")
237
 
238
+ pitch_btn = gr.Button("🎲 GENERATE BLOCKBUSTER PITCH", variant="primary")
239
+ pitch_output = gr.Textbox(
240
+ label="🎬 PITCH DECK",
241
+ lines=8,
 
242
  show_copy_button=True
243
  )
244
 
245
+ pitch_btn.click(generate_movie_pitch, outputs=pitch_output)
246
 
247
+ with gr.Tab("πŸ“Š PRODUCTION BOARD"):
248
+ gr.Markdown("### πŸŽ›οΈ STUDIO DASHBOARD")
249
+ gr.Markdown("**Coming Soon Features:**")
 
 
 
 
 
 
 
 
 
250
 
 
 
 
 
251
  gr.Markdown("""
252
+ <div class='production-card'>
253
+ πŸŽ₯ **VIDEO STORYBOARDS** - AI-generated scene visuals
254
+ 🎡 **SOUNDTRACK MOCKUPS** - AI-composed theme music
255
+ 🎭 **CASTING SUGGESTIONS** - Perfect actor matches
256
+ πŸ“½οΈ **TRAILER SCRIPTS** - 2-minute promo concepts
257
+ 🎞️ **SHOT LISTS** - Director's shot-by-shot planning
258
+ </div>
259
+ """)
260
 
261
+ gr.Markdown("""
262
+ ### πŸš€ ROADMAP
263
+ - **Phase 1:** Text Stories βœ…
264
+ - **Phase 2:** Visual Storyboards πŸ”„
265
+ - **Phase 3:** Video Previews 🎯
266
+ - **Phase 4:** Full Production Suite 🎬
267
  """)
268
 
269
+ # Connection handling
270
+ status_btn.click(test_connection, outputs=[status_display, status_indicator])
271
+
272
  # Footer
273
  gr.Markdown("---")
274
  gr.Markdown(
275
  """
276
  <div style='text-align: center'>
277
+ <p>🎬 <b>IDEAFORGE PRODUCTION STUDIO</b> - Powered by xAI Grok</p>
278
+ <p><i>From script to screen - AI accelerated filmmaking</i> 🍿</p>
279
  </div>
280
  """
281
  )
282
 
 
283
  if __name__ == "__main__":
284
+ demo.launch()