Spaces:
Runtime error
Runtime error
AJ-Gazin
commited on
Commit
•
7666783
1
Parent(s):
a86434c
req.txt
Browse files- app.py +9 -18
- requirements.txt +1 -0
app.py
CHANGED
@@ -23,7 +23,7 @@ def check_api_key(api_key):
|
|
23 |
|
24 |
def generate_english_text(api_key, description, tone, channel, customizations, temperature):
|
25 |
openai_client = OpenAI(api_key=api_key)
|
26 |
-
customizations = [c.strip() for c in customizations
|
27 |
|
28 |
messages = [
|
29 |
{"role": "system", "content": SYSTEM_PROMPT},
|
@@ -149,21 +149,12 @@ with gr.Blocks(js=js_func, css=".connection-status { text-align: center; margin-
|
|
149 |
tone_input = gr.Dropdown(["Friendly and inviting", "Authoritative and confident", "Informative", "Enthusiastic and energetic", "Inspirational", "Exclusive and luxurious"], label="Tone", allow_custom_value=True)
|
150 |
channel_input = gr.Dropdown(["Facebook", "Instagram", "LinkedIn", "Twitter", "Viber", "Telegram", "Email"], label="Channel", allow_custom_value=True)
|
151 |
|
152 |
-
customizations_input = gr.
|
153 |
-
label="Text Customizations (comma-separated)",
|
154 |
-
placeholder="e.g., Shorten, Add emojis"
|
155 |
-
)
|
156 |
-
customization_options = gr.Dropdown(
|
157 |
["Modernize", "Expand", "Add emojis", "Simplify language", "Improve writing", "Correct spelling"],
|
158 |
-
label="
|
159 |
-
info="
|
160 |
-
show_label=
|
161 |
-
|
162 |
-
|
163 |
-
customization_options.change(
|
164 |
-
fn=add_customization,
|
165 |
-
inputs=[customization_options, customizations_input],
|
166 |
-
outputs=customizations_input
|
167 |
)
|
168 |
|
169 |
translation_input = gr.Dropdown(["English", "Moldovan", "Belarusian", "Albanian", "Russian", "Arabic", "Ukrainian", "French", "Kazakh", "Bosnian", "Armenian", "Serbian", "Tajik", "Azerbaijani", "Uzbek", "Romanian", "Spanish"], label="Translation", allow_custom_value=False)
|
@@ -184,9 +175,9 @@ with gr.Blocks(js=js_func, css=".connection-status { text-align: center; margin-
|
|
184 |
|
185 |
gr.Examples(
|
186 |
examples=[
|
187 |
-
["Get ready for incredible deals! Save up to 50% on our wide selection of products during our annual Summer Sale. Visit our website or store today to take advantage of these limited-time offers.", "Enthusiastic and energetic", "Email", "Add emojis, Improve writing", "English"],
|
188 |
-
["Introducing our latest innovation: the all-new SmartWatch Pro. With advanced features, sleek design, and unmatched performance, it's the perfect companion for your active lifestyle. Order now and be among the first to experience the future of wearable technology.", "Informative", "Facebook", "Simplify language", "French"],
|
189 |
-
["To our valued customers, we want to express our deepest gratitude for your continued support. As a token of our appreciation, we're offering an exclusive 20% discount on your next purchase. Use code THANKYOU20 at checkout. Your satisfaction is our top priority!", "Friendly and inviting", "Instagram", "Shorten, Correct spelling", "Spanish"]
|
190 |
],
|
191 |
inputs=[description_input, tone_input, channel_input, customizations_input, translation_input]
|
192 |
)
|
|
|
23 |
|
24 |
def generate_english_text(api_key, description, tone, channel, customizations, temperature):
|
25 |
openai_client = OpenAI(api_key=api_key)
|
26 |
+
customizations = [c.strip() for c in customizations] if customizations else []
|
27 |
|
28 |
messages = [
|
29 |
{"role": "system", "content": SYSTEM_PROMPT},
|
|
|
149 |
tone_input = gr.Dropdown(["Friendly and inviting", "Authoritative and confident", "Informative", "Enthusiastic and energetic", "Inspirational", "Exclusive and luxurious"], label="Tone", allow_custom_value=True)
|
150 |
channel_input = gr.Dropdown(["Facebook", "Instagram", "LinkedIn", "Twitter", "Viber", "Telegram", "Email"], label="Channel", allow_custom_value=True)
|
151 |
|
152 |
+
customizations_input = gr.Dropdown(
|
|
|
|
|
|
|
|
|
153 |
["Modernize", "Expand", "Add emojis", "Simplify language", "Improve writing", "Correct spelling"],
|
154 |
+
label="Text Customizations",
|
155 |
+
info="Select customization options",
|
156 |
+
show_label=True,
|
157 |
+
multiselect=True # Allow multiple selections
|
|
|
|
|
|
|
|
|
|
|
158 |
)
|
159 |
|
160 |
translation_input = gr.Dropdown(["English", "Moldovan", "Belarusian", "Albanian", "Russian", "Arabic", "Ukrainian", "French", "Kazakh", "Bosnian", "Armenian", "Serbian", "Tajik", "Azerbaijani", "Uzbek", "Romanian", "Spanish"], label="Translation", allow_custom_value=False)
|
|
|
175 |
|
176 |
gr.Examples(
|
177 |
examples=[
|
178 |
+
["Get ready for incredible deals! Save up to 50% on our wide selection of products during our annual Summer Sale. Visit our website or store today to take advantage of these limited-time offers.", "Enthusiastic and energetic", "Email", ["Add emojis", "Improve writing"], "English"],
|
179 |
+
["Introducing our latest innovation: the all-new SmartWatch Pro. With advanced features, sleek design, and unmatched performance, it's the perfect companion for your active lifestyle. Order now and be among the first to experience the future of wearable technology.", "Informative", "Facebook", ["Simplify language"], "French"],
|
180 |
+
["To our valued customers, we want to express our deepest gratitude for your continued support. As a token of our appreciation, we're offering an exclusive 20% discount on your next purchase. Use code THANKYOU20 at checkout. Your satisfaction is our top priority!", "Friendly and inviting", "Instagram", ["Shorten", "Correct spelling"], "Spanish"]
|
181 |
],
|
182 |
inputs=[description_input, tone_input, channel_input, customizations_input, translation_input]
|
183 |
)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
openai
|