michecosta commited on
Commit
f74e1c9
·
verified ·
1 Parent(s): 0276bd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -31
app.py CHANGED
@@ -138,16 +138,13 @@ def generate_response(input_testuale_utente, tones, output_type, narrative_arc,m
138
  messages = [
139
  {"role": "user", "content": input_testuale_utente},
140
  ]
141
- assistant_message = f"""
142
- Scrivi esclusivamente nella seguente lingua: {choosing_language(language_choosen)}
143
- """
144
 
145
  if output_type == "REVIEW Reply":
146
  assistant_message += f"""\n\n Scrivi in {language_choosen} una risposta a questa recensione '{inject_personification(personification_focus)}'
147
- in maniera non troppo piatta e banale o generica. usando esclusivamente il seguente arco narrativo: '{generate_narrative_arc(narrative_arc)}' e la struttura di copywriting '{generate_marketing_model(marketing_model)}'.
148
- usando un tono {', '.join(tones)}. Non serve che tu risponda a ogni singolo punto emerso dalla recensione alla quale rispondi. E' molto importante che ti attieni rigorosamente al tono o alla combinazione di toni scelti e soprattutto che scrivi poco se il tono scelto è anche conciso.
149
  """
150
- assistant_message += clean_text_from_file('comerispondere_recensioni.txt')
151
  elif output_type == "Facebook Post":
152
  assistant_message += f"""\n\n crea un post per Facebook in {language_choosen} con un tono {', '.join(tones)} '{inject_personification(personification_focus)}'
153
  usando esclusivamente il seguente arco narrativo: '{generate_narrative_arc(narrative_arc)}' e la struttura di copywriting '{generate_marketing_model(marketing_model)}' riguardante l'argomento proposto nel testo di input.
@@ -211,13 +208,7 @@ def generate_response(input_testuale_utente, tones, output_type, narrative_arc,m
211
 
212
 
213
 
214
-
215
-
216
- response_content = ""
217
- #response_content = "Tones Selected: " + ', '.join(tones) + "\n\n"
218
- #response_content += "Assistant Message: " + assistant_message + "\n\n"
219
-
220
-
221
 
222
  completion = client.chat.completions.create(
223
  model="mixtral-8x7b-32768",
@@ -229,8 +220,9 @@ def generate_response(input_testuale_utente, tones, output_type, narrative_arc,m
229
  stop=None,
230
  )
231
 
232
-
233
-
 
234
  short_message_added = False
235
  informal_added = False
236
  formal_added = False
@@ -247,7 +239,7 @@ def generate_response(input_testuale_utente, tones, output_type, narrative_arc,m
247
  formal_added = True
248
 
249
 
250
- assistant_message += f"""Scrivi esclusivamente nella seguente lingua: {choosing_language(language_choosen)} """
251
 
252
 
253
  marketing_models_table_html = generate_marketing_models_table_html()
@@ -258,31 +250,20 @@ def generate_response(input_testuale_utente, tones, output_type, narrative_arc,m
258
 
259
 
260
  assistant_message += clean_text_from_file('hotel_core_info.txt')
261
- #assistant_message += clean_text_from_file('/Users/michelecostantini/Desktop/crewAI/hotel_core_info.txt')
262
 
263
 
264
 
265
 
266
  if informal_added == True:
267
  assistant_message += """\n\n Ricorda di scrivere esclusivamente un testo molto corto (very short text to write)"""
268
-
269
-
270
-
271
-
272
-
273
- messages.append({"role": "assistant", "content": assistant_message})
274
-
275
-
276
-
277
-
278
-
279
-
280
 
281
  output_html = "<h3>Prompt Utilizzato</h3>"
282
  output_textbox_1 = "### Tones Selected: " + ', '.join(tones) + "\n\n" "### Assistant Message: " + assistant_message
283
- output_textbox_2 = response_content + "\n\n\n\n #############################"
284
 
285
- print("\n\n\n\n\n\n\n\n\n\n\n\n ############################# \n\n Prompt composto per te:", output_textbox_1) # This line prints the debug information to the terminal
286
 
287
  # Return only the necessary outputs for the Gradio interface, excluding the debug information
288
  return output_html, output_textbox_2
 
138
  messages = [
139
  {"role": "user", "content": input_testuale_utente},
140
  ]
141
+ assistant_message = f"""Scrivi esclusivamente nella seguente lingua: {choosing_language(language_choosen)} """
 
 
142
 
143
  if output_type == "REVIEW Reply":
144
  assistant_message += f"""\n\n Scrivi in {language_choosen} una risposta a questa recensione '{inject_personification(personification_focus)}'
145
+ usando esclusivamente il seguente arco narrativo: '{generate_narrative_arc(narrative_arc)}' e la struttura di copywriting '{generate_marketing_model(marketing_model)}'.
146
+ \n\n Usa un tono {', '.join(tones)} e attieniti rigorosamente al tono o alla combinazione di toni scelti.
147
  """
 
148
  elif output_type == "Facebook Post":
149
  assistant_message += f"""\n\n crea un post per Facebook in {language_choosen} con un tono {', '.join(tones)} '{inject_personification(personification_focus)}'
150
  usando esclusivamente il seguente arco narrativo: '{generate_narrative_arc(narrative_arc)}' e la struttura di copywriting '{generate_marketing_model(marketing_model)}' riguardante l'argomento proposto nel testo di input.
 
208
 
209
 
210
 
211
+ messages.append({"role": "assistant", "content": assistant_message})
 
 
 
 
 
 
212
 
213
  completion = client.chat.completions.create(
214
  model="mixtral-8x7b-32768",
 
220
  stop=None,
221
  )
222
 
223
+ response_content = ""
224
+ #response_content = "Tones Selected: " + ', '.join(tones) + "\n\n"
225
+ #response_content += "Assistant Message: " + assistant_message + "\n\n"
226
  short_message_added = False
227
  informal_added = False
228
  formal_added = False
 
239
  formal_added = True
240
 
241
 
242
+ assistant_message = f"""Scrivi esclusivamente nella seguente lingua: {choosing_language(language_choosen)} """
243
 
244
 
245
  marketing_models_table_html = generate_marketing_models_table_html()
 
250
 
251
 
252
  assistant_message += clean_text_from_file('hotel_core_info.txt')
253
+ #assistant_message += clean_text_from_file('/Users/michelecostantini/Desktop/mic_crewai/hotel_core_info.txt')
254
 
255
 
256
 
257
 
258
  if informal_added == True:
259
  assistant_message += """\n\n Ricorda di scrivere esclusivamente un testo molto corto (very short text to write)"""
260
+
 
 
 
 
 
 
 
 
 
 
 
261
 
262
  output_html = "<h3>Prompt Utilizzato</h3>"
263
  output_textbox_1 = "### Tones Selected: " + ', '.join(tones) + "\n\n" "### Assistant Message: " + assistant_message
264
+ output_textbox_2 = response_content
265
 
266
+ print("Prompt composto per te:", assistant_message) # This line prints the debug information to the terminal
267
 
268
  # Return only the necessary outputs for the Gradio interface, excluding the debug information
269
  return output_html, output_textbox_2