Spaces:
Paused
Paused
add number of versions slider
Browse files
app.py
CHANGED
|
@@ -266,8 +266,8 @@ def generate(*data):
|
|
| 266 |
global visible
|
| 267 |
print("visible", visible)
|
| 268 |
|
| 269 |
-
nargs =
|
| 270 |
-
feature, image, garment_type, model, temperature, excluded_words, included_words, glossary_upload, debug = data[:nargs]
|
| 271 |
struct_ref = data[nargs:]
|
| 272 |
|
| 273 |
print(f"{feature=}")
|
|
@@ -323,8 +323,9 @@ def generate(*data):
|
|
| 323 |
print("Using both copy and structure")
|
| 324 |
messages = [
|
| 325 |
SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
|
| 326 |
-
HumanMessage(content=f"""Generate
|
| 327 |
Write in a way that target the customer.
|
|
|
|
| 328 |
Make sure that the structure of each output follows the reference structure.
|
| 329 |
Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
|
| 330 |
Use markdown format for each output.
|
|
@@ -378,8 +379,9 @@ Excluded words: {excluded_words}"""),]
|
|
| 378 |
print("Using copy")
|
| 379 |
messages = [
|
| 380 |
SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
|
| 381 |
-
HumanMessage(content=f"""Generate
|
| 382 |
-
Write in a way that target the customer.
|
|
|
|
| 383 |
Make sure that the structure of each output follows the structure of the reference copy.
|
| 384 |
Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
|
| 385 |
Use markdown format for each output.
|
|
@@ -434,8 +436,9 @@ Excluded words: {excluded_words}"""),]
|
|
| 434 |
print("Using structure")
|
| 435 |
messages = [
|
| 436 |
SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
|
| 437 |
-
HumanMessage(content=f"""Generate
|
| 438 |
-
Write in a way that target the customer.
|
|
|
|
| 439 |
Make sure that the structure of each output follows the reference structure.
|
| 440 |
Use markdown format for each output.
|
| 441 |
Do not include any part of the reference structure in the output.
|
|
@@ -579,6 +582,7 @@ with gr.Blocks() as demo:
|
|
| 579 |
with gr.Accordion(label="Advanced Options", open=False):
|
| 580 |
model = gr.Dropdown(models, value="claude-3-5-sonnet-20240620", interactive=True, label="Model", visible=True)
|
| 581 |
temperature = gr.Slider(minimum=0., maximum=1.0, value=0., interactive=True, label="Temperature", visible=True)
|
|
|
|
| 582 |
excluded_words = gr.Textbox(label="Excluded words", interactive=True, lines=2)
|
| 583 |
included_words = gr.Textbox(label="Included words", interactive=True, lines=2)
|
| 584 |
# glossary = gr.Dataframe(row_count = (2, "dynamic"), col_count=(2,"static"), headers=["Description", "Way of writing"], label="Glossary", interactive=True)
|
|
@@ -603,7 +607,7 @@ with gr.Blocks() as demo:
|
|
| 603 |
with gr.Column():
|
| 604 |
md_output = gr.Markdown(label="Output", show_label=True)
|
| 605 |
json_output = gr.JSON(label="JSON Output")
|
| 606 |
-
submit.click(generate, inputs=[feature, image, garment_type, model, temperature,
|
| 607 |
excluded_words, included_words, glossary_upload, debug, *struct_ref],
|
| 608 |
outputs=[md_output, json_output])
|
| 609 |
# advanced.click(show_advanced, inputs=[], outputs=[model, temperature])
|
|
|
|
| 266 |
global visible
|
| 267 |
print("visible", visible)
|
| 268 |
|
| 269 |
+
nargs = 10
|
| 270 |
+
feature, image, garment_type, model, temperature, nversions, excluded_words, included_words, glossary_upload, debug = data[:nargs]
|
| 271 |
struct_ref = data[nargs:]
|
| 272 |
|
| 273 |
print(f"{feature=}")
|
|
|
|
| 323 |
print("Using both copy and structure")
|
| 324 |
messages = [
|
| 325 |
SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
|
| 326 |
+
HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
|
| 327 |
Write in a way that target the customer.
|
| 328 |
+
Use feedbacks from the previous versions to improve the quality of the next versions.
|
| 329 |
Make sure that the structure of each output follows the reference structure.
|
| 330 |
Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
|
| 331 |
Use markdown format for each output.
|
|
|
|
| 379 |
print("Using copy")
|
| 380 |
messages = [
|
| 381 |
SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
|
| 382 |
+
HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
|
| 383 |
+
Write in a way that target the customer.
|
| 384 |
+
Use feedbacks from the previous versions to improve the quality of the next versions.
|
| 385 |
Make sure that the structure of each output follows the structure of the reference copy.
|
| 386 |
Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
|
| 387 |
Use markdown format for each output.
|
|
|
|
| 436 |
print("Using structure")
|
| 437 |
messages = [
|
| 438 |
SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites. Make sure to write in {languages[i]} language."""),
|
| 439 |
+
HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
|
| 440 |
+
Write in a way that target the customer.
|
| 441 |
+
Use feedbacks from the previous versions to improve the quality of the next versions.
|
| 442 |
Make sure that the structure of each output follows the reference structure.
|
| 443 |
Use markdown format for each output.
|
| 444 |
Do not include any part of the reference structure in the output.
|
|
|
|
| 582 |
with gr.Accordion(label="Advanced Options", open=False):
|
| 583 |
model = gr.Dropdown(models, value="claude-3-5-sonnet-20240620", interactive=True, label="Model", visible=True)
|
| 584 |
temperature = gr.Slider(minimum=0., maximum=1.0, value=0., interactive=True, label="Temperature", visible=True)
|
| 585 |
+
nversions = gr.Slider(minimum=1, maximum=10, value=1, step=int, interactive=True, label="Number of versions", visible=True)
|
| 586 |
excluded_words = gr.Textbox(label="Excluded words", interactive=True, lines=2)
|
| 587 |
included_words = gr.Textbox(label="Included words", interactive=True, lines=2)
|
| 588 |
# glossary = gr.Dataframe(row_count = (2, "dynamic"), col_count=(2,"static"), headers=["Description", "Way of writing"], label="Glossary", interactive=True)
|
|
|
|
| 607 |
with gr.Column():
|
| 608 |
md_output = gr.Markdown(label="Output", show_label=True)
|
| 609 |
json_output = gr.JSON(label="JSON Output")
|
| 610 |
+
submit.click(generate, inputs=[feature, image, garment_type, model, temperature, nversions,
|
| 611 |
excluded_words, included_words, glossary_upload, debug, *struct_ref],
|
| 612 |
outputs=[md_output, json_output])
|
| 613 |
# advanced.click(show_advanced, inputs=[], outputs=[model, temperature])
|