diwash-barla commited on
Commit
c960247
·
verified ·
1 Parent(s): e216926

Old prompt

Browse files
Files changed (1) hide show
  1. app.py +6 -42
app.py CHANGED
@@ -113,34 +113,8 @@ def generate_visual_blueprint_with_groq(user_prompt, api_key, model_name):
113
  return visual_blueprint, None
114
  except Exception as e: return None, f"Groq API Error: {e}"
115
 
116
- def distill_prompt_for_short_video(enhanced_prompt, api_key, model_name):
117
- print("🧪 Contacting Groq (Prompt Distiller)...")
118
- try:
119
- client = Groq(api_key=api_key)
120
- system_prompt = """You are an expert video editor who specializes in ultra-short clips (3-4 seconds).
121
- Your task is to take a long, hyper-detailed prompt and distill it into a concise, powerful version perfect for a brief video.
122
- RULES:
123
- 1. Identify the single most important subject and a very brief, clear action.
124
- 2. Focus the entire prompt on ONE dynamic moment or a powerful, static scene. Do not describe multiple complex actions.
125
- 3. Condense descriptive keywords. Instead of 'photorealistic, 4k, ultra realistic, hyper-detailed', choose the best two, like 'cinematic, hyper-detailed'.
126
- 4. The final prompt must be significantly shorter but retain the core artistic vision.
127
- Output ONLY the final, short, distilled prompt.
128
- """
129
- response = client.chat.completions.create(
130
- model=model_name,
131
- messages=[
132
- {"role": "system", "content": system_prompt},
133
- {"role": "user", "content": enhanced_prompt}
134
- ]
135
- )
136
- distilled_prompt = response.choices[0].message.content.strip()
137
- print(f"✨ Distiller's final prompt: {distilled_prompt}")
138
- return distilled_prompt, None
139
- except Exception as e:
140
- print(f"⚠️ Groq Distiller failed: {e}. Falling back to original enhanced prompt.")
141
- return enhanced_prompt, None
142
 
143
- # /// --- यह नया, सही और सुरक्षित फंक्शन है --- ///
144
  def generate_clip(prompt, idx, api_key, bytez_model):
145
  from bytez import Bytez
146
  sdk = Bytez(api_key)
@@ -150,34 +124,24 @@ def generate_clip(prompt, idx, api_key, bytez_model):
150
  err = None
151
 
152
  try:
153
- # हम model.run() से आने वाले सभी आउटपुट को एक ही वेरिएबल में पकड़ेंगे
154
  result = model.run(prompt)
155
-
156
- # हम यह देखने के लिए प्रिंट करेंगे कि असल में क्या आ रहा है (डीबगिंग के लिए)
157
  print(f"DEBUG: model.run() returned a '{type(result)}'. Full result: {result}")
158
 
159
- # अब हम सुरक्षित रूप से जांच करेंगे कि क्या result एक ट्यूपल (tuple) है
160
  if isinstance(result, tuple) and len(result) >= 2:
161
- # यदि यह एक ट्यूपल है, तो हम पहले दो मानों को out और err में डालेंगे
162
  out = result[0]
163
  err = result[1]
164
  elif isinstance(result, tuple) and len(result) == 1:
165
- # यदि केवल एक ही मान है, तो हम मानते हैं कि यह आउटपुट है
166
  out = result[0]
167
  err = None
168
  else:
169
- # यदि यह ट्यूपल नहीं है, तो हम मानते हैं कि यह सफल आउटपुट है
170
  out = result
171
  err = None
172
 
173
  except Exception as e:
174
- # यदि model.run() खुद ही क्रैश हो जाए (जो नहीं होना चाहिए, लेकिन सुरक्षा के लिए)
175
  print(f"🛑 CRITICAL ERROR during model.run() call: {e}")
176
  return None, str(e)
177
 
178
- # --- बाकी का लॉजिक वही रहेगा ---
179
  if err:
180
- # अगर मॉडल ने कोई एरर लौटाया है (जैसे सेफ्टी फिल्टर)
181
  return None, f"Model Error (Key ...{api_key[-4:]}): {err}"
182
 
183
  filename = f"clip_{idx}_{uuid.uuid4().hex}.mp4"
@@ -190,7 +154,6 @@ def generate_clip(prompt, idx, api_key, bytez_model):
190
  r.raise_for_status()
