Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -117,7 +117,6 @@ def generate(goal, kind, tone, audience, length, constraints, language, n, tier=
|
|
| 117 |
constraints = normalize(constraints, "none")
|
| 118 |
language = normalize(language, "Indonesian")
|
| 119 |
|
| 120 |
-
# batas varian
|
| 121 |
limits = {"free": 5, "premium": 10, "super": 20}
|
| 122 |
n = max(1, min(limits[tier], int(n)))
|
| 123 |
|
|
@@ -125,9 +124,6 @@ def generate(goal, kind, tone, audience, length, constraints, language, n, tier=
|
|
| 125 |
kind, goal, tone, audience, length, constraints, language, n, tier
|
| 126 |
)
|
| 127 |
|
| 128 |
-
# ============================
|
| 129 |
-
# FORMAT PROMPT SIAP PAKAI
|
| 130 |
-
# ============================
|
| 131 |
ready = []
|
| 132 |
for v in variants:
|
| 133 |
if kind == "text":
|
|
@@ -155,13 +151,11 @@ def super_handler(token, *args):
|
|
| 155 |
# ============================
|
| 156 |
# UI
|
| 157 |
# ============================
|
| 158 |
-
with gr.Blocks(
|
| 159 |
|
| 160 |
gr.Markdown("# π AIPromptLab β Super Premium Edition")
|
| 161 |
|
| 162 |
-
#
|
| 163 |
-
# FREE TAB
|
| 164 |
-
# ============================
|
| 165 |
with gr.Tab("Free"):
|
| 166 |
goal = gr.Textbox(label="Goal")
|
| 167 |
kind = gr.Radio(["text", "image", "code"], value="text")
|
|
@@ -173,15 +167,13 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 173 |
n = gr.Slider(1, 5, value=3, step=1, label="Jumlah Varian")
|
| 174 |
|
| 175 |
btn = gr.Button("Generate (Free)")
|
| 176 |
-
out = gr.Textbox(label="Prompt Siap Pakai", lines=20)
|
| 177 |
copy_btn = gr.Button("Copy")
|
| 178 |
|
| 179 |
btn.click(generate, [goal, kind, tone, audience, length, constraints, language, n], out)
|
| 180 |
-
copy_btn.click(None,
|
| 181 |
|
| 182 |
-
#
|
| 183 |
-
# PREMIUM TAB
|
| 184 |
-
# ============================
|
| 185 |
with gr.Tab("Premium"):
|
| 186 |
token_p = gr.Textbox(label="Token Premium", type="password")
|
| 187 |
goal_p = gr.Textbox(label="Goal")
|
|
@@ -194,20 +186,16 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 194 |
n_p = gr.Slider(1, 10, value=5, step=1, label="Jumlah Varian")
|
| 195 |
|
| 196 |
btn_p = gr.Button("Generate (Premium)")
|
| 197 |
-
out_p = gr.Textbox(label="Prompt Siap Pakai", lines=20)
|
| 198 |
copy_p = gr.Button("Copy")
|
| 199 |
|
| 200 |
btn_p.click(premium_handler,
|
| 201 |
[token_p, goal_p, kind_p, tone_p, audience_p, length_p, constraints_p, language_p, n_p],
|
| 202 |
out_p)
|
| 203 |
-
copy_p.click(None,
|
| 204 |
|
| 205 |
-
#
|
| 206 |
-
# SUPER PREMIUM TAB
|
| 207 |
-
# ============================
|
| 208 |
with gr.Tab("Super Premium"):
|
| 209 |
-
gr.Markdown("### π Super Premium β Output Maksimal, Siap Pakai")
|
| 210 |
-
|
| 211 |
token_s = gr.Textbox(label="Token Super Premium", type="password")
|
| 212 |
goal_s = gr.Textbox(label="Goal")
|
| 213 |
kind_s = gr.Radio(["text", "image", "code"], value="text")
|
|
@@ -219,13 +207,19 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 219 |
n_s = gr.Slider(1, 20, value=10, step=1, label="Jumlah Varian")
|
| 220 |
|
| 221 |
btn_s = gr.Button("Generate (Super Premium)")
|
| 222 |
-
out_s = gr.Textbox(label="Prompt Siap Pakai", lines=20)
|
| 223 |
copy_s = gr.Button("Copy")
|
| 224 |
|
| 225 |
btn_s.click(super_handler,
|
| 226 |
[token_s, goal_s, kind_s, tone_s, audience_s, length_s, constraints_s, language_s, n_s],
|
| 227 |
out_s)
|
| 228 |
-
copy_s.click(None,
|
| 229 |
|
| 230 |
-
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
constraints = normalize(constraints, "none")
|
| 118 |
language = normalize(language, "Indonesian")
|
| 119 |
|
|
|
|
| 120 |
limits = {"free": 5, "premium": 10, "super": 20}
|
| 121 |
n = max(1, min(limits[tier], int(n)))
|
| 122 |
|
|
|
|
| 124 |
kind, goal, tone, audience, length, constraints, language, n, tier
|
| 125 |
)
|
| 126 |
|
|
|
|
|
|
|
|
|
|
| 127 |
ready = []
|
| 128 |
for v in variants:
|
| 129 |
if kind == "text":
|
|
|
|
| 151 |
# ============================
|
| 152 |
# UI
|
| 153 |
# ============================
|
| 154 |
+
with gr.Blocks() as demo:
|
| 155 |
|
| 156 |
gr.Markdown("# π AIPromptLab β Super Premium Edition")
|
| 157 |
|
| 158 |
+
# FREE TAB
|
|
|
|
|
|
|
| 159 |
with gr.Tab("Free"):
|
| 160 |
goal = gr.Textbox(label="Goal")
|
| 161 |
kind = gr.Radio(["text", "image", "code"], value="text")
|
|
|
|
| 167 |
n = gr.Slider(1, 5, value=3, step=1, label="Jumlah Varian")
|
| 168 |
|
| 169 |
btn = gr.Button("Generate (Free)")
|
| 170 |
+
out = gr.Textbox(label="Prompt Siap Pakai", lines=20, elem_id="copy-free")
|
| 171 |
copy_btn = gr.Button("Copy")
|
| 172 |
|
| 173 |
btn.click(generate, [goal, kind, tone, audience, length, constraints, language, n], out)
|
| 174 |
+
copy_btn.click(None, None, None, js="navigator.clipboard.writeText(document.getElementById('copy-free').value)")
|
| 175 |
|
| 176 |
+
# PREMIUM TAB
|
|
|
|
|
|
|
| 177 |
with gr.Tab("Premium"):
|
| 178 |
token_p = gr.Textbox(label="Token Premium", type="password")
|
| 179 |
goal_p = gr.Textbox(label="Goal")
|
|
|
|
| 186 |
n_p = gr.Slider(1, 10, value=5, step=1, label="Jumlah Varian")
|
| 187 |
|
| 188 |
btn_p = gr.Button("Generate (Premium)")
|
| 189 |
+
out_p = gr.Textbox(label="Prompt Siap Pakai", lines=20, elem_id="copy-premium")
|
| 190 |
copy_p = gr.Button("Copy")
|
| 191 |
|
| 192 |
btn_p.click(premium_handler,
|
| 193 |
[token_p, goal_p, kind_p, tone_p, audience_p, length_p, constraints_p, language_p, n_p],
|
| 194 |
out_p)
|
| 195 |
+
copy_p.click(None, None, None, js="navigator.clipboard.writeText(document.getElementById('copy-premium').value)")
|
| 196 |
|
| 197 |
+
# SUPER PREMIUM TAB
|
|
|
|
|
|
|
| 198 |
with gr.Tab("Super Premium"):
|
|
|
|
|
|
|
| 199 |
token_s = gr.Textbox(label="Token Super Premium", type="password")
|
| 200 |
goal_s = gr.Textbox(label="Goal")
|
| 201 |
kind_s = gr.Radio(["text", "image", "code"], value="text")
|
|
|
|
| 207 |
n_s = gr.Slider(1, 20, value=10, step=1, label="Jumlah Varian")
|
| 208 |
|
| 209 |
btn_s = gr.Button("Generate (Super Premium)")
|
| 210 |
+
out_s = gr.Textbox(label="Prompt Siap Pakai", lines=20, elem_id="copy-super")
|
| 211 |
copy_s = gr.Button("Copy")
|
| 212 |
|
| 213 |
btn_s.click(super_handler,
|
| 214 |
[token_s, goal_s, kind_s, tone_s, audience_s, length_s, constraints_s, language_s, n_s],
|
| 215 |
out_s)
|
| 216 |
+
copy_s.click(None, None, None, js="navigator.clipboard.writeText(document.getElementById('copy-super').value)")
|
| 217 |
|
| 218 |
+
# ============================
|
| 219 |
+
# LAUNCH
|
| 220 |
+
# ============================
|
| 221 |
+
demo.launch(
|
| 222 |
+
server_name="0.0.0.0",
|
| 223 |
+
server_port=7860,
|
| 224 |
+
theme=gr.themes.Soft()
|
| 225 |
+
)
|