Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,25 +4,18 @@ from groq import Groq
|
|
4 |
def clean_text_from_file(file_path):
|
5 |
with open(file_path, "r", encoding="utf-8") as file:
|
6 |
text = file.read()
|
7 |
-
# Qui puoi aggiungere la logica per pulire il testo
|
8 |
-
# ad esempio, rimuovendo parti non desiderate
|
9 |
-
# o applicando altre trasformazioni necessarie
|
10 |
-
# Una volta pulito, restituisci il testo
|
11 |
return text
|
12 |
|
13 |
def generate_narrative_arc(narrative_arc):
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
return "La persuasione narrativa"
|
24 |
-
elif narrative_arc == "Conciso":
|
25 |
-
return "Conciso e Super Stringato"
|
26 |
|
27 |
def generate_marketing_model(marketing_model):
|
28 |
if marketing_model in ["PAS", "AIDA", "BAB", "4Cs", "So What", "PPPP", "SSS", "FAB", "SLAP", "4Us"]:
|
@@ -311,7 +304,10 @@ def generate_response(input_testuale_utente, tones, output_type, narrative_arc,m
|
|
311 |
output_textbox_1 = "### Tones Selected: " + ', '.join(tones) + "\n\n" "### Assistant Message: " + assistant_message
|
312 |
output_textbox_2 = response_content
|
313 |
|
314 |
-
|
|
|
|
|
|
|
315 |
|
316 |
choices = ["π Formal", "π Informal", "π Long", "π Short", "π‘ Inspiring", "π Ironic"]
|
317 |
output_types = ["REVIEW Reply", "Facebook Post", "Instagram Post", "Linkedin Post", "EMAIL Reply", "NEWSLETTER", "Marketing Strategy", "Coaching", "Hotel Management"]
|
@@ -321,29 +317,22 @@ personifications = ["π¨ Brand / Hotel", "π§βπ« Coach", "π¨βπΌ Hote
|
|
321 |
languages = ["Italian", "English", "French", "Spanish"] # Add more languages as needed
|
322 |
|
323 |
|
324 |
-
additional_text_output_prompt = gr.Textbox(label="Prompt composto per te:", placeholder="...")
|
325 |
|
326 |
|
327 |
iface = gr.Interface(
|
328 |
fn=generate_response,
|
329 |
inputs=[
|
330 |
gr.Textbox(label="Trasformo le tue idee in cose pratiche. Copia incolla e Vai!"),
|
331 |
-
#gr.HTML("<h3>Stile del Messaggio</h3>"),
|
332 |
gr.CheckboxGroup(choices=choices, label="Toni e preferenze"),
|
333 |
-
#gr.HTML("<h3>A cosa ti serve?</h3>"),
|
334 |
gr.Radio(choices=output_types, label="Output Type", value="Ecco la magia..."),
|
335 |
-
#gr.HTML("<h3>Applica STORYTELLING</h3>"),
|
336 |
gr.Radio(choices=narrative_arcs, label="Scegli un arco narrativo"),
|
337 |
-
#gr.HTML("<h3>Applica Marketing Framework</h3>"),
|
338 |
gr.Radio(choices=marketing_models, label="Scegli un marketing model"),
|
339 |
-
#gr.HTML("<h3>\"CHI\" risponde?</h3>"),
|
340 |
gr.Radio(choices=personifications, label="Scegli l'impersonificazione"),
|
341 |
-
#gr.HTML("<h3>In Quale Lingua?</h3>"),
|
342 |
gr.Radio(choices=languages, label="Select output language")
|
343 |
],
|
344 |
outputs=[
|
345 |
gr.HTML("<h3>Prompt Utilizzato</h3>"),
|
346 |
-
additional_text_output_prompt,
|
347 |
gr.Textbox(label="Ecco a te")
|
348 |
],
|
349 |
title="Hotel Guru Assistant",
|
|
|
4 |
def clean_text_from_file(file_path):
|
5 |
with open(file_path, "r", encoding="utf-8") as file:
|
6 |
text = file.read()
|
|
|
|
|
|
|
|
|
7 |
return text
|
8 |
|
9 |
def generate_narrative_arc(narrative_arc):
|
10 |
+
narrative_mapping = {
|
11 |
+
"Hero's Journey": "Il viaggio dell'eroe",
|
12 |
+
"Story Cycle": "Il ciclo della storia",
|
13 |
+
"Motivation Sequence": "La sequenza di motivazione",
|
14 |
+
"Narrative Transportation": "Il trasporto narrativo",
|
15 |
+
"Narrative Persuasion": "La persuasione narrativa",
|
16 |
+
"Conciso": "Conciso e Super Stringato"
|
17 |
+
}
|
18 |
+
return narrative_mapping.get(narrative_arc, "")
|
|
|
|
|
|
|
19 |
|
20 |
def generate_marketing_model(marketing_model):
|
21 |
if marketing_model in ["PAS", "AIDA", "BAB", "4Cs", "So What", "PPPP", "SSS", "FAB", "SLAP", "4Us"]:
|
|
|
304 |
output_textbox_1 = "### Tones Selected: " + ', '.join(tones) + "\n\n" "### Assistant Message: " + assistant_message
|
305 |
output_textbox_2 = response_content
|
306 |
|
307 |
+
print("Prompt composto per te:", assistant_message) # This line prints the debug information to the terminal
|
308 |
+
|
309 |
+
# Return only the necessary outputs for the Gradio interface, excluding the debug information
|
310 |
+
return output_html, output_textbox_2
|
311 |
|
312 |
choices = ["π Formal", "π Informal", "π Long", "π Short", "π‘ Inspiring", "π Ironic"]
|
313 |
output_types = ["REVIEW Reply", "Facebook Post", "Instagram Post", "Linkedin Post", "EMAIL Reply", "NEWSLETTER", "Marketing Strategy", "Coaching", "Hotel Management"]
|
|
|
317 |
languages = ["Italian", "English", "French", "Spanish"] # Add more languages as needed
|
318 |
|
319 |
|
320 |
+
#additional_text_output_prompt = gr.Textbox(label="Prompt composto per te:", placeholder="...")
|
321 |
|
322 |
|
323 |
iface = gr.Interface(
|
324 |
fn=generate_response,
|
325 |
inputs=[
|
326 |
gr.Textbox(label="Trasformo le tue idee in cose pratiche. Copia incolla e Vai!"),
|
|
|
327 |
gr.CheckboxGroup(choices=choices, label="Toni e preferenze"),
|
|
|
328 |
gr.Radio(choices=output_types, label="Output Type", value="Ecco la magia..."),
|
|
|
329 |
gr.Radio(choices=narrative_arcs, label="Scegli un arco narrativo"),
|
|
|
330 |
gr.Radio(choices=marketing_models, label="Scegli un marketing model"),
|
|
|
331 |
gr.Radio(choices=personifications, label="Scegli l'impersonificazione"),
|
|
|
332 |
gr.Radio(choices=languages, label="Select output language")
|
333 |
],
|
334 |
outputs=[
|
335 |
gr.HTML("<h3>Prompt Utilizzato</h3>"),
|
|
|
336 |
gr.Textbox(label="Ecco a te")
|
337 |
],
|
338 |
title="Hotel Guru Assistant",
|