Spaces:
Paused
Paused
File size: 17,916 Bytes
f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c f2bbca9 d990e2c b8505ee d990e2c 8312c1b d990e2c cab320e 8312c1b d990e2c f2bbca9 d990e2c b8505ee f2bbca9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
def str2escaped(input_str: str, remove_spaces: bool = True) -> str:
input_str = input_str.replace('"', '\\"')
lines = input_str.split("\n")
if remove_spaces:
return "\\n".join([line.rstrip() for line in lines])
return "\\n".join(lines)
struct_copy_prompt = """Generate {nversions} versions of the product description for a product with the following information.
Write in a way that target the customer.
For each version, write at least {min_length} words and at most {max_length} words.
Make sure that the structure of each output follows the reference structure. Do not add any additional sentences or structures that are not in the reference structure.
Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
Use markdown format for each output.
Do not include any part of the reference structure in the output.
The structure of the output should follow the reference structure.
Do not use the structure of the reference copy in the output.
Do not use any of the excluded words in the output.
Try to inlcude included words in the output when relevant.
Use the relevant information from the product features and intended use in the output.
Do not hallucinate any information about the product, use only the provided key features and intended use to write about the product.
Note that the reference copy should be used for style and tone only, do not use any part of the reference copy in the output.
Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
Use creative language in each output, do not use the common ways of starting product descriptions.
Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
For each version, try to write in different style.
Put each item in the list on a separate line. Use '-' character to start each item.
Rate the quality of each version based on the following criteria:
- how faithful it describes the product features.
- how well it follows the reference structure.
- how well it follows the tone of voice, rythm, cadence and style of the reference copy.
- how well it avoid the excluded words.
- how well it includes the included words.
- how creative the language is.
The score should be a number between 0 and 10 with 10 being the best quality.
Return the result in the following JSON format:
{{
"versions": [
{{
"id": 1,
"content": The first product description,
"explanation": A less than 20 word explanation of the score of the first product description,
"score": The score of the first product description
}},
{{
"id": 2,
"content": The second product description,
"explanation": A less than 20 word explanation of the score of the first product description,
"score": The score of the second product description
}},
...
],
"best_version": {{
"explanation": Explanation for why this version is the best,
"id": The id of the best version
}}
}}
Make sure that the output is in JSON format, no extra text should be included in the output.
<product_information>
<key_features>
{key_features}
</key_features>
<reference_structure>
{structure}
</reference_structure>
<reference_copy>
{copy}
</reference_copy>
<included_phrases>
{included_phrases}
</included_phrases>
<excluded_phrases>
{excluded_phrases}
</excluded_phrases>
</product_information>"""
copy_prompt = """Generate {nversions} versions of the product description for a product with the following information.
Write in a way that target the customer.
For each version, write at least {min_length} words and at most {max_length} words.
Make sure that the structure of each output follows the structure of the reference copy.
Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
Use markdown format for each output.
Make sure that the structure of each output follows the structure of the reference copy.
Do not use any of the excluded words in the output.
Try to inlcude included words in the output when relevant.
Use the relevant information from the product features and intended use in the output.
Do not hallucinate any information about the product, use only the provided key features and intended use to write about the product.
Note that the reference copy should be used for style and tone only, do not use any part of the reference copy in the output.
Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
Use creative language in each output, do not use the common ways of starting product descriptions.
Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
For each version, try to write in different style.
Put each item in the list on a separate line. Use '-' character to start each item.
Rate the quality of each version based on the following criteria:
- how faithful it describes the product features.
- how well it follows the tone of voice, rythm, cadence and style of the reference copy.
- how well it avoid the excluded words.
- how well it includes the included words.
- how creative the language is
The score should be a number between 0 and 10 with 10 being the best quality.
Return the result in the following JSON format:
{{
"versions": [
{{
"id": 1,
"content": The first product description,
"explanation": A less than 20 word explanation of the score of the first product description,
"score": The score of the first product description
}},
{{
"id": 2,
"content": The second product description,
"explanation": A less than 20 word explanation of the score of the first product description,
"score": The score of the second product description
}},
...
],
"best_version": {{
"explanation": Explanation for why this version is the best,
"id": The id of the best version
}}
}}
Make sure that the output is in JSON format, no extra text should be included in the output.
<product_information>
<key_features>
{key_features}
</key_features>
<reference_copy>
{copy}
</reference_copy>
<included_phrases>
{included_phrases}
</included_phrases>
<excluded_phrases>
{excluded_phrases}
</excluded_phrases>
</product_information>"""
struct_prompt = """Generate {nversions} versions of the product description for a product with the following information.
Write in a way that target the customer.
For each version, write at least {min_length} words and at most {max_length} words.
Make sure that the structure of each output follows the reference structure. Do not add any additional sentences or structures that are not in the reference structure.
Use markdown format for each output.
Do not include any part of the reference structure in the output.
Make sure that the structure of each output follows the reference structure.
Do not use any of the excluded words in the output.
Try to inlcude included words in the output when relevant.
Use the relevant information from the product features and intended use in the output.
Do not hallucinate any information about the product, use only the provided key features and intended use to write about the product.
Note that the reference structure should be used for structure only, do not use any part of the reference structure in the output.
Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
Use creative language in each output, do not use the common ways of starting product descriptions.
Avoid common phrases and cliches such as "Step into something", "Elevate something", "Discover something", "Unleash something", "Embrace something", and similar phrases.
For each version, try to write in different style.
Put each item in the list on a separate line. Use '-' character to start each item.
Rate the quality of each version based on the following criteria:
- how faithful it describes the product features.
- how well it follows the reference structure.
- how well it avoid the excluded words.
- how well it includes the included words.
- how creative the language is.
The score should be a number between 0 and 10 with 10 being the best quality.
Return the result in the following JSON format:
{{
"versions": [
{{
"id": 1,
"content": The first product description,
"explanation": A less than 20 word explanation of the score of the first product description,
"score": The score of the first product description
}},
{{
"id": 2,
"content": The second product description,
"explanation": A less than 20 word explanation of the score of the first product description,
"score": The score of the second product description
}},
...
],
"best_version": {{
"explanation": Explanation for why this version is the best,
"id": The id of the best version
}}
}}
Make sure that the output is in JSON format, no extra text should be included in the output.
<product_information>
<key_features>
{key_features}
</key_features>
<reference_structure>
{structure}
</reference_structure>
<included_phrases>
{included_phrases}
</included_phrases>
<excluded_phrases>
{excluded_phrases}
</excluded_phrases>
</product_information>"""
evaluation_prompt = """You will be given information of a product and a list of product descriptions.
Evaluate the quality of the product descriptions based on the following criteria:
- how faithful it describes the product features.
- how well it follows the reference structure.
- how well it follows the tone of voice, rythm, cadence and style of the reference copy.
- how well it avoid the excluded words.
- how well it includes the included words.
- how creative the language is.
Give a score between 0 and 10 for each product description based on the above criteria.
Return the result in the following JSON format:
{{
"versions": [
{{
"id": 1,
"content": The first product description,
"explanation": A less than 20 word explanation of the score of the first product description,
"score": The score of the first product description
}},
{{
"id": 2,
"content": The second product description,
"explanation": A less than 20 word explanation of the score of the first product description,
"score": The score of the second product description
}},
...
],
"best_version": {{
"explanation": Explanation for why this version is the best,
"id": The id of the best version
}}
}}
Make sure that the output is in JSON format, no extra text should be included in the output.
<product_information>
<key_features>
{key_features}
</key_features>
<reference_structure>
{structure}
</reference_structure>
<reference_copy>
{copy}
</reference_copy>
<included_phrases>
{included_phrases}
</included_phrases>
<excluded_phrases>
{excluded_phrases}
</excluded_phrases>
</product_information>
<product_descriptions>
{product_descriptions}
</product_descriptions>"""
improve_structure_prompt = """You are given a structure for a product description.
Reformat the structure so that it is easier to read and understand for human and AI.
Return the reformatted structure only. Do not add any preceding or trailing characters.
<structure>/n{structure}</structure>"""
reasoning_prompt = """You are given information of a product, a reference structure, and a reference copy.
Please analyze the structure, make a plan on how to follow the structure correctly.
Use the tone of voice of the reference copy if available for the generated description.
Do not hallucinate, do not add information that is not in the product information.
Try your best to avoid using the excluded words and phrases.
Try your best to include the included words and phrases in the product description.
Make sure to keep to the requirements of the structure, writing no more or less than specified.
If the structure does not specify a length, write a description that is between {min_length} and {max_length} words.
Do not enclose the output in html tags, quotes, braces, brackets or anything.
Put each item in the list on a separate line. Always use '-' character to start each item in a list.
Return the product description only.
<product_information>
{key_features}
</product_information>
<reference_structure>
{structure}
</reference_structure>
<reference_copy>
{copy}
</reference_copy>
<excluded_phrases>
{excluded_phrases}
</excluded_phrases>
<included_phrases>
{included_phrases}
</included_phrases>"""
import codecs
if __name__ == "__main__":
print("struct_copy_prompt\n", str2escaped(struct_copy_prompt))
print()
print("copy_prompt\n", str2escaped(copy_prompt))
print()
print("struct_prompt\n", str2escaped(struct_prompt))
print()
print("reasoning_prompt\n", str2escaped(reasoning_prompt))
# print()
# print('"write_struct_copy": "' + str2escaped(both).strip() + '",')
# print()
# print('"write_copy": "' + str2escaped(copy).strip() + '",')
# print()
# print('"write_struct": "' + str2escaped(struct).strip() + '",')
# print()
# print('test\n', str2escaped(test))
# print(str2escaped(text))
# print('------------------------------')
# print(test_prompt)
# print('test')
# print(codecs.getdecoder("unicode_escape")(str2escaped(both))[0])
# print("Generate {nversions} versions of the product description for a product with the following information.\nWrite in a way that target the customer.\nFor each version, write at least {min_length} words and at most {max_length} words.\nMake sure that the structure of each output follows the reference structure.\nUse markdown format for each output.\nDo not include any part of the reference structure in the output.\nDo not use any of the excluded words in the output.\nInclude all included words in the output.\nDo not hallucinate any information.\nUse creative language in each output, do not use the common ways of starting a description.\nRate the quality of each version based on the following criteria:\n - how well it follows the reference tone of voice, rythm, cadence and style.\n - how well it follows the reference structure.\n - how faithful it describes the product features.\n - how well it avoid the excluded words.\n - how well it includes the included words.\n - how creative the language is.\nThe score should be a number between 0 and 10 with 10 being the best quality.\nReturn the result in the following JSON format:\n{{\n \"versions\": [\n {{\n \"id\": 1,\n \"content\": The first product description,\n \"explanation\": A less than 20 word explanation of the score of the first product description,\n \"score\": The score of the first product description\n }},\n {{\n \"id\": 2,\n \"content\": The second product description,\n \"explanation\": A less than 20 word explanation of the score of the first product description,\n \"score\": The score of the second product description\n }},\n ...\n ],\n \"best_version\": {{\n \"id\": The id of the best version,\n \"explanation\": Explanation for why this version is the best\n }}\n}}\nMake sure that the output is in JSON format, no extra text should be included in the output.\n\nProduct information:\nKey features: {key_features}\n\nReference structure: {structure}\n\nIncluded words: {included_phrases}\n\nExcluded words: {excluded_phrases}") |