Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -171,21 +171,28 @@ def perform_personalization_gigachat(standard_message, personalization_prompt, m
|
|
171 |
elif model == "gigachat_plus":
|
172 |
return generate_message_gigachat_plus(full_prompt)
|
173 |
|
174 |
-
#
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
personalization_prompt = generate_personalization_prompt(*selected_values)
|
177 |
yield personalization_prompt, "", "", "", "", "Промпт для персонализации сгенерирован"
|
178 |
|
179 |
-
personalized_message_gpt4o = perform_personalization(
|
180 |
yield personalization_prompt, personalized_message_gpt4o, "", "", "", "Персонализированное сообщение GPT-4o сгенерировано"
|
181 |
|
182 |
-
personalized_message_gigachat_pro = perform_personalization_gigachat(
|
183 |
yield personalization_prompt, personalized_message_gpt4o, personalized_message_gigachat_pro, "", "", "Персонализированное сообщение GigaChat-Pro сгенерировано"
|
184 |
|
185 |
-
personalized_message_gigachat_lite = perform_personalization_gigachat(
|
186 |
yield personalization_prompt, personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, "", "Персонализированное сообщение GigaChat-Lite сгенерировано"
|
187 |
|
188 |
-
personalized_message_gigachat_plus = perform_personalization_gigachat(
|
189 |
yield personalization_prompt, personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, personalized_message_gigachat_plus, "Все персонализированные сообщения сгенерированы"
|
190 |
|
191 |
# Функция для генерации промпта проверки текста
|
@@ -318,7 +325,7 @@ with gr.Blocks() as demo:
|
|
318 |
with gr.Row():
|
319 |
personalize_btn.click(
|
320 |
personalize_messages_with_yield,
|
321 |
-
inputs=[output_text_gpt4o] + selections,
|
322 |
outputs=[
|
323 |
gr.Textbox(label="Промпт для персонализации", lines=6, interactive=False),
|
324 |
gr.Textbox(label="Персонализированное сообщение GPT-4o", lines=6),
|
@@ -328,6 +335,7 @@ with gr.Blocks() as demo:
|
|
328 |
status_display
|
329 |
]
|
330 |
)
|
|
|
331 |
|
332 |
with gr.Row():
|
333 |
check_errors_btn = gr.Button("3. Проверить текст (нажимать только после кнопки 2)", elem_id="check_errors_button")
|
@@ -335,7 +343,7 @@ with gr.Blocks() as demo:
|
|
335 |
with gr.Row():
|
336 |
check_errors_btn.click(
|
337 |
check_errors_with_yield,
|
338 |
-
inputs=[
|
339 |
outputs=[
|
340 |
gr.Textbox(label="Промпт для проверки текста", lines=6, interactive=False),
|
341 |
gr.Textbox(label="Результат проверки GPT-4o", lines=6),
|
@@ -346,4 +354,5 @@ with gr.Blocks() as demo:
|
|
346 |
]
|
347 |
)
|
348 |
|
|
|
349 |
demo.launch()
|
|
|
171 |
elif model == "gigachat_plus":
|
172 |
return generate_message_gigachat_plus(full_prompt)
|
173 |
|
174 |
+
# Глобальные переменные для персонализированных сообщений
|
175 |
+
personalized_message_gpt4o = None
|
176 |
+
personalized_message_gigachat_pro = None
|
177 |
+
personalized_message_gigachat_lite = None
|
178 |
+
personalized_message_gigachat_plus = None
|
179 |
+
|
180 |
+
def personalize_messages_with_yield(gpt4o_message, gigachat_pro_message, gigachat_lite_message, gigachat_plus_message, *selected_values):
|
181 |
+
global personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, personalized_message_gigachat_plus
|
182 |
+
|
183 |
personalization_prompt = generate_personalization_prompt(*selected_values)
|
184 |
yield personalization_prompt, "", "", "", "", "Промпт для персонализации сгенерирован"
|
185 |
|
186 |
+
personalized_message_gpt4o = perform_personalization(gpt4o_message, personalization_prompt)
|
187 |
yield personalization_prompt, personalized_message_gpt4o, "", "", "", "Персонализированное сообщение GPT-4o сгенерировано"
|
188 |
|
189 |
+
personalized_message_gigachat_pro = perform_personalization_gigachat(gigachat_pro_message, personalization_prompt, "gigachat_pro")
|
190 |
yield personalization_prompt, personalized_message_gpt4o, personalized_message_gigachat_pro, "", "", "Персонализированное сообщение GigaChat-Pro сгенерировано"
|
191 |
|
192 |
+
personalized_message_gigachat_lite = perform_personalization_gigachat(gigachat_lite_message, personalization_prompt, "gigachat_lite")
|
193 |
yield personalization_prompt, personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, "", "Персонализированное сообщение GigaChat-Lite сгенерировано"
|
194 |
|
195 |
+
personalized_message_gigachat_plus = perform_personalization_gigachat(gigachat_plus_message, personalization_prompt, "gigachat_plus")
|
196 |
yield personalization_prompt, personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, personalized_message_gigachat_plus, "Все персонализированные сообщения сгенерированы"
|
197 |
|
198 |
# Функция для генерации промпта проверки текста
|
|
|
325 |
with gr.Row():
|
326 |
personalize_btn.click(
|
327 |
personalize_messages_with_yield,
|
328 |
+
inputs=[output_text_gpt4o, output_text_gigachat_pro, output_text_gigachat_lite, output_text_gigachat_plus] + selections,
|
329 |
outputs=[
|
330 |
gr.Textbox(label="Промпт для персонализации", lines=6, interactive=False),
|
331 |
gr.Textbox(label="Персонализированное сообщение GPT-4o", lines=6),
|
|
|
335 |
status_display
|
336 |
]
|
337 |
)
|
338 |
+
|
339 |
|
340 |
with gr.Row():
|
341 |
check_errors_btn = gr.Button("3. Проверить текст (нажимать только после кнопки 2)", elem_id="check_errors_button")
|
|
|
343 |
with gr.Row():
|
344 |
check_errors_btn.click(
|
345 |
check_errors_with_yield,
|
346 |
+
inputs=[personalized_message_gpt4o, personalized_message_gigachat_pro, personalized_message_gigachat_lite, personalized_message_gigachat_plus],
|
347 |
outputs=[
|
348 |
gr.Textbox(label="Промпт для проверки текста", lines=6, interactive=False),
|
349 |
gr.Textbox(label="Результат проверки GPT-4o", lines=6),
|
|
|
354 |
]
|
355 |
)
|
356 |
|
357 |
+
|
358 |
demo.launch()
|