Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -88,7 +88,7 @@ def generate_message_gpt4o(prompt):
|
|
88 |
response_data = response.json()
|
89 |
return response_data["choices"][0]["message"]["content"].strip()
|
90 |
except Exception as e:
|
91 |
-
|
92 |
|
93 |
def generate_message_gigachat_pro(prompt):
|
94 |
try:
|
@@ -161,11 +161,32 @@ def personalize_messages(results, *selected_values):
|
|
161 |
personalization_prompt_gigachat_lite += requirement
|
162 |
personalization_prompt_gigachat_plus += requirement
|
163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
# Персонализированные сообщения
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
return personalization_prompt_gpt4o, personalized_message_gpt4o, personalization_prompt_gigachat_pro, personalized_message_gigachat_pro, personalization_prompt_gigachat_lite, personalized_message_gigachat_lite, personalization_prompt_gigachat_plus, personalized_message_gigachat_plus
|
171 |
|
@@ -212,7 +233,6 @@ with gr.Blocks() as demo:
|
|
212 |
output_text_gigachat_lite = gr.Textbox(label="Создание сообщения GigaChat-Lite", lines=3)
|
213 |
output_text_gigachat_plus = gr.Textbox(label="Создание сообщения GigaChat-Lite+", lines=3)
|
214 |
|
215 |
-
# Кнопка для генерации стандартных сообщений
|
216 |
submit_btn.click(
|
217 |
generate_messages,
|
218 |
inputs=[description_input, advantages_input] + selections,
|
@@ -220,26 +240,21 @@ with gr.Blocks() as demo:
|
|
220 |
)
|
221 |
|
222 |
with gr.Row():
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
personalization_prompt_gigachat_pro_display = gr.Textbox(label="Промпт для персонализации GigaChat-Pro", lines=6, interactive=False)
|
227 |
-
personalized_output_text_gigachat_pro = gr.Textbox(label="Персонализированное сообщение GigaChat-Pro", lines=3)
|
228 |
-
personalization_prompt_gigachat_lite_display = gr.Textbox(label="Промпт для персонализации GigaChat-Lite", lines=6, interactive=False)
|
229 |
-
personalized_output_text_gigachat_lite = gr.Textbox(label="Персонализированное сообщение GigaChat-Lite", lines=3)
|
230 |
-
personalization_prompt_gigachat_plus_display = gr.Textbox(label="Промпт для персонализации GigaChat-Lite+", lines=6, interactive=False)
|
231 |
-
personalized_output_text_gigachat_plus = gr.Textbox(label="Персонализированное сообщение GigaChat-Lite+", lines=3)
|
232 |
-
|
233 |
-
# Кнопка для выполнения персонализации
|
234 |
-
personalize_btn = gr.Button("Выполнить персонализацию")
|
235 |
personalize_btn.click(
|
236 |
personalize_messages,
|
237 |
inputs=[prompt_display, output_text_gpt4o, output_text_gigachat_pro, output_text_gigachat_lite, output_text_gigachat_plus] + selections,
|
238 |
outputs=[
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
|
|
|
|
|
|
243 |
]
|
244 |
)
|
245 |
|
|
|
88 |
response_data = response.json()
|
89 |
return response_data["choices"][0]["message"]["content"].strip()
|
90 |
except Exception as e:
|
91 |
+
print(f"Ошибка при обращении к ChatGPT-4o-Latest: {e}")
|
92 |
|
93 |
def generate_message_gigachat_pro(prompt):
|
94 |
try:
|
|
|
161 |
personalization_prompt_gigachat_lite += requirement
|
162 |
personalization_prompt_gigachat_plus += requirement
|
163 |
|
164 |
+
print("Промпты для персонализации созданы успешно.")
|
165 |
+
print(f"GPT-4o: {personalization_prompt_gpt4o}")
|
166 |
+
print(f"GigaChat-Pro: {personalization_prompt_gigachat_pro}")
|
167 |
+
print(f"GigaChat-Lite: {personalization_prompt_gigachat_lite}")
|
168 |
+
print(f"GigaChat-Plus: {personalization_prompt_gigachat_plus}")
|
169 |
+
|
170 |
# Персонализированные сообщения
|
171 |
+
try:
|
172 |
+
personalized_message_gpt4o = generate_message_gpt4o(personalization_prompt_gpt4o)
|
173 |
+
except Exception as e:
|
174 |
+
personalized_message_gpt4o = f"Ошибка при персонализации GPT-4o: {e}"
|
175 |
+
|
176 |
+
try:
|
177 |
+
personalized_message_gigachat_pro = generate_message_gigachat_pro(personalization_prompt_gigachat_pro)
|
178 |
+
except Exception as e:
|
179 |
+
personalized_message_gigachat_pro = f"Ошибка при персонализации GigaChat-Pro: {e}"
|
180 |
+
|
181 |
+
try:
|
182 |
+
personalized_message_gigachat_lite = generate_message_gigachat_lite(personalization_prompt_gigachat_lite)
|
183 |
+
except Exception as e:
|
184 |
+
personalized_message_gigachat_lite = f"Ошибка при персонализации GigaChat-Lite: {e}"
|
185 |
+
|
186 |
+
try:
|
187 |
+
personalized_message_gigachat_plus = generate_message_gigachat_plus(personalization_prompt_gigachat_plus)
|
188 |
+
except Exception as e:
|
189 |
+
personalized_message_gigachat_plus = f"Ошибка при персонализации GigaChat-Lite+: {e}"
|
190 |
|
191 |
return personalization_prompt_gpt4o, personalized_message_gpt4o, personalization_prompt_gigachat_pro, personalized_message_gigachat_pro, personalization_prompt_gigachat_lite, personalized_message_gigachat_lite, personalization_prompt_gigachat_plus, personalized_message_gigachat_plus
|
192 |
|
|
|
233 |
output_text_gigachat_lite = gr.Textbox(label="Создание сообщения GigaChat-Lite", lines=3)
|
234 |
output_text_gigachat_plus = gr.Textbox(label="Создание сообщения GigaChat-Lite+", lines=3)
|
235 |
|
|
|
236 |
submit_btn.click(
|
237 |
generate_messages,
|
238 |
inputs=[description_input, advantages_input] + selections,
|
|
|
240 |
)
|
241 |
|
242 |
with gr.Row():
|
243 |
+
gr.Markdown("### Выполнить персонализацию")
|
244 |
+
|
245 |
+
personalize_btn = gr.Button("Выполнить персонализацию", elem_id="personalize_btn")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
personalize_btn.click(
|
247 |
personalize_messages,
|
248 |
inputs=[prompt_display, output_text_gpt4o, output_text_gigachat_pro, output_text_gigachat_lite, output_text_gigachat_plus] + selections,
|
249 |
outputs=[
|
250 |
+
gr.Textbox(label="Промпт для персонализации GPT-4o", lines=6, interactive=False),
|
251 |
+
gr.Textbox(label="Персонализированное сообщение GPT-4o", lines=3),
|
252 |
+
gr.Textbox(label="Промпт для персонализации GigaChat-Pro", lines=6, interactive=False),
|
253 |
+
gr.Textbox(label="Персонализированное сообщение GigaChat-Pro", lines=3),
|
254 |
+
gr.Textbox(label="Промпт для персонализации GigaChat-Lite", lines=6, interactive=False),
|
255 |
+
gr.Textbox(label="Персонализированное сообщение GigaChat-Lite", lines=3),
|
256 |
+
gr.Textbox(label="Промпт для персонализации GigaChat-Lite+", lines=6, interactive=False),
|
257 |
+
gr.Textbox(label="Персонализированное сообщение GigaChat-Lite+", lines=3)
|
258 |
]
|
259 |
)
|
260 |
|