Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -127,31 +127,33 @@ def generate_messages(description, advantages, *selected_values):
|
|
127 |
"gigachat_plus": None
|
128 |
}
|
129 |
|
130 |
-
yield results["prompt"], "", "", "", "",
|
131 |
|
132 |
results["gpt4o"] = generate_message_gpt4o(standard_prompt)
|
133 |
-
yield results["prompt"], results["gpt4o"], "", "", "",
|
134 |
|
135 |
results["gigachat_pro"] = generate_message_gigachat_pro(standard_prompt)
|
136 |
-
yield results["prompt"], results["gpt4o"], results["gigachat_pro"], "", "",
|
137 |
|
138 |
results["gigachat_lite"] = generate_message_gigachat_lite(standard_prompt)
|
139 |
-
yield results["prompt"], results["gpt4o"], results["gigachat_pro"], results["gigachat_lite"], "",
|
140 |
|
141 |
results["gigachat_plus"] = generate_message_gigachat_plus(standard_prompt)
|
142 |
-
yield results["prompt"], results["gpt4o"], results["gigachat_pro"], results["gigachat_lite"], results["gigachat_plus"],
|
143 |
|
|
|
144 |
return results
|
145 |
|
146 |
# Функция для выполнения персонализации
|
147 |
-
def
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
151 |
else:
|
152 |
-
|
153 |
-
|
154 |
-
return f"Ошибка при обработке данных: {e}"
|
155 |
|
156 |
# Создание интерфейса Gradio
|
157 |
with gr.Blocks() as demo:
|
@@ -195,12 +197,12 @@ with gr.Blocks() as demo:
|
|
195 |
output_text_gigachat_pro = gr.Textbox(label="Создание сообщения GigaChat-Pro", lines=3)
|
196 |
output_text_gigachat_lite = gr.Textbox(label="Создание сообщения GigaChat-Lite", lines=3)
|
197 |
output_text_gigachat_plus = gr.Textbox(label="Создание сообщения GigaChat-Lite+", lines=3)
|
198 |
-
|
199 |
|
200 |
submit_btn.click(
|
201 |
generate_messages,
|
202 |
inputs=[description_input, advantages_input] + selections,
|
203 |
-
outputs=[prompt_display, output_text_gpt4o, output_text_gigachat_pro, output_text_gigachat_lite, output_text_gigachat_plus,
|
204 |
)
|
205 |
|
206 |
with gr.Row():
|
@@ -208,9 +210,9 @@ with gr.Blocks() as demo:
|
|
208 |
|
209 |
with gr.Row():
|
210 |
personalize_btn.click(
|
211 |
-
|
212 |
-
inputs=
|
213 |
-
outputs=[gr.Textbox(label="Персонализированный текст для
|
214 |
)
|
215 |
|
216 |
demo.launch()
|
|
|
127 |
"gigachat_plus": None
|
128 |
}
|
129 |
|
130 |
+
yield results["prompt"], "", "", "", "", "Генерация стандартного промпта завершена"
|
131 |
|
132 |
results["gpt4o"] = generate_message_gpt4o(standard_prompt)
|
133 |
+
yield results["prompt"], results["gpt4o"], "", "", "", "Сообщение GPT-4o сгенерировано"
|
134 |
|
135 |
results["gigachat_pro"] = generate_message_gigachat_pro(standard_prompt)
|
136 |
+
yield results["prompt"], results["gpt4o"], results["gigachat_pro"], "", "", "Сообщение GigaChat-Pro сгенерировано"
|
137 |
|
138 |
results["gigachat_lite"] = generate_message_gigachat_lite(standard_prompt)
|
139 |
+
yield results["prompt"], results["gpt4o"], results["gigachat_pro"], results["gigachat_lite"], "", "Сообщение GigaChat-Lite сгенерировано"
|
140 |
|
141 |
results["gigachat_plus"] = generate_message_gigachat_plus(standard_prompt)
|
142 |
+
yield results["prompt"], results["gpt4o"], results["gigachat_pro"], results["gigachat_lite"], results["gigachat_plus"], "Все сообщения сгенерированы"
|
143 |
|
144 |
+
# Возвращаем результаты для дальнейшей персонализации
|
145 |
return results
|
146 |
|
147 |
# Функция для выполнения персонализации
|
148 |
+
def personalize_all_texts(*selected_values):
|
149 |
+
personalized_texts = []
|
150 |
+
for i, feature in enumerate(features.keys()):
|
151 |
+
if selected_values[i]:
|
152 |
+
text = features[feature].get(selected_values[i], "Текст не найден")
|
153 |
+
personalized_texts.append(f"Персонализированный текст для {feature}: {text}")
|
154 |
else:
|
155 |
+
personalized_texts.append(f"Персонализированный текст для {feature}: не выбран")
|
156 |
+
return personalized_texts
|
|
|
157 |
|
158 |
# Создание интерфейса Gradio
|
159 |
with gr.Blocks() as demo:
|
|
|
197 |
output_text_gigachat_pro = gr.Textbox(label="Создание сообщения GigaChat-Pro", lines=3)
|
198 |
output_text_gigachat_lite = gr.Textbox(label="Создание сообщения GigaChat-Lite", lines=3)
|
199 |
output_text_gigachat_plus = gr.Textbox(label="Создание сообщения GigaChat-Lite+", lines=3)
|
200 |
+
status_display = gr.Textbox(label="Статус выполнения", lines=4, interactive=False) # Новый блок для отображения статуса
|
201 |
|
202 |
submit_btn.click(
|
203 |
generate_messages,
|
204 |
inputs=[description_input, advantages_input] + selections,
|
205 |
+
outputs=[prompt_display, output_text_gpt4o, output_text_gigachat_pro, output_text_gigachat_lite, output_text_gigachat_plus, status_display]
|
206 |
)
|
207 |
|
208 |
with gr.Row():
|
|
|
210 |
|
211 |
with gr.Row():
|
212 |
personalize_btn.click(
|
213 |
+
personalize_all_texts,
|
214 |
+
inputs=selections,
|
215 |
+
outputs=[gr.Textbox(label=f"Персонализированный текст для {feature}", lines=3) for feature in features.keys()]
|
216 |
)
|
217 |
|
218 |
demo.launch()
|