Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -492,14 +492,42 @@ def generate_personalized_sms_wrapper(selected_product, description, product_nam
|
|
492 |
save_user_request_to_github(selected_product, description, product_name, benefits, key_message, chosen_approach, personalization_params)
|
493 |
return sms_1, sms_2, final_prompt_1, final_prompt_2
|
494 |
|
495 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
if not final_prompt_1.strip() or not final_prompt_2.strip():
|
497 |
gr.Warning("Нечего перегенерировать, сначала создайте SMS.")
|
498 |
return "", ""
|
|
|
499 |
print("Regen Final Prompt 1:", final_prompt_1)
|
500 |
print("Regen Final Prompt 2:", final_prompt_2)
|
|
|
501 |
sms_1 = generate_message_with_retry(final_prompt_1, product_name)
|
502 |
sms_2 = generate_message_with_retry(final_prompt_2, product_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
return sms_1, sms_2
|
504 |
|
505 |
def on_load_previous():
|
@@ -747,8 +775,30 @@ with gr.Blocks(theme="default") as demo:
|
|
747 |
)
|
748 |
|
749 |
regen_btn.click(
|
750 |
-
fn=
|
751 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
outputs=[sms_1, sms_2]
|
753 |
)
|
754 |
|
|
|
492 |
save_user_request_to_github(selected_product, description, product_name, benefits, key_message, chosen_approach, personalization_params)
|
493 |
return sms_1, sms_2, final_prompt_1, final_prompt_2
|
494 |
|
495 |
+
def on_regenerate(
|
496 |
+
selected_product, description, product_name, benefits, key_message,
|
497 |
+
gender, generation, psychotype, business_stage, industry, opf,
|
498 |
+
chosen_approach, presence_in_db,
|
499 |
+
model_1_name, prompt_1, final_prompt_1, sms_1,
|
500 |
+
model_2_name, prompt_2, final_prompt_2, sms_2
|
501 |
+
):
|
502 |
+
"""
|
503 |
+
Функция для кнопки «Перегенерировать SMS (не нравится ни одно из SMS)».
|
504 |
+
1) Перегенерирует sms_1, sms_2 с помощью final_prompt_1, final_prompt_2 и product_name.
|
505 |
+
2) Сохраняет все те же данные, что и on_prefer_sms_1/2, но с chosen_sms="none".
|
506 |
+
3) Возвращает новые sms_1, sms_2 для обновления интерфейса.
|
507 |
+
"""
|
508 |
+
|
509 |
+
# Перегенерируем SMS (аналогично regen_sms)
|
510 |
if not final_prompt_1.strip() or not final_prompt_2.strip():
|
511 |
gr.Warning("Нечего перегенерировать, сначала создайте SMS.")
|
512 |
return "", ""
|
513 |
+
|
514 |
print("Regen Final Prompt 1:", final_prompt_1)
|
515 |
print("Regen Final Prompt 2:", final_prompt_2)
|
516 |
+
|
517 |
sms_1 = generate_message_with_retry(final_prompt_1, product_name)
|
518 |
sms_2 = generate_message_with_retry(final_prompt_2, product_name)
|
519 |
+
|
520 |
+
# Теперь сохраняем всё, как при «Я предпочитаю это SMS»,
|
521 |
+
# только chosen_sms="none"
|
522 |
+
save_preferred_sms_to_github(
|
523 |
+
selected_product, description, product_name, benefits, key_message,
|
524 |
+
gender, generation, psychotype, business_stage, industry, opf,
|
525 |
+
chosen_approach, presence_in_db,
|
526 |
+
model_1_name, prompt_1, final_prompt_1, new_sms_1,
|
527 |
+
model_2_name, prompt_2, final_prompt_2, new_sms_2,
|
528 |
+
chosen_sms="none" # <-- признак, что ни одно SMS не выбрано
|
529 |
+
)
|
530 |
+
|
531 |
return sms_1, sms_2
|
532 |
|
533 |
def on_load_previous():
|
|
|
775 |
)
|
776 |
|
777 |
regen_btn.click(
|
778 |
+
fn=on_regenerate,
|
779 |
+
inputs=[
|
780 |
+
product_dropdown,
|
781 |
+
description,
|
782 |
+
product_name,
|
783 |
+
benefits,
|
784 |
+
key_message,
|
785 |
+
gender_dropdown,
|
786 |
+
generation_dropdown,
|
787 |
+
psychotype_dropdown,
|
788 |
+
business_stage_dropdown,
|
789 |
+
industry_dropdown,
|
790 |
+
opf_dropdown,
|
791 |
+
chosen_approach,
|
792 |
+
presence_in_db,
|
793 |
+
model_1_name,
|
794 |
+
prompt_1,
|
795 |
+
final_prompt_1_state,
|
796 |
+
sms_1,
|
797 |
+
model_2_name,
|
798 |
+
prompt_2,
|
799 |
+
final_prompt_2_state,
|
800 |
+
sms_2
|
801 |
+
],
|
802 |
outputs=[sms_1, sms_2]
|
803 |
)
|
804 |
|