tunght commited on
Commit
a20cccf
·
1 Parent(s): 98a1118

Add prompts to remove common openings

Browse files
Files changed (1) hide show
  1. app.py +48 -27
app.py CHANGED
@@ -322,6 +322,8 @@ def generate(*data):
322
  # print(term)
323
 
324
  batch = []
 
 
325
  for i in range(visible + 1):
326
  structure = struct_ref[2 * i]
327
  copy = struct_ref[2 * i + 1]
@@ -332,7 +334,8 @@ def generate(*data):
332
  messages = [
333
  SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
334
  HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
335
- Write in a way that target the customer.
 
336
  Make sure that the structure of each output follows the reference structure.
337
  Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
338
  Use markdown format for each output.
@@ -340,9 +343,11 @@ Do not include any part of the reference structure in the output.
340
  Do not use any of the excluded words in the output.
341
  Include all included words in the output.
342
  Do not hallucinate any information.
343
- Use creative language in each output.
 
 
344
  Rate the quality of each version based on the following criteria:
345
- - how well it follows the reference tone of voice, rythm, cadence and style.
346
  - how well it follows the reference structure.
347
  - how faithful it describes the product features.
348
  - how well it avoid the excluded words.
@@ -375,10 +380,15 @@ Make sure that the output is in JSON format, no extra text should be included in
375
 
376
  Product information:
377
  Key features: {feature + detected_features}
 
378
  Intended use: {intended_use}
 
379
  Reference structure: {structure}
 
380
  Reference copy: {copy}
 
381
  Included words: {included_words}
 
382
  Excluded words: {excluded_words}"""),]
383
 
384
  elif len(copy.strip()) > 0:
@@ -387,7 +397,8 @@ Excluded words: {excluded_words}"""),]
387
  messages = [
388
  SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
389
  HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
390
- Write in a way that target the customer.
 
391
  Make sure that the structure of each output follows the structure of the reference copy.
392
  Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
393
  Use markdown format for each output.
@@ -395,44 +406,49 @@ Do not include any part of the reference structure in the output.
395
  Do not use any of the excluded words in the output.
396
  Include all included words in the output.
397
  Do not hallucinate any information.
398
- Use creative language in each output.
 
 
399
  Rate the quality of each version based on the following criteria:
400
- - how well it follows the reference tone of voice, rythm, cadence and style.
401
- - how well it follows the reference structure.
402
- - how faithful it describes the product features.
403
- - how well it avoid the excluded words.
404
- - how well it includes the included words.
405
- - how creative the language is.
406
- The score should be a number between 0 and 10 with 10 being the best quality.
407
  Return the result in the following JSON format:
408
  {{
409
- "versions": [
410
  {{
411
  "id": 1,
412
  "content": The first product description,
413
- "explanation": A less than 20 word explanation of the score of the first product description,
414
  "score": The score of the first product description
415
  }},
416
  {{
417
  "id": 2,
418
  "content": The second product description,
419
- "explanation": A less than 20 word explanation of the score of the first product description,
420
  "score": The score of the second product description
421
  }},
422
- ...
423
- ],
424
  "best_version": {{
425
  "id": The id of the best version,
426
- "explanation": Explanation for why this version is the best
427
- }}
428
- }}
429
- Make sure that the output is in JSON format, no extra text should be included in the output.
430
-
431
  Product information:
432
- Key features: {feature + detected_features}
433
- Intended use: {intended_use}
 
 
434
  Reference copy: {copy}
 
435
  Included words: {included_words}
 
436
  Excluded words: {excluded_words}"""),]
437
  print(messages[1].content)
438
  print('------------')
@@ -444,15 +460,17 @@ Excluded words: {excluded_words}"""),]
444
  SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
445
  HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
446
  Write in a way that target the customer.
 
447
  Make sure that the structure of each output follows the reference structure.
448
  Use markdown format for each output.
449
  Do not include any part of the reference structure in the output.
450
  Do not use any of the excluded words in the output.
451
  Include all included words in the output.
452
  Do not hallucinate any information.
453
- Use creative language in each output.
 
 
454
  Rate the quality of each version based on the following criteria:
455
- - how well it follows the reference tone of voice, rythm, cadence and style.
456
  - how well it follows the reference structure.
457
  - how faithful it describes the product features.
458
  - how well it avoid the excluded words.
@@ -485,10 +503,13 @@ Make sure that the output is in JSON format, no extra text should be included in
485
 
486
  Product information:
487
  Key features: {feature + detected_features}
 
488
  Intended use: {intended_use}
 
489
  Reference structure: {structure}
