fruitpicker01 commited on
Commit
745c4d4
·
verified ·
1 Parent(s): 1fb86d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -188,8 +188,6 @@ def personalize_messages_with_yield(gpt4o_message, gigachat_pro_message, gigacha
188
  personalized_message_gigachat_plus = perform_personalization_gigachat(gigachat_plus_message, personalization_prompt, "gigachat_plus")
189
  yield personalization_prompt, personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, personalized_message_gigachat_plus, "Все персонализированные сообщения сгенерированы"
190
 
191
- return personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, personalized_message_gigachat_plus
192
-
193
  # Функция для генерации промпта проверки текста
194
  def generate_error_check_prompt():
195
  prompt = (
@@ -236,27 +234,27 @@ def generate_error_check_prompt():
236
 
237
 
238
  # Функция для выполнения проверки текста с использованием yield
239
- def check_errors_with_yield(gpt4o_message, gigachat_pro_message, gigachat_lite_message, gigachat_plus_message):
240
- if len([gpt4o_message, gigachat_pro_message, gigachat_lite_message, gigachat_plus_message]) < 4:
241
  yield "", "", "", "", "", "Ошибка: недостаточно сообщений для проверки"
242
  return
243
 
244
  error_check_prompt = generate_error_check_prompt()
245
  yield error_check_prompt, "", "", "", "", "Промпт для проверки текста сгенерирован"
246
 
247
- error_message_gpt4o = perform_personalization(f"{error_check_prompt}\n\n{gpt4o_message}", "")
248
  yield error_check_prompt, error_message_gpt4o, "", "", "", "Результат проверки GPT-4o сгенерирован"
249
 
250
- error_message_gigachat_pro = perform_personalization_gigachat(f"{error_check_prompt}\n\n{gigachat_pro_message}", "", "gigachat_pro")
251
  yield error_check_prompt, error_message_gpt4o, error_message_gigachat_pro, "", "", "Результат проверки GigaChat-Pro сгенерирован"
252
 
253
  time.sleep(3)
254
- error_message_gigachat_lite = perform_personalization_gigachat(f"{error_check_prompt}\n\n{gigachat_lite_message}", "", "gigachat_lite")
255
  yield error_check_prompt, error_message_gpt4o, error_message_gigachat_pro, error_message_gigachat_lite, "", "Результат проверки GigaChat-Lite сгенерирован"
256
 
257
  try:
258
  time.sleep(3)
259
- error_message_gigachat_plus = perform_personalization_gigachat(f"{error_check_prompt}\n\n{gigachat_plus_message}", "", "gigachat_plus")
260
  except Exception as e:
261
  error_message_gigachat_plus = f"Ошибка при обработке GigaChat-Plus: {e}"
262
 
@@ -323,10 +321,10 @@ with gr.Blocks() as demo:
323
  inputs=[output_text_gpt4o, output_text_gigachat_pro, output_text_gigachat_lite, output_text_gigachat_plus] + selections,
324
  outputs=[
325
  gr.Textbox(label="Промпт для персонализации", lines=6, interactive=False),
326
- gr.State(value=""), # To store personalized message for GPT-4o
327
- gr.State(value=""), # To store personalized message for GigaChat-Pro
328
- gr.State(value=""), # To store personalized message for GigaChat-Lite
329
- gr.State(value=""), # To store personalized message for GigaChat-Lite+
330
  status_display
331
  ]
332
  )
@@ -338,7 +336,7 @@ with gr.Blocks() as demo:
338
  with gr.Row():
339
  check_errors_btn.click(
340
  check_errors_with_yield,
341
- inputs=[personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, personalized_message_gigachat_plus],
342
  outputs=[
343
  gr.Textbox(label="Промпт для проверки текста", lines=6, interactive=False),
344
  gr.Textbox(label="Результат проверки GPT-4o", lines=6),
@@ -349,5 +347,4 @@ with gr.Blocks() as demo:
349
  ]
350
  )
351
 
352
-
353
  demo.launch()
 
188
  personalized_message_gigachat_plus = perform_personalization_gigachat(gigachat_plus_message, personalization_prompt, "gigachat_plus")
189
  yield personalization_prompt, personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, personalized_message_gigachat_plus, "Все персонализированные сообщения сгенерированы"
190
 
 
 
191
  # Функция для генерации промпта проверки текста
192
  def generate_error_check_prompt():
193
  prompt = (
 
234
 
235
 
236
  # Функция для выполнения проверки текста с использованием yield
237
+ def check_errors_with_yield(*personalized_messages):
238
+ if len(personalized_messages) < 4:
239
  yield "", "", "", "", "", "Ошибка: недостаточно сообщений для проверки"
240
  return
241
 
242
  error_check_prompt = generate_error_check_prompt()
243
  yield error_check_prompt, "", "", "", "", "Промпт для проверки текста сгенерирован"
244
 
245
+ error_message_gpt4o = perform_personalization(f"{error_check_prompt}\n\n{personalized_messages[0]}", "")
246
  yield error_check_prompt, error_message_gpt4o, "", "", "", "Результат проверки GPT-4o сгенерирован"
247
 
248
+ error_message_gigachat_pro = perform_personalization_gigachat(f"{error_check_prompt}\n\n{personalized_messages[1]}", "", "gigachat_pro")
249
  yield error_check_prompt, error_message_gpt4o, error_message_gigachat_pro, "", "", "Результат проверки GigaChat-Pro сгенерирован"
250
 
251
  time.sleep(3)
252
+ error_message_gigachat_lite = perform_personalization_gigachat(f"{error_check_prompt}\n\n{personalized_messages[2]}", "", "gigachat_lite")
253
  yield error_check_prompt, error_message_gpt4o, error_message_gigachat_pro, error_message_gigachat_lite, "", "Результат проверки GigaChat-Lite сгенерирован"
254
 
255
  try:
256
  time.sleep(3)
257
+ error_message_gigachat_plus = perform_personalization_gigachat(f"{error_check_prompt}\n\n{personalized_messages[3]}", "", "gigachat_plus")
258
  except Exception as e:
259
  error_message_gigachat_plus = f"Ошибка при обработке GigaChat-Plus: {e}"
260
 
 
321
  inputs=[output_text_gpt4o, output_text_gigachat_pro, output_text_gigachat_lite, output_text_gigachat_plus] + selections,
322
  outputs=[
323
  gr.Textbox(label="Промпт для персонализации", lines=6, interactive=False),
324
+ gr.Textbox(label="Персонализированное сообщение GPT-4o", lines=6),
325
+ gr.Textbox(label="Персонализированное сообщение GigaChat-Pro", lines=6),
326
+ gr.Textbox(label="Персонализированное сообщение GigaChat-Lite", lines=6),
327
+ gr.Textbox(label="Персонализированное сообщение GigaChat-Lite+", lines=6),
328
  status_display
329
  ]
330
  )
 
336
  with gr.Row():
337
  check_errors_btn.click(
338
  check_errors_with_yield,
339
+ inputs=[output_text_gpt4o, output_text_gigachat_pro, output_text_gigachat_lite, output_text_gigachat_plus],
340
  outputs=[
341
  gr.Textbox(label="Промпт для проверки текста", lines=6, interactive=False),
342
  gr.Textbox(label="Результат проверки GPT-4o", lines=6),
 
347
  ]
348
  )
349
 
 
350
  demo.launch()