fruitpicker01 commited on
Commit
b0abcf4
·
verified ·
1 Parent(s): 2254ef8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -244,8 +244,21 @@ def clean_message(message):
244
  return message
245
 
246
  def generate_message_with_retry(model_prompt):
247
- # опущено из-за длины, вставьте ваш код
248
- return "..."
 
 
 
 
 
 
 
 
 
 
 
 
 
249
 
250
  def update_prompts_on_params_change(description, product_name, benefits, key_message,
251
  gender, generation, psychotype, business_stage, industry, opf):
 
244
  return message
245
 
246
  def generate_message_with_retry(model_prompt):
247
+ last_message = ""
248
+ for _ in range(10):
249
+ msg = call_model(model_prompt)
250
+ msg = correct_dash_usage(msg)
251
+ msg = clean_message(msg)
252
+ length = len(msg)
253
+ if 160 <= length <= 250:
254
+ # Добавляем информацию о количестве знаков
255
+ msg += f"\n\n------\nКоличество знаков: {length}"
256
+ return msg
257
+ last_message = msg
258
+ # Если не удалось подобрать длину
259
+ length = len(last_message)
260
+ last_message += f"\n\n------\nКоличество знаков: {length}"
261
+ return last_message
262
 
263
  def update_prompts_on_params_change(description, product_name, benefits, key_message,
264
  gender, generation, psychotype, business_stage, industry, opf):