Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -248,7 +248,7 @@ def save_user_request_to_github(selected_product, description, product_name, ben
|
|
248 |
"message": f"Добавлен новый файл {path}",
|
249 |
"content": file_content_encoded
|
250 |
}
|
251 |
-
|
252 |
|
253 |
def load_previous_user_request_from_github():
|
254 |
global current_request_index
|
@@ -287,12 +287,20 @@ def load_previous_user_request_from_github():
|
|
287 |
return products[0], "", "", "", "", "", None, None, None, None, None, "", "", "", "", "", ""
|
288 |
|
289 |
def generate_final_prompt_from_display(prompt_text, single_approach, is_prompt_1=True):
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
293 |
prompt_text = prompt_text.replace(" / ", " ")
|
294 |
-
|
295 |
-
|
|
|
|
|
|
|
296 |
return prompt_text
|
297 |
|
298 |
final_prompt_1_state = gr.State("")
|
@@ -469,7 +477,7 @@ with gr.Blocks(theme="default") as demo:
|
|
469 |
)
|
470 |
|
471 |
create_personal_sms_btn.click(
|
472 |
-
fn=
|
473 |
inputs=[product_dropdown, description, product_name, benefits, key_message,
|
474 |
gender_dropdown, generation_dropdown, psychotype_dropdown,
|
475 |
business_stage_dropdown, industry_dropdown, opf_dropdown,
|
|
|
248 |
"message": f"Добавлен новый файл {path}",
|
249 |
"content": file_content_encoded
|
250 |
}
|
251 |
+
requests.put(url, headers=headers, data=json.dumps(data))
|
252 |
|
253 |
def load_previous_user_request_from_github():
|
254 |
global current_request_index
|
|
|
287 |
return products[0], "", "", "", "", "", None, None, None, None, None, "", "", "", "", "", ""
|
288 |
|
289 |
def generate_final_prompt_from_display(prompt_text, single_approach, is_prompt_1=True):
|
290 |
+
chosen_prefix = approach_dict[single_approach]["prefix"]
|
291 |
+
chosen_suffix = approach_dict[single_approach]["suffix"]
|
292 |
+
for approach in approach_dict:
|
293 |
+
if approach != single_approach:
|
294 |
+
other_prefix = approach_dict[approach]["prefix"]
|
295 |
+
other_suffix = approach_dict[approach]["suffix"]
|
296 |
+
prompt_text = prompt_text.replace(other_prefix, "")
|
297 |
+
prompt_text = prompt_text.replace(other_suffix, "")
|
298 |
prompt_text = prompt_text.replace(" / ", " ")
|
299 |
+
if chosen_prefix not in prompt_text:
|
300 |
+
prompt_text = re.sub(r"с учетом пробелов\. [^.\n]*\.", f"с учетом пробелов. {chosen_prefix}.", prompt_text)
|
301 |
+
if chosen_suffix not in prompt_text:
|
302 |
+
prompt_text = re.sub(r"\n[^\n]*Убедись, что УМЕСТНО использовал КАЖДЫЙ необходимый термин.\n[^\n]*Убедись, что в SMS без.*\n[^\n]*Убедись, что в SMS есть следующая ключевая информация:",
|
303 |
+
f"\n{chosen_suffix}.\nУбедись, что УМЕСТНО использовал КАЖДЫЙ необходимый термин.\nУбедись, что в SMS без изменений, синонимов и перестановок слов используется наименование продукта:\nУбедись, что в SMS есть следующая ключевая информация:", prompt_text, flags=re.DOTALL)
|
304 |
return prompt_text
|
305 |
|
306 |
final_prompt_1_state = gr.State("")
|
|
|
477 |
)
|
478 |
|
479 |
create_personal_sms_btn.click(
|
480 |
+
fn=generate_personal_sms_wrapper,
|
481 |
inputs=[product_dropdown, description, product_name, benefits, key_message,
|
482 |
gender_dropdown, generation_dropdown, psychotype_dropdown,
|
483 |
business_stage_dropdown, industry_dropdown, opf_dropdown,
|