191
  with open(filepath, "wb") as f: f.write(r.content)
192
  else:
193
- # यदि 'out' में कुछ भी अपेक्षित नहीं है (जैसे None), तो हम यहाँ एक स्पष्ट एरर देंगे
194
  return None, f"Unexpected or empty output from model. Output type: {type(out)}"
195
  except Exception as e:
196
  return None, f"Failed to save or download the generated clip: {e}"
@@ -298,12 +261,13 @@ def start():
298
  set_progress(status="error", error=err, active=False, log_message=f"🛑 Groq Enhancer Failure: {err}"); return jsonify({"error": err}), 500
299
  set_progress(log_message=f"✨ Enhanced Blueprint: \"{visual_blueprint[:80]}...\"")
300
 
301
- set_progress(log_message="🧪 Distilling prompt for short video clip...")
302
- distilled_prompt, err = distill_prompt_for_short_video(visual_blueprint, GROQ_API_KEY, GROQ_MODEL)
303
- set_progress(log_message=f"🎯 Final Distilled Prompt: \"{distilled_prompt[:80]}...\"")
304
 
305
  negative_keywords = "blurry, deformed, ugly, bad anatomy, watermark, noise, grain, low quality, distortion, glitch, pixelated, artifacts"
306
- final_prompt = f"{distilled_prompt}, {negative_keywords}"
 
307
 
308
  print(f"🚀 Final Prompt for Bytez (Model: {bytez_model}): {final_prompt}")
309
  job_thread = threading.Thread(target=generate_video_job, args=(final_prompt, num_clips, bytez_model), daemon=True)
 
113
  return visual_blueprint, None
114
  except Exception as e: return None, f"Groq API Error: {e}"
115
 
116
+ # हमने यहाँ से distill_prompt_for_short_video फंक्शन को हटा दिया है।
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
 
118
  def generate_clip(prompt, idx, api_key, bytez_model):
119
  from bytez import Bytez
120
  sdk = Bytez(api_key)
 
124
  err = None
125
 
126
  try:
 
127
  result = model.run(prompt)
 
 
128
  print(f"DEBUG: model.run() returned a '{type(result)}'. Full result: {result}")
129
 
 
130
  if isinstance(result, tuple) and len(result) >= 2:
 
131
  out = result[0]
132
  err = result[1]
133
  elif isinstance(result, tuple) and len(result) == 1:
 
134
  out = result[0]
135
  err = None
136
  else:
 
137
  out = result
138
  err = None
139
 
140
  except Exception as e:
 
141
  print(f"🛑 CRITICAL ERROR during model.run() call: {e}")
142
  return None, str(e)
143
 
 
144
  if err:
 
145
  return None, f"Model Error (Key ...{api_key[-4:]}): {err}"
146
 
147
  filename = f"clip_{idx}_{uuid.uuid4().hex}.mp4"
 
154
  r.raise_for_status()
155
  with open(filepath, "wb") as f: f.write(r.content)
156
  else:
 
157
  return None, f"Unexpected or empty output from model. Output type: {type(out)}"
158
  except Exception as e:
159
  return None, f"Failed to save or download the generated clip: {e}"
 
261
  set_progress(status="error", error=err, active=False, log_message=f"🛑 Groq Enhancer Failure: {err}"); return jsonify({"error": err}), 500
262
  set_progress(log_message=f"✨ Enhanced Blueprint: \"{visual_blueprint[:80]}...\"")
263
 
264
+ ### --- यह हिस्सा बदला गया है --- ###
265
+ # हमने यहाँ से "Prompt Distiller" को हटा दिया है।
266
+ # अब हम विस्तृत प्रॉम्प्ट को सीधे उपयोग करेंगे।
267
 
268
  negative_keywords = "blurry, deformed, ugly, bad anatomy, watermark, noise, grain, low quality, distortion, glitch, pixelated, artifacts"
269
+ # अब हम `visual_blueprint` का सीधा उपयोग कर रहे हैं।
270
+ final_prompt = f"{visual_blueprint}, {negative_keywords}"
271
 
272
  print(f"🚀 Final Prompt for Bytez (Model: {bytez_model}): {final_prompt}")
273
  job_thread = threading.Thread(target=generate_video_job, args=(final_prompt, num_clips, bytez_model), daemon=True)