Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,6 @@ HF_TOKEN = os.environ.get("HF_TOKEN", "")
|
|
| 11 |
DATASET_REPO = os.environ.get("DATASET_REPO", "")
|
| 12 |
DATASET_FILE = "data.jsonl"
|
| 13 |
|
| 14 |
-
# Modelle aufteilen!
|
| 15 |
MODEL_DEFAULT = "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8"
|
| 16 |
MODEL_TUNING = "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8"
|
| 17 |
|
|
@@ -76,31 +75,30 @@ Rules:
|
|
| 76 |
- verdict is one precise sentence in German, max 12 words. Acknowledge substance if present.
|
| 77 |
- ALL string values must be valid JSON strings."""
|
| 78 |
|
| 79 |
-
|
|
|
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
-
|
| 84 |
-
-
|
| 85 |
-
|
| 86 |
-
- Call to Action Ziel: {cta}
|
| 87 |
|
| 88 |
-
|
| 89 |
-
-
|
| 90 |
-
-
|
| 91 |
-
-
|
| 92 |
-
-
|
| 93 |
-
-
|
| 94 |
-
- Behalte die Kernaussage und alle wichtigen Fakten (wie Links oder Zahlen) des Originals bei.
|
| 95 |
|
| 96 |
-
|
| 97 |
-
-
|
| 98 |
-
-
|
| 99 |
-
-
|
| 100 |
-
-
|
| 101 |
-
-
|
| 102 |
|
| 103 |
-
|
| 104 |
|
| 105 |
|
| 106 |
# ── HF Dataset Persistenz ──────────────────────────────────────────────────────
|
|
@@ -416,10 +414,10 @@ def generate_tuned_post(original_text, ton, substanz, laenge, zielgruppe, cta):
|
|
| 416 |
{original_text}
|
| 417 |
|
| 418 |
TUNING:
|
| 419 |
-
-
|
| 420 |
-
-
|
| 421 |
-
-
|
| 422 |
-
-
|
| 423 |
- Call to Action: {cta}"""
|
| 424 |
try:
|
| 425 |
return _call_llm(prompt, user_msg, max_tokens=800, model_id=MODEL_TUNING)
|
|
@@ -433,8 +431,7 @@ def generate_tuned_post_with_loader(original_text, ton, substanz, laenge, zielgr
|
|
| 433 |
yield "Bitte zuerst einen Post eingeben.", "*Bitte zuerst einen Post eingeben.*"
|
| 434 |
return
|
| 435 |
|
| 436 |
-
|
| 437 |
-
yield "⏳ Llama-4-Maverick optimiert den Post nach deinen Vorgaben...", "*Lädt...*"
|
| 438 |
result = generate_tuned_post(original_text, ton, substanz, laenge, zielgruppe, cta)
|
| 439 |
yield result, result
|
| 440 |
|
|
@@ -572,6 +569,10 @@ body, .gradio-container {
|
|
| 572 |
.li-header .badge {
|
| 573 |
margin-left:auto; background:rgba(255,255,255,.18); border-radius:20px;
|
| 574 |
padding:5px 14px; font-size:.74rem; font-weight:600; color:#fff; white-space:nowrap;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
}
|
| 576 |
.direction-banner {
|
| 577 |
text-align:center; font-size:.8rem; font-weight:700; letter-spacing:.6px;
|
|
@@ -654,7 +655,7 @@ with gr.Blocks(title="LinkedIn Translator") as demo:
|
|
| 654 |
<h1>LinkedIn Translator</h1>
|
| 655 |
<p>Banale Wahrheit ↔ Epische LinkedIn-Prosa · powered by Llama</p>
|
| 656 |
</div>
|
| 657 |
-
<
|
| 658 |
</div>
|
| 659 |
""")
|
| 660 |
|
|
@@ -663,7 +664,7 @@ with gr.Blocks(title="LinkedIn Translator") as demo:
|
|
| 663 |
with gr.Row(equal_height=True):
|
| 664 |
with gr.Column(scale=5):
|
| 665 |
input_box = gr.Textbox(label="✍️ Normale Aussage",
|
| 666 |
-
placeholder="z.B. 'Ich hab heute meinen Kaffee verschuettet.'",
|
| 667 |
lines=10)
|
| 668 |
with gr.Column(scale=1, min_width=120):
|
| 669 |
gr.HTML("<div style='height:40px'></div>")
|
|
|
|
| 11 |
DATASET_REPO = os.environ.get("DATASET_REPO", "")
|
| 12 |
DATASET_FILE = "data.jsonl"
|
| 13 |
|
|
|
|
| 14 |
MODEL_DEFAULT = "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8"
|
| 15 |
MODEL_TUNING = "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8"
|
| 16 |
|
|
|
|
| 75 |
- verdict is one precise sentence in German, max 12 words. Acknowledge substance if present.
|
| 76 |
- ALL string values must be valid JSON strings."""
|
| 77 |
|
| 78 |
+
# HIER IST DER NEUE ENGLISCHE PROMPT FÜR BESSERE SPRACH-KONTROLLE BEI LLAMA 4
|
| 79 |
+
PROMPT_AI_TUNING = """You are an elite LinkedIn copywriter and content optimizer. Your task is to rewrite the provided post strictly according to the tuning parameters.
|
| 80 |
|
| 81 |
+
CRITICAL RULE:
|
| 82 |
+
You MUST output the text in the EXACT SAME LANGUAGE as the original post.
|
| 83 |
+
- If the input is English, output MUST be English.
|
| 84 |
+
- If the input is German, output MUST be German.
|
| 85 |
+
Never translate the post!
|
|
|
|
| 86 |
|
| 87 |
+
TUNING PARAMETERS:
|
| 88 |
+
- Tone: {ton}/100 (0 = highly professional/corporate, 100 = provocative/bold/loud)
|
| 89 |
+
- Substance: {substanz}/100 (0 = pure storytelling/emotional, 100 = hard facts/data/insights only)
|
| 90 |
+
- Length: {laenge}/100 (0 = extremely short/1-2 sentences, 100 = very detailed/long)
|
| 91 |
+
- Target Audience: {zielgruppe}
|
| 92 |
+
- Call to Action Goal: {cta}
|
|
|
|
| 93 |
|
| 94 |
+
EXECUTION RULES:
|
| 95 |
+
- Treat the parameters (0-100) as absolute constraints. If Length is < 20, the post MUST be tiny. If Substance is > 80, strip ALL fluff and keep only hard facts.
|
| 96 |
+
- Remove generic "LinkedIn Bingo" phrases.
|
| 97 |
+
- Maintain the core message and all links/metrics from the original.
|
| 98 |
+
- If the output is German, ALWAYS use the informal "Du", never "Sie".
|
| 99 |
+
- Format using Markdown.
|
| 100 |
|
| 101 |
+
Output ONLY the optimized post. No preamble, no explanations."""
|
| 102 |
|
| 103 |
|
| 104 |
# ── HF Dataset Persistenz ──────────────────────────────────────────────────────
|
|
|
|
| 414 |
{original_text}
|
| 415 |
|
| 416 |
TUNING:
|
| 417 |
+
- Tone: {ton}/100
|
| 418 |
+
- Substance: {substanz}/100
|
| 419 |
+
- Length: {laenge}/100
|
| 420 |
+
- Target Audience: {zielgruppe}
|
| 421 |
- Call to Action: {cta}"""
|
| 422 |
try:
|
| 423 |
return _call_llm(prompt, user_msg, max_tokens=800, model_id=MODEL_TUNING)
|
|
|
|
| 431 |
yield "Bitte zuerst einen Post eingeben.", "*Bitte zuerst einen Post eingeben.*"
|
| 432 |
return
|
| 433 |
|
| 434 |
+
yield "⏳ KI optimiert den Post nach deinen Vorgaben... Bitte warten.", "*Lädt...*"
|
|
|
|
| 435 |
result = generate_tuned_post(original_text, ton, substanz, laenge, zielgruppe, cta)
|
| 436 |
yield result, result
|
| 437 |
|
|
|
|
| 569 |
.li-header .badge {
|
| 570 |
margin-left:auto; background:rgba(255,255,255,.18); border-radius:20px;
|
| 571 |
padding:5px 14px; font-size:.74rem; font-weight:600; color:#fff; white-space:nowrap;
|
| 572 |
+
cursor: pointer; transition: background 0.2s ease; border: none; outline: none;
|
| 573 |
+
}
|
| 574 |
+
.li-header .badge:hover {
|
| 575 |
+
background:rgba(255,255,255,.3);
|
| 576 |
}
|
| 577 |
.direction-banner {
|
| 578 |
text-align:center; font-size:.8rem; font-weight:700; letter-spacing:.6px;
|
|
|
|
| 655 |
<h1>LinkedIn Translator</h1>
|
| 656 |
<p>Banale Wahrheit ↔ Epische LinkedIn-Prosa · powered by Llama</p>
|
| 657 |
</div>
|
| 658 |
+
<button class="badge" onclick="document.getElementById('tuning_toggle_btn').click()">✨ AI Post Tuning</button>
|
| 659 |
</div>
|
| 660 |
""")
|
| 661 |
|
|
|
|
| 664 |
with gr.Row(equal_height=True):
|
| 665 |
with gr.Column(scale=5):
|
| 666 |
input_box = gr.Textbox(label="✍️ Normale Aussage",
|
| 667 |
+
placeholder="z.B. 'Ich hab heute meinen Kaffee verschuettet.'\n\nTipp: Du kannst hier auch direkt einen fertigen Text einfügen und ihn oben rechts über '✨ AI Post Tuning' optimieren lassen!",
|
| 668 |
lines=10)
|
| 669 |
with gr.Column(scale=1, min_width=120):
|
| 670 |
gr.HTML("<div style='height:40px'></div>")
|