490
- Reference copy: {copy}
491
  Included words: {included_words}
 
492
  Excluded words: {excluded_words}"""),]
493
  print(messages[1].content)
494
  print('------------')
 
322
  # print(term)
323
 
324
  batch = []
325
+ min_length = 50
326
+ max_length = 150
327
  for i in range(visible + 1):
328
  structure = struct_ref[2 * i]
329
  copy = struct_ref[2 * i + 1]
 
334
  messages = [
335
  SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
336
  HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
337
+ Write in a way that target the customer.
338
+ For each version, write at least {min_length} words and at most {max_length} words.
339
  Make sure that the structure of each output follows the reference structure.
340
  Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
341
  Use markdown format for each output.
 
343
  Do not use any of the excluded words in the output.
344
  Include all included words in the output.
345
  Do not hallucinate any information.
346
+ Use creative language in each output, do not use the common ways of starting product descriptions.
347
+ Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
348
+ For each version, try to write in different style.
349
  Rate the quality of each version based on the following criteria:
350
+ - how well it follows the tone of voice, rythm, cadence and style of the reference copy.
351
  - how well it follows the reference structure.
352
  - how faithful it describes the product features.
353
  - how well it avoid the excluded words.
 
380
 
381
  Product information:
382
  Key features: {feature + detected_features}
383
+
384
  Intended use: {intended_use}
385
+
386
  Reference structure: {structure}
387
+
388
  Reference copy: {copy}
389
+
390
  Included words: {included_words}
391
+
392
  Excluded words: {excluded_words}"""),]
393
 
394
  elif len(copy.strip()) > 0:
 
397
  messages = [
398
  SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
399
  HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
400
+ Write in a way that target the customer.
401
+ For each version, write at least {min_length} words and at most {max_length} words.
402
  Make sure that the structure of each output follows the structure of the reference copy.
403
  Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
404
  Use markdown format for each output.
 
406
  Do not use any of the excluded words in the output.
407
  Include all included words in the output.
408
  Do not hallucinate any information.
409
+ Use creative language in each output, do not use the common ways of starting product descriptions.
410
+ Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
411
+ For each version, try to write in different style.
412
  Rate the quality of each version based on the following criteria:
413
+ - how well it follows the tone of voice, rythm, cadence and style of the reference copy.
414
+ - how faithful it describes the product features.
415
+ - how well it avoid the excluded words.
416
+ - how well it includes the included words.
417
+ - how creative the language is
418
+ The score should be a number between 0 and 10 with 10 being the best quality.
 
419
  Return the result in the following JSON format:
420
  {{
421
+ "versions": [
422
  {{
423
  "id": 1,
424
  "content": The first product description,
425
+ "explanation": A less than 20 word explanation of the score of the first product description,
426
  "score": The score of the first product description
427
  }},
428
  {{
429
  "id": 2,
430
  "content": The second product description,
431
+ "explanation": A less than 20 word explanation of the score of the first product description,
432
  "score": The score of the second product description
433
  }},
434
+ ...
435
+ ],
436
  "best_version": {{
437
  "id": The id of the best version,
438
+ "explanation": Explanation for why this version is the best
439
+ }}
440
+ }}
441
+ Make sure that the output is in JSON format, no extra text should be included in the output.
442
+
443
  Product information:
444
+ Key features: {feature + detected_features}
445
+
446
+ Intended use: {intended_use}
447
+
448
  Reference copy: {copy}
449
+
450
  Included words: {included_words}
451
+
452
  Excluded words: {excluded_words}"""),]
453
  print(messages[1].content)
454
  print('------------')
 
460
  SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
461
  HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
462
  Write in a way that target the customer.
463
+ For each version, write at least {min_length} words and at most {max_length} words.
464
  Make sure that the structure of each output follows the reference structure.
465
  Use markdown format for each output.
466
  Do not include any part of the reference structure in the output.
467
  Do not use any of the excluded words in the output.
468
  Include all included words in the output.
469
  Do not hallucinate any information.
470
+ Use creative language in each output, do not use the common ways of starting product descriptions.
471
+ Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
472
+ For each version, try to write in different style.
473
  Rate the quality of each version based on the following criteria:
 
474
  - how well it follows the reference structure.
475
  - how faithful it describes the product features.
476
  - how well it avoid the excluded words.
 
503
 
504
  Product information:
505
  Key features: {feature + detected_features}
506
+
507
  Intended use: {intended_use}
508
+
509
  Reference structure: {structure}
510
+
511
  Included words: {included_words}
512
+
513
  Excluded words: {excluded_words}"""),]
514
  print(messages[1].content)
515
  print('------------')