Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,10 +58,13 @@ TONES = {
|
|
| 58 |
def rewrite_one(text: str, tone_name: str) -> str:
|
| 59 |
"""Call the model once for a single tone."""
|
| 60 |
instruction = TONES[tone_name]
|
|
|
|
| 61 |
try:
|
| 62 |
-
resp = client.
|
| 63 |
model=MODEL,
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
{
|
| 66 |
"role": "system",
|
| 67 |
"content": (
|
|
@@ -70,16 +73,18 @@ def rewrite_one(text: str, tone_name: str) -> str:
|
|
| 70 |
"no quotes around the result."
|
| 71 |
),
|
| 72 |
},
|
| 73 |
-
{
|
|
|
|
|
|
|
|
|
|
| 74 |
],
|
| 75 |
-
max_completion_tokens=2000,
|
| 76 |
-
reasoning_effort="minimal",
|
| 77 |
)
|
| 78 |
-
|
|
|
|
|
|
|
| 79 |
except Exception as e:
|
| 80 |
return f"⚠️ Error calling the model: {e}"
|
| 81 |
|
| 82 |
-
|
| 83 |
def shift_all(text: str, selected_tones: list[str]) -> str:
|
| 84 |
"""Run the rewrite for each selected tone, return one Markdown blob."""
|
| 85 |
if not selected_tones:
|
|
@@ -100,7 +105,7 @@ with gr.Blocks(title="Tone Shifter", theme=gr.themes.Soft()) as demo:
|
|
| 100 |
gr.Markdown(
|
| 101 |
"# 🎭 Tone Shifter\n"
|
| 102 |
"Paste any text, pick the vibes, watch it transform. "
|
| 103 |
-
"*Powered by GPT-
|
| 104 |
)
|
| 105 |
|
| 106 |
with gr.Row():
|
|
|
|
| 58 |
def rewrite_one(text: str, tone_name: str) -> str:
|
| 59 |
"""Call the model once for a single tone."""
|
| 60 |
instruction = TONES[tone_name]
|
| 61 |
+
|
| 62 |
try:
|
| 63 |
+
resp = client.responses.create(
|
| 64 |
model=MODEL,
|
| 65 |
+
reasoning={"effort": "minimal"},
|
| 66 |
+
max_output_tokens=700,
|
| 67 |
+
input=[
|
| 68 |
{
|
| 69 |
"role": "system",
|
| 70 |
"content": (
|
|
|
|
| 73 |
"no quotes around the result."
|
| 74 |
),
|
| 75 |
},
|
| 76 |
+
{
|
| 77 |
+
"role": "user",
|
| 78 |
+
"content": text,
|
| 79 |
+
},
|
| 80 |
],
|
|
|
|
|
|
|
| 81 |
)
|
| 82 |
+
|
| 83 |
+
return resp.output_text.strip()
|
| 84 |
+
|
| 85 |
except Exception as e:
|
| 86 |
return f"⚠️ Error calling the model: {e}"
|
| 87 |
|
|
|
|
| 88 |
def shift_all(text: str, selected_tones: list[str]) -> str:
|
| 89 |
"""Run the rewrite for each selected tone, return one Markdown blob."""
|
| 90 |
if not selected_tones:
|
|
|
|
| 105 |
gr.Markdown(
|
| 106 |
"# 🎭 Tone Shifter\n"
|
| 107 |
"Paste any text, pick the vibes, watch it transform. "
|
| 108 |
+
"*Powered by GPT-5 nano, hosted on Hugging Face Spaces.*"
|
| 109 |
)
|
| 110 |
|
| 111 |
with gr.Row():
|