Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -249,10 +249,6 @@ def save_user_request_to_github(selected_product, description, product_name, ben
|
|
249 |
"content": file_content_encoded
|
250 |
}
|
251 |
response = requests.put(url, headers=headers, data=json.dumps(data))
|
252 |
-
if response.status_code == 201:
|
253 |
-
print("Данные успешно сохранены на GitHub")
|
254 |
-
else:
|
255 |
-
print(f"Ошибка при сохранении данных на GitHub: {response.status_code} {response.text}")
|
256 |
|
257 |
def load_previous_user_request_from_github():
|
258 |
global current_request_index
|
@@ -266,7 +262,6 @@ def load_previous_user_request_from_github():
|
|
266 |
files = response.json()
|
267 |
json_files = [file for file in files if file['name'].startswith("user_request_")]
|
268 |
if not json_files:
|
269 |
-
print("Нет сохраненных запросов.")
|
270 |
return products[0], "", "", "", "", "", None, None, None, None, None, "", "", "", "", "", ""
|
271 |
current_request_index -= 1
|
272 |
if abs(current_request_index) > len(json_files):
|
@@ -287,10 +282,8 @@ def load_previous_user_request_from_github():
|
|
287 |
personalization_params += [None]*(6-len(personalization_params))
|
288 |
return (selected_product, description, product_name, benefits, key_message, approach, *personalization_params)
|
289 |
else:
|
290 |
-
print(f"Ошибка при загрузке файла: {file_response.status_code}")
|
291 |
return products[0], "", "", "", "", "", None, None, None, None, None, "", "", "", "", "", ""
|
292 |
else:
|
293 |
-
print(f"Ошибка при обращении к GitHub: {response.status_code}")
|
294 |
return products[0], "", "", "", "", "", None, None, None, None, None, "", "", "", "", "", ""
|
295 |
|
296 |
def generate_final_prompt_from_display(prompt_text, single_approach, is_prompt_1=True):
|
@@ -309,11 +302,11 @@ def generate_personalized_sms_wrapper(selected_product, description, product_nam
|
|
309 |
gender, generation, psychotype, business_stage, industry, opf,
|
310 |
chosen_approach, prompt_1, prompt_2):
|
311 |
if "Для формирования промпта выберите хотя бы один личный персональный параметр" in prompt_1 or chosen_approach == "Подход не найден для выбранных параметров.":
|
312 |
-
gr.Warning("Задайте хотя бы один личный персональный параметр для определения
|
313 |
return "", "", "", ""
|
314 |
approach_list = [a.strip() for a in chosen_approach.split(',') if a.strip()]
|
315 |
if not approach_list:
|
316 |
-
gr.Warning("Задайте хотя бы один личный персональный параметр для определения
|
317 |
return "", "", "", ""
|
318 |
chosen_single_approach_1 = random.choice(approach_list) if len(approach_list) > 1 else approach_list[0]
|
319 |
chosen_single_approach_2 = random.choice(approach_list) if len(approach_list) > 1 else approach_list[0]
|
|
|
249 |
"content": file_content_encoded
|
250 |
}
|
251 |
response = requests.put(url, headers=headers, data=json.dumps(data))
|
|
|
|
|
|
|
|
|
252 |
|
253 |
def load_previous_user_request_from_github():
|
254 |
global current_request_index
|
|
|
262 |
files = response.json()
|
263 |
json_files = [file for file in files if file['name'].startswith("user_request_")]
|
264 |
if not json_files:
|
|
|
265 |
return products[0], "", "", "", "", "", None, None, None, None, None, "", "", "", "", "", ""
|
266 |
current_request_index -= 1
|
267 |
if abs(current_request_index) > len(json_files):
|
|
|
282 |
personalization_params += [None]*(6-len(personalization_params))
|
283 |
return (selected_product, description, product_name, benefits, key_message, approach, *personalization_params)
|
284 |
else:
|
|
|
285 |
return products[0], "", "", "", "", "", None, None, None, None, None, "", "", "", "", "", ""
|
286 |
else:
|
|
|
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):
|
|
|
302 |
gender, generation, psychotype, business_stage, industry, opf,
|
303 |
chosen_approach, prompt_1, prompt_2):
|
304 |
if "Для формирования промпта выберите хотя бы один личный персональный параметр" in prompt_1 or chosen_approach == "Подход не найден для выбранных параметров.":
|
305 |
+
gr.Warning("Задайте хотя бы один личный персональный параметр для определения подхода")
|
306 |
return "", "", "", ""
|
307 |
approach_list = [a.strip() for a in chosen_approach.split(',') if a.strip()]
|
308 |
if not approach_list:
|
309 |
+
gr.Warning("Задайте хотя бы один личный персональный параметр для определения подхода")
|
310 |
return "", "", "", ""
|
311 |
chosen_single_approach_1 = random.choice(approach_list) if len(approach_list) > 1 else approach_list[0]
|
312 |
chosen_single_approach_2 = random.choice(approach_list) if len(approach_list) > 1 else approach_list[0]
|