Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -430,14 +430,16 @@ def polish_prompt(original_prompt: str, mode: str = "generate") -> str:
|
|
| 430 |
|
| 431 |
TASK: Rewrite the user's input into a precise, technical prompt describing the target visual result.
|
| 432 |
|
|
|
|
|
|
|
| 433 |
STRICT RULES:
|
| 434 |
-
- MAXIMUM
|
| 435 |
- Focus on: artistic style, color palette, lighting, texture, rendering technique, mood
|
| 436 |
- Describe HOW the image should look, not what to change
|
| 437 |
- No action words like "transform", "convert", "change"
|
| 438 |
- Present tense, as if describing the final image
|
| 439 |
|
| 440 |
-
You MUST respect the maximum of
|
| 441 |
|
| 442 |
OUTPUT FORMAT: Only the final prompt text. No thinking, no explanation, no preamble, no word count."""
|
| 443 |
else:
|
|
@@ -445,20 +447,22 @@ OUTPUT FORMAT: Only the final prompt text. No thinking, no explanation, no pream
|
|
| 445 |
|
| 446 |
TASK: Expand the user's input into a detailed, expressive prompt for stunning image generation.
|
| 447 |
|
|
|
|
|
|
|
| 448 |
STRICT RULES:
|
| 449 |
-
- MAXIMUM
|
| 450 |
- Be descriptive about: subject, lighting, atmosphere, style, composition, details
|
| 451 |
- Use vivid, specific language
|
| 452 |
- Include artistic style references when appropriate
|
| 453 |
|
| 454 |
-
You MUST respect the maximum of
|
| 455 |
|
| 456 |
OUTPUT FORMAT: Only the final prompt text. No thinking, no explanation, no preamble, no word count."""
|
| 457 |
|
| 458 |
try:
|
| 459 |
response = client.chat.completions.create(
|
| 460 |
model="deepseek-reasoner",
|
| 461 |
-
max_tokens=
|
| 462 |
messages=[
|
| 463 |
{"role": "system", "content": system_prompt},
|
| 464 |
{"role": "user", "content": original_prompt}
|
|
@@ -484,7 +488,7 @@ OUTPUT FORMAT: Only the final prompt text. No thinking, no explanation, no pream
|
|
| 484 |
content = content.split("</think>")[-1].strip()
|
| 485 |
if content.startswith('"') and content.endswith('"'):
|
| 486 |
content = content[1:-1]
|
| 487 |
-
max_words =
|
| 488 |
words = content.split()
|
| 489 |
if len(words) > max_words:
|
| 490 |
content = " ".join(words[:max_words])
|
|
|
|
| 430 |
|
| 431 |
TASK: Rewrite the user's input into a precise, technical prompt describing the target visual result.
|
| 432 |
|
| 433 |
+
GLOBAL RULE: You must generate the improved prompt with a maximum size of 800 tokens. This is a Global rule.
|
| 434 |
+
|
| 435 |
STRICT RULES:
|
| 436 |
+
- MAXIMUM 800 TOKENS (strict limit). You MUST write the new prompt in maximum of 800 tokens.
|
| 437 |
- Focus on: artistic style, color palette, lighting, texture, rendering technique, mood
|
| 438 |
- Describe HOW the image should look, not what to change
|
| 439 |
- No action words like "transform", "convert", "change"
|
| 440 |
- Present tense, as if describing the final image
|
| 441 |
|
| 442 |
+
You MUST respect the maximum of 800 TOKENS in your response. This is a Global rule.
|
| 443 |
|
| 444 |
OUTPUT FORMAT: Only the final prompt text. No thinking, no explanation, no preamble, no word count."""
|
| 445 |
else:
|
|
|
|
| 447 |
|
| 448 |
TASK: Expand the user's input into a detailed, expressive prompt for stunning image generation.
|
| 449 |
|
| 450 |
+
GLOBAL RULE: You must generate the improved prompt with a maximum size of 800 tokens. This is a Global rule.
|
| 451 |
+
|
| 452 |
STRICT RULES:
|
| 453 |
+
- MAXIMUM 800 TOKENS (strict limit). You MUST write the new prompt in maximum of 800 tokens.
|
| 454 |
- Be descriptive about: subject, lighting, atmosphere, style, composition, details
|
| 455 |
- Use vivid, specific language
|
| 456 |
- Include artistic style references when appropriate
|
| 457 |
|
| 458 |
+
You MUST respect the maximum of 800 TOKENS in your response. This is a Global rule.
|
| 459 |
|
| 460 |
OUTPUT FORMAT: Only the final prompt text. No thinking, no explanation, no preamble, no word count."""
|
| 461 |
|
| 462 |
try:
|
| 463 |
response = client.chat.completions.create(
|
| 464 |
model="deepseek-reasoner",
|
| 465 |
+
max_tokens=800,
|
| 466 |
messages=[
|
| 467 |
{"role": "system", "content": system_prompt},
|
| 468 |
{"role": "user", "content": original_prompt}
|
|
|
|
| 488 |
content = content.split("</think>")[-1].strip()
|
| 489 |
if content.startswith('"') and content.endswith('"'):
|
| 490 |
content = content[1:-1]
|
| 491 |
+
max_words = 800 # 800 tokens limit for all modes (Global rule)
|
| 492 |
words = content.split()
|
| 493 |
if len(words) > max_words:
|
| 494 |
content = " ".join(words[:max_words])
|