Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,32 +2,33 @@ import gradio as gr
|
|
| 2 |
import random
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
client = InferenceClient(model=MODEL_NAME)
|
| 7 |
|
| 8 |
VARIATION_HINTS = [
|
| 9 |
-
"Use a concise and
|
| 10 |
-
"Write
|
| 11 |
-
"Keep the
|
| 12 |
"Reorder sentences naturally while preserving intent.",
|
| 13 |
-
"Write as a senior consultant reaching out professionally."
|
| 14 |
]
|
| 15 |
|
| 16 |
-
def build_prompt(
|
| 17 |
variation = random.choice(VARIATION_HINTS)
|
| 18 |
return f"""
|
| 19 |
-
Rewrite the following email for a business audience.
|
| 20 |
|
| 21 |
Requirements:
|
| 22 |
-
-
|
| 23 |
- Suitable for Gmail Primary inbox
|
| 24 |
- Clearly indicate availability for freelance consulting
|
| 25 |
-
- Preserve names,
|
| 26 |
-
- Avoid promotional language
|
| 27 |
- {variation}
|
| 28 |
|
| 29 |
Email:
|
| 30 |
-
{
|
| 31 |
"""
|
| 32 |
|
| 33 |
def process_text(input_text):
|
|
@@ -46,7 +47,7 @@ def process_text(input_text):
|
|
| 46 |
|
| 47 |
iface = gr.Interface(
|
| 48 |
fn=process_text,
|
| 49 |
-
inputs=gr.Textbox(lines=10, placeholder="Paste
|
| 50 |
outputs=gr.Textbox(lines=10),
|
| 51 |
title="Professional Email Rewriter",
|
| 52 |
)
|
|
|
|
| 2 |
import random
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
# IMPORTANT: use a Space or hosted inference endpoint
|
| 6 |
+
MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
|
| 7 |
+
|
| 8 |
client = InferenceClient(model=MODEL_NAME)
|
| 9 |
|
| 10 |
VARIATION_HINTS = [
|
| 11 |
+
"Use a concise and professional consulting tone.",
|
| 12 |
+
"Write neutrally and to the point.",
|
| 13 |
+
"Keep the email crisp and business-focused.",
|
| 14 |
"Reorder sentences naturally while preserving intent.",
|
|
|
|
| 15 |
]
|
| 16 |
|
| 17 |
+
def build_prompt(text):
|
| 18 |
variation = random.choice(VARIATION_HINTS)
|
| 19 |
return f"""
|
| 20 |
+
Rewrite the following email for a professional business audience.
|
| 21 |
|
| 22 |
Requirements:
|
| 23 |
+
- Human-written, professional tone
|
| 24 |
- Suitable for Gmail Primary inbox
|
| 25 |
- Clearly indicate availability for freelance consulting
|
| 26 |
+
- Preserve names, numbers, and links
|
| 27 |
+
- Avoid promotional or sales language
|
| 28 |
- {variation}
|
| 29 |
|
| 30 |
Email:
|
| 31 |
+
{text}
|
| 32 |
"""
|
| 33 |
|
| 34 |
def process_text(input_text):
|
|
|
|
| 47 |
|
| 48 |
iface = gr.Interface(
|
| 49 |
fn=process_text,
|
| 50 |
+
inputs=gr.Textbox(lines=10, placeholder="Paste email content here"),
|
| 51 |
outputs=gr.Textbox(lines=10),
|
| 52 |
title="Professional Email Rewriter",
|
| 53 |
)
|