Spaces:
Paused
Paused
Add '-' to list prompt
Browse files- app.py +1 -0
- str2escaped.py +132 -49
app.py
CHANGED
|
@@ -398,6 +398,7 @@ Try your best to include the included words and phrases in the product descripti
|
|
| 398 |
Make sure to keep to the requirements of the structure, writing no more or less than specified.
|
| 399 |
If the structure does not specify a length, write a description that is between {min_length} and {max_length} words.
|
| 400 |
Do not enclose the output in html tags, quotes, braces, brackets or anything.
|
|
|
|
| 401 |
Return the product description only.
|
| 402 |
|
| 403 |
<product_information>
|
|
|
|
| 398 |
Make sure to keep to the requirements of the structure, writing no more or less than specified.
|
| 399 |
If the structure does not specify a length, write a description that is between {min_length} and {max_length} words.
|
| 400 |
Do not enclose the output in html tags, quotes, braces, brackets or anything.
|
| 401 |
+
Put each item in the list on a separate line. Use '-' character to start each item.
|
| 402 |
Return the product description only.
|
| 403 |
|
| 404 |
<product_information>
|
str2escaped.py
CHANGED
|
@@ -6,7 +6,7 @@ def str2escaped(input_str: str, remove_spaces: bool = True) -> str:
|
|
| 6 |
return "\\n".join(lines)
|
| 7 |
|
| 8 |
|
| 9 |
-
|
| 10 |
Write in a way that target the customer.
|
| 11 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 12 |
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.
|
|
@@ -16,8 +16,8 @@ Do not include any part of the reference structure in the output.
|
|
| 16 |
The structure of the output should follow the reference structure.
|
| 17 |
Do not use the structure of the reference copy in the output.
|
| 18 |
Do not use any of the excluded words in the output.
|
| 19 |
-
|
| 20 |
-
|
| 21 |
Do not hallucinate any information about the product, use only the provided key features and intended use to write about the product.
|
| 22 |
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.
|
| 23 |
Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
|
|
@@ -57,21 +57,30 @@ Return the result in the following JSON format:
|
|
| 57 |
}}
|
| 58 |
Make sure that the output is in JSON format, no extra text should be included in the output.
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
|
|
|
|
|
|
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
-
|
| 75 |
Write in a way that target the customer.
|
| 76 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 77 |
Make sure that the structure of each output follows the structure of the reference copy.
|
|
@@ -79,8 +88,8 @@ Make sure to use the tone of voice, rythm, cadence and style of the reference co
|
|
| 79 |
Use markdown format for each output.
|
| 80 |
Make sure that the structure of each output follows the structure of the reference copy.
|
| 81 |
Do not use any of the excluded words in the output.
|
| 82 |
-
|
| 83 |
-
|
| 84 |
Do not hallucinate any information about the product, use only the provided key features and intended use to write about the product.
|
| 85 |
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.
|
| 86 |
Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
|
|
@@ -119,19 +128,26 @@ Return the result in the following JSON format:
|
|
| 119 |
}}
|
| 120 |
Make sure that the output is in JSON format, no extra text should be included in the output.
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
|
| 127 |
-
|
|
|
|
|
|
|
| 128 |
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
|
| 134 |
-
|
| 135 |
Write in a way that target the customer.
|
| 136 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 137 |
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.
|
|
@@ -139,8 +155,8 @@ Use markdown format for each output.
|
|
| 139 |
Do not include any part of the reference structure in the output.
|
| 140 |
Make sure that the structure of each output follows the reference structure.
|
| 141 |
Do not use any of the excluded words in the output.
|
| 142 |
-
|
| 143 |
-
|
| 144 |
Do not hallucinate any information about the product, use only the provided key features and intended use to write about the product.
|
| 145 |
Note that the reference structure should be used for structure only, do not use any part of the reference structure in the output.
|
| 146 |
Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
|
|
@@ -179,39 +195,99 @@ Return the result in the following JSON format:
|
|
| 179 |
}}
|
| 180 |
Make sure that the output is in JSON format, no extra text should be included in the output.
|
| 181 |
|
| 182 |
-
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
|
|
|
|
|
|
|
| 188 |
|
| 189 |
-
|
|
|
|
|
|
|
| 190 |
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
-
test_prompt = "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. Do not add any additional sentences or structures that are not in the reference structure.\nMake sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.\nUse markdown format for each output.\nDo not include any part of the reference structure in the output.\nThe structure of the output should follow the reference structure.\nDo not use the structure of the reference copy 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. Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.\nUse creative language in each output, do not use the common ways of starting product descriptions.\nAvoid common phrases and cliches such as \"Step into something\", \"Elevate something\", \"Discover something\", \"Unleash something\", \"Embrace something\", and similar phrases.\nFor each version, try to write in different style.\nPut each item in the list on a separate line. Use '-' character to start each item. \nRate the quality of each version based on the following criteria:\n - how well it follows the reference structure.\n - how well it follows the tone of voice, rythm, cadence and style of the reference copy.\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 \"explanation\": Explanation for why this version is the best,\n \"id\": The id of the best version\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\nReference copy: {copy}\n\nIncluded words: {included_phrases}\n\nExcluded words: {excluded_phrases}"
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
|
|
|
| 198 |
|
| 199 |
-
{
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
gemini_prompt = """You are given information of a product, a reference structure, and a reference copy.
|
| 208 |
-
Please analyze the structure, make a plan on how to follow the structure correctly, and write a product
|
| 209 |
-
description for the product. Use the tone of voice of the reference copy for the generated description.
|
| 210 |
-
Write from {min_length} to {max_length} words.
|
| 211 |
-
Do not hallucinate, do not add information that is not in the product information.
|
| 212 |
Try your best to avoid using the excluded words and phrases.
|
| 213 |
-
Try your best to include the included words and phrases.
|
| 214 |
-
|
|
|
|
|
|
|
| 215 |
Return the product description only.
|
| 216 |
|
| 217 |
<product_information>
|
|
@@ -234,9 +310,16 @@ Return the product description only.
|
|
| 234 |
{included_phrases}
|
| 235 |
</included_phrases>"""
|
| 236 |
|
|
|
|
| 237 |
import codecs
|
| 238 |
if __name__ == "__main__":
|
| 239 |
-
print(str2escaped(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
# print()
|
| 241 |
# print('"write_struct_copy": "' + str2escaped(both).strip() + '",')
|
| 242 |
# print()
|
|
|
|
| 6 |
return "\\n".join(lines)
|
| 7 |
|
| 8 |
|
| 9 |
+
struct_copy_prompt = """Generate {nversions} versions of the product description for a product with the following information.
|
| 10 |
Write in a way that target the customer.
|
| 11 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 12 |
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.
|
|
|
|
| 16 |
The structure of the output should follow the reference structure.
|
| 17 |
Do not use the structure of the reference copy in the output.
|
| 18 |
Do not use any of the excluded words in the output.
|
| 19 |
+
Try to inlcude included words in the output when relevant.
|
| 20 |
+
Use the relevant information from the product features and intended use in the output.
|
| 21 |
Do not hallucinate any information about the product, use only the provided key features and intended use to write about the product.
|
| 22 |
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.
|
| 23 |
Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
|
|
|
|
| 57 |
}}
|
| 58 |
Make sure that the output is in JSON format, no extra text should be included in the output.
|
| 59 |
|
| 60 |
+
<product_information>
|
| 61 |
+
<key_features>
|
| 62 |
+
{key_features}
|
| 63 |
+
</key_features>
|
| 64 |
|
| 65 |
+
<reference_structure>
|
| 66 |
+
{structure}
|
| 67 |
+
</reference_structure>
|
| 68 |
|
| 69 |
+
<reference_copy>
|
| 70 |
+
{copy}
|
| 71 |
+
</reference_copy>
|
| 72 |
|
| 73 |
+
<included_phrases>
|
| 74 |
+
{included_phrases}
|
| 75 |
+
</included_phrases>
|
| 76 |
|
| 77 |
+
<excluded_phrases>
|
| 78 |
+
{excluded_phrases}
|
| 79 |
+
</excluded_phrases>
|
| 80 |
+
</product_information>"""
|
| 81 |
|
| 82 |
|
| 83 |
+
copy_prompt = """Generate {nversions} versions of the product description for a product with the following information.
|
| 84 |
Write in a way that target the customer.
|
| 85 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 86 |
Make sure that the structure of each output follows the structure of the reference copy.
|
|
|
|
| 88 |
Use markdown format for each output.
|
| 89 |
Make sure that the structure of each output follows the structure of the reference copy.
|
| 90 |
Do not use any of the excluded words in the output.
|
| 91 |
+
Try to inlcude included words in the output when relevant.
|
| 92 |
+
Use the relevant information from the product features and intended use in the output.
|
| 93 |
Do not hallucinate any information about the product, use only the provided key features and intended use to write about the product.
|
| 94 |
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.
|
| 95 |
Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
|
|
|
|
| 128 |
}}
|
| 129 |
Make sure that the output is in JSON format, no extra text should be included in the output.
|
| 130 |
|
| 131 |
+
<product_information>
|
| 132 |
+
<key_features>
|
| 133 |
+
{key_features}
|
| 134 |
+
</key_features>
|
| 135 |
|
| 136 |
+
<reference_copy>
|
| 137 |
+
{copy}
|
| 138 |
+
</reference_copy>
|
| 139 |
|
| 140 |
+
<included_phrases>
|
| 141 |
+
{included_phrases}
|
| 142 |
+
</included_phrases>
|
| 143 |
|
| 144 |
+
<excluded_phrases>
|
| 145 |
+
{excluded_phrases}
|
| 146 |
+
</excluded_phrases>
|
| 147 |
+
</product_information>"""
|
| 148 |
|
| 149 |
|
| 150 |
+
struct_prompt = """Generate {nversions} versions of the product description for a product with the following information.
|
| 151 |
Write in a way that target the customer.
|
| 152 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 153 |
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.
|
|
|
|
| 155 |
Do not include any part of the reference structure in the output.
|
| 156 |
Make sure that the structure of each output follows the reference structure.
|
| 157 |
Do not use any of the excluded words in the output.
|
| 158 |
+
Try to inlcude included words in the output when relevant.
|
| 159 |
+
Use the relevant information from the product features and intended use in the output.
|
| 160 |
Do not hallucinate any information about the product, use only the provided key features and intended use to write about the product.
|
| 161 |
Note that the reference structure should be used for structure only, do not use any part of the reference structure in the output.
|
| 162 |
Do not hallucinate information about size and weight. Write about size and weight only if it is available in the list of features.
|
|
|
|
| 195 |
}}
|
| 196 |
Make sure that the output is in JSON format, no extra text should be included in the output.
|
| 197 |
|
| 198 |
+
<product_information>
|
| 199 |
+
<key_features>
|
| 200 |
+
{key_features}
|
| 201 |
+
</key_features>
|
| 202 |
+
|
| 203 |
+
<reference_structure>
|
| 204 |
+
{structure}
|
| 205 |
+
</reference_structure>
|
| 206 |
+
|
| 207 |
+
<included_phrases>
|
| 208 |
+
{included_phrases}
|
| 209 |
+
</included_phrases>
|
| 210 |
+
|
| 211 |
+
<excluded_phrases>
|
| 212 |
+
{excluded_phrases}
|
| 213 |
+
</excluded_phrases>
|
| 214 |
+
</product_information>"""
|
| 215 |
+
|
| 216 |
+
evaluation_prompt = """You will be given information of a product and a list of product descriptions.
|
| 217 |
+
Evaluate the quality of the product descriptions based on the following criteria:
|
| 218 |
+
- how faithful it describes the product features.
|
| 219 |
+
- how well it follows the reference structure.
|
| 220 |
+
- how well it follows the tone of voice, rythm, cadence and style of the reference copy.
|
| 221 |
+
- how well it avoid the excluded words.
|
| 222 |
+
- how well it includes the included words.
|
| 223 |
+
- how creative the language is.
|
| 224 |
+
Give a score between 0 and 10 for each product description based on the above criteria.
|
| 225 |
+
Return the result in the following JSON format:
|
| 226 |
+
{{
|
| 227 |
+
"versions": [
|
| 228 |
+
{{
|
| 229 |
+
"id": 1,
|
| 230 |
+
"content": The first product description,
|
| 231 |
+
"explanation": A less than 20 word explanation of the score of the first product description,
|
| 232 |
+
"score": The score of the first product description
|
| 233 |
+
}},
|
| 234 |
+
{{
|
| 235 |
+
"id": 2,
|
| 236 |
+
"content": The second product description,
|
| 237 |
+
"explanation": A less than 20 word explanation of the score of the first product description,
|
| 238 |
+
"score": The score of the second product description
|
| 239 |
+
}},
|
| 240 |
+
...
|
| 241 |
+
],
|
| 242 |
+
"best_version": {{
|
| 243 |
+
"explanation": Explanation for why this version is the best,
|
| 244 |
+
"id": The id of the best version
|
| 245 |
+
}}
|
| 246 |
+
}}
|
| 247 |
+
Make sure that the output is in JSON format, no extra text should be included in the output.
|
| 248 |
|
| 249 |
+
<product_information>
|
| 250 |
+
<key_features>
|
| 251 |
+
{key_features}
|
| 252 |
+
</key_features>
|
| 253 |
|
| 254 |
+
<reference_structure>
|
| 255 |
+
{structure}
|
| 256 |
+
</reference_structure>
|
| 257 |
|
| 258 |
+
<reference_copy>
|
| 259 |
+
{copy}
|
| 260 |
+
</reference_copy>
|
| 261 |
|
| 262 |
+
<included_phrases>
|
| 263 |
+
{included_phrases}
|
| 264 |
+
</included_phrases>
|
| 265 |
+
|
| 266 |
+
<excluded_phrases>
|
| 267 |
+
{excluded_phrases}
|
| 268 |
+
</excluded_phrases>
|
| 269 |
+
</product_information>
|
| 270 |
|
| 271 |
+
<product_descriptions>
|
| 272 |
+
{product_descriptions}
|
| 273 |
+
</product_descriptions>"""
|
| 274 |
|
|
|
|
| 275 |
|
| 276 |
+
improve_structure_prompt = """You are given a structure for a product description.
|
| 277 |
+
Reformat the structure so that it is easier to read and understand for human and AI.
|
| 278 |
+
Return the reformatted structure only. Do not add any preceding or trailing characters.
|
| 279 |
|
| 280 |
+
<structure>/n{structure}</structure>"""
|
| 281 |
+
|
| 282 |
+
reasoning_prompt = """You are given information of a product, a reference structure, and a reference copy.
|
| 283 |
+
Please analyze the structure, make a plan on how to follow the structure correctly.
|
| 284 |
+
Use the tone of voice of the reference copy if available for the generated description.
|
| 285 |
+
Do not hallucinate, do not add information that is not in the product information.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
Try your best to avoid using the excluded words and phrases.
|
| 287 |
+
Try your best to include the included words and phrases in the product description.
|
| 288 |
+
Make sure to keep to the requirements of the structure, writing no more or less than specified.
|
| 289 |
+
If the structure does not specify a length, write a description that is between {min_length} and {max_length} words.
|
| 290 |
+
Do not enclose the output in html tags, quotes, braces, brackets or anything.
|
| 291 |
Return the product description only.
|
| 292 |
|
| 293 |
<product_information>
|
|
|
|
| 310 |
{included_phrases}
|
| 311 |
</included_phrases>"""
|
| 312 |
|
| 313 |
+
|
| 314 |
import codecs
|
| 315 |
if __name__ == "__main__":
|
| 316 |
+
print("struct_copy_prompt\n", str2escaped(struct_copy_prompt))
|
| 317 |
+
print()
|
| 318 |
+
print("copy_prompt\n", str2escaped(copy_prompt))
|
| 319 |
+
print()
|
| 320 |
+
print("struct_prompt\n", str2escaped(struct_prompt))
|
| 321 |
+
print()
|
| 322 |
+
print("reasoning_prompt\n", str2escaped(reasoning_prompt))
|
| 323 |
# print()
|
| 324 |
# print('"write_struct_copy": "' + str2escaped(both).strip() + '",')
|
| 325 |
# print()
|