Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -174,6 +174,38 @@ def save_message_to_table(data):
|
|
174 |
print(f"Error updating messages file: {response.status_code}")
|
175 |
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
def load_previous_user_request_from_github():
|
178 |
global current_request_index # Используем глобальную переменную
|
179 |
|
@@ -2152,12 +2184,12 @@ with gr.Blocks() as demo:
|
|
2152 |
inputs=[],
|
2153 |
outputs=[save_gigachat_pro_btn]
|
2154 |
).then(
|
2155 |
-
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
inputs=[
|
2162 |
adapted_output_text_gigachat_pro,
|
2163 |
personalized_output_text_gigachat_pro,
|
@@ -2186,19 +2218,19 @@ with gr.Blocks() as demo:
|
|
2186 |
outputs=[save_gigachat_pro_btn]
|
2187 |
)
|
2188 |
|
2189 |
-
|
2190 |
# Повторяем аналогично для других кнопок:
|
2191 |
save_gigachat_lite_btn.click(
|
2192 |
fn=prepare_button_text,
|
2193 |
inputs=[],
|
2194 |
outputs=[save_gigachat_lite_btn]
|
2195 |
).then(
|
2196 |
-
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
inputs=[
|
2203 |
adapted_output_text_gigachat_lite,
|
2204 |
personalized_output_text_gigachat_lite,
|
@@ -2209,14 +2241,14 @@ with gr.Blocks() as demo:
|
|
2209 |
prompt_display,
|
2210 |
output_text_gigachat_lite,
|
2211 |
personalization_prompt,
|
2212 |
-
selections[0],
|
2213 |
-
selections[1],
|
2214 |
-
selections[2],
|
2215 |
-
selections[3],
|
2216 |
-
selections[4],
|
2217 |
-
selections[5],
|
2218 |
-
key_message_input,
|
2219 |
-
approach_input
|
2220 |
],
|
2221 |
outputs=None
|
2222 |
).then(
|
@@ -2233,12 +2265,12 @@ with gr.Blocks() as demo:
|
|
2233 |
inputs=[],
|
2234 |
outputs=[save_gigachat_plus_btn]
|
2235 |
).then(
|
2236 |
-
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
inputs=[
|
2243 |
adapted_output_text_gigachat_plus,
|
2244 |
personalized_output_text_gigachat_plus,
|
@@ -2249,14 +2281,14 @@ with gr.Blocks() as demo:
|
|
2249 |
prompt_display,
|
2250 |
output_text_gigachat_plus,
|
2251 |
personalization_prompt,
|
2252 |
-
selections[0],
|
2253 |
-
selections[1],
|
2254 |
-
selections[2],
|
2255 |
-
selections[3],
|
2256 |
-
selections[4],
|
2257 |
-
selections[5],
|
2258 |
-
key_message_input,
|
2259 |
-
approach_input
|
2260 |
],
|
2261 |
outputs=None
|
2262 |
).then(
|
@@ -2273,12 +2305,12 @@ with gr.Blocks() as demo:
|
|
2273 |
inputs=[],
|
2274 |
outputs=[save_gpt4o_btn]
|
2275 |
).then(
|
2276 |
-
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
inputs=[
|
2283 |
adapted_output_text_gpt4o,
|
2284 |
personalized_output_text_gpt4o,
|
@@ -2289,14 +2321,14 @@ with gr.Blocks() as demo:
|
|
2289 |
prompt_display,
|
2290 |
output_text_gpt4o,
|
2291 |
personalization_prompt,
|
2292 |
-
selections[0],
|
2293 |
-
selections[1],
|
2294 |
-
selections[2],
|
2295 |
-
selections[3],
|
2296 |
-
selections[4],
|
2297 |
-
selections[5],
|
2298 |
-
key_message_input,
|
2299 |
-
approach_input
|
2300 |
],
|
2301 |
outputs=None
|
2302 |
).then(
|
@@ -2307,18 +2339,18 @@ with gr.Blocks() as demo:
|
|
2307 |
outputs=[save_gpt4o_btn]
|
2308 |
)
|
2309 |
|
2310 |
-
|
2311 |
save_meta_llama_405b_btn.click(
|
2312 |
fn=prepare_button_text,
|
2313 |
inputs=[],
|
2314 |
outputs=[save_meta_llama_405b_btn]
|
2315 |
).then(
|
2316 |
-
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
inputs=[
|
2323 |
adapted_output_text_meta_llama_405b,
|
2324 |
personalized_output_text_meta_llama_405b,
|
@@ -2329,14 +2361,14 @@ with gr.Blocks() as demo:
|
|
2329 |
prompt_display,
|
2330 |
output_text_meta_llama_405b,
|
2331 |
personalization_prompt,
|
2332 |
-
selections[0],
|
2333 |
-
selections[1],
|
2334 |
-
selections[2],
|
2335 |
-
selections[3],
|
2336 |
-
selections[4],
|
2337 |
-
selections[5],
|
2338 |
-
key_message_input,
|
2339 |
-
approach_input
|
2340 |
],
|
2341 |
outputs=None
|
2342 |
).then(
|
|
|
174 |
print(f"Error updating messages file: {response.status_code}")
|
175 |
|
176 |
|
177 |
+
def save_both(adapted_message, personalized_message, model_name, comment, corrected_message, description, advantages,
|
178 |
+
non_personalized_prompt, non_personalized_message, personalization_prompt, gender, generation, psychotype,
|
179 |
+
business_stage, industry, legal_form, key_message, approach):
|
180 |
+
# Вызываем функцию для сохранения в JSON-файл
|
181 |
+
save_to_github(adapted_message, personalized_message, model_name, comment, corrected_message, description,
|
182 |
+
advantages, non_personalized_prompt, non_personalized_message, personalization_prompt, gender,
|
183 |
+
generation, psychotype, business_stage, industry, legal_form, key_message, approach)
|
184 |
+
|
185 |
+
# Подготавливаем данные для сохранения в CSV/XLSX
|
186 |
+
data = {
|
187 |
+
"Timestamp": time.time(),
|
188 |
+
"Модель": model_name,
|
189 |
+
"Адаптированное сообщение": adapted_message,
|
190 |
+
"Персонализированное сообщение": personalized_message,
|
191 |
+
"Комментарий": comment,
|
192 |
+
"Откорректированное сообщение": corrected_message,
|
193 |
+
"Описание предложения": description,
|
194 |
+
"Преимущества": advantages,
|
195 |
+
"Ключевое сообщение": key_message,
|
196 |
+
"Подход": approach,
|
197 |
+
"Пол": gender,
|
198 |
+
"Поколение": generation,
|
199 |
+
"Психотип": psychotype,
|
200 |
+
"Стадия бизнеса": business_stage,
|
201 |
+
"Отрасль": industry,
|
202 |
+
"ОПФ": legal_form
|
203 |
+
}
|
204 |
+
|
205 |
+
# Вызываем функцию для сохранения в CSV/XLSX
|
206 |
+
save_message_to_table(data)
|
207 |
+
|
208 |
+
|
209 |
def load_previous_user_request_from_github():
|
210 |
global current_request_index # Используем глобальную переменную
|
211 |
|
|
|
2184 |
inputs=[],
|
2185 |
outputs=[save_gigachat_pro_btn]
|
2186 |
).then(
|
2187 |
+
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2188 |
+
non_personalized_prompt, non_personalized_message, personalization_prompt, gender, generation, psychotype,
|
2189 |
+
business_stage, industry, legal_form, key_message, approach:
|
2190 |
+
save_both(adapted_message, personalized_message, "GigaChat-Pro", comment, corrected_message, description,
|
2191 |
+
advantages, non_personalized_prompt, non_personalized_message, personalization_prompt, gender,
|
2192 |
+
generation, psychotype, business_stage, industry, legal_form, key_message, approach),
|
2193 |
inputs=[
|
2194 |
adapted_output_text_gigachat_pro,
|
2195 |
personalized_output_text_gigachat_pro,
|
|
|
2218 |
outputs=[save_gigachat_pro_btn]
|
2219 |
)
|
2220 |
|
2221 |
+
|
2222 |
# Повторяем аналогично для других кнопок:
|
2223 |
save_gigachat_lite_btn.click(
|
2224 |
fn=prepare_button_text,
|
2225 |
inputs=[],
|
2226 |
outputs=[save_gigachat_lite_btn]
|
2227 |
).then(
|
2228 |
+
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2229 |
+
non_personalized_prompt, non_personalized_message, personalization_prompt, gender, generation, psychotype,
|
2230 |
+
business_stage, industry, legal_form, key_message, approach:
|
2231 |
+
save_both(adapted_message, personalized_message, "GigaChat-Lite", comment, corrected_message, description,
|
2232 |
+
advantages, non_personalized_prompt, non_personalized_message, personalization_prompt, gender,
|
2233 |
+
generation, psychotype, business_stage, industry, legal_form, key_message, approach),
|
2234 |
inputs=[
|
2235 |
adapted_output_text_gigachat_lite,
|
2236 |
personalized_output_text_gigachat_lite,
|
|
|
2241 |
prompt_display,
|
2242 |
output_text_gigachat_lite,
|
2243 |
personalization_prompt,
|
2244 |
+
selections[0],
|
2245 |
+
selections[1],
|
2246 |
+
selections[2],
|
2247 |
+
selections[3],
|
2248 |
+
selections[4],
|
2249 |
+
selections[5],
|
2250 |
+
key_message_input,
|
2251 |
+
approach_input
|
2252 |
],
|
2253 |
outputs=None
|
2254 |
).then(
|
|
|
2265 |
inputs=[],
|
2266 |
outputs=[save_gigachat_plus_btn]
|
2267 |
).then(
|
2268 |
+
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2269 |
+
non_personalized_prompt, non_personalized_message, personalization_prompt, gender, generation, psychotype,
|
2270 |
+
business_stage, industry, legal_form, key_message, approach:
|
2271 |
+
save_both(adapted_message, personalized_message, "GigaChat-Lite+", comment, corrected_message, description,
|
2272 |
+
advantages, non_personalized_prompt, non_personalized_message, personalization_prompt, gender,
|
2273 |
+
generation, psychotype, business_stage, industry, legal_form, key_message, approach),
|
2274 |
inputs=[
|
2275 |
adapted_output_text_gigachat_plus,
|
2276 |
personalized_output_text_gigachat_plus,
|
|
|
2281 |
prompt_display,
|
2282 |
output_text_gigachat_plus,
|
2283 |
personalization_prompt,
|
2284 |
+
selections[0],
|
2285 |
+
selections[1],
|
2286 |
+
selections[2],
|
2287 |
+
selections[3],
|
2288 |
+
selections[4],
|
2289 |
+
selections[5],
|
2290 |
+
key_message_input,
|
2291 |
+
approach_input
|
2292 |
],
|
2293 |
outputs=None
|
2294 |
).then(
|
|
|
2305 |
inputs=[],
|
2306 |
outputs=[save_gpt4o_btn]
|
2307 |
).then(
|
2308 |
+
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2309 |
+
non_personalized_prompt, non_personalized_message, personalization_prompt, gender, generation, psychotype,
|
2310 |
+
business_stage, industry, legal_form, key_message, approach:
|
2311 |
+
save_both(adapted_message, personalized_message, "GPT-4o", comment, corrected_message, description,
|
2312 |
+
advantages, non_personalized_prompt, non_personalized_message, personalization_prompt, gender,
|
2313 |
+
generation, psychotype, business_stage, industry, legal_form, key_message, approach),
|
2314 |
inputs=[
|
2315 |
adapted_output_text_gpt4o,
|
2316 |
personalized_output_text_gpt4o,
|
|
|
2321 |
prompt_display,
|
2322 |
output_text_gpt4o,
|
2323 |
personalization_prompt,
|
2324 |
+
selections[0],
|
2325 |
+
selections[1],
|
2326 |
+
selections[2],
|
2327 |
+
selections[3],
|
2328 |
+
selections[4],
|
2329 |
+
selections[5],
|
2330 |
+
key_message_input,
|
2331 |
+
approach_input
|
2332 |
],
|
2333 |
outputs=None
|
2334 |
).then(
|
|
|
2339 |
outputs=[save_gpt4o_btn]
|
2340 |
)
|
2341 |
|
2342 |
+
|
2343 |
save_meta_llama_405b_btn.click(
|
2344 |
fn=prepare_button_text,
|
2345 |
inputs=[],
|
2346 |
outputs=[save_meta_llama_405b_btn]
|
2347 |
).then(
|
2348 |
+
fn=lambda adapted_message, personalized_message, comment, corrected_message, description, advantages,
|
2349 |
+
non_personalized_prompt, non_personalized_message, personalization_prompt, gender, generation, psychotype,
|
2350 |
+
business_stage, industry, legal_form, key_message, approach:
|
2351 |
+
save_both(adapted_message, personalized_message, "Meta-Llama-3.1-405B", comment, corrected_message, description,
|
2352 |
+
advantages, non_personalized_prompt, non_personalized_message, personalization_prompt, gender,
|
2353 |
+
generation, psychotype, business_stage, industry, legal_form, key_message, approach),
|
2354 |
inputs=[
|
2355 |
adapted_output_text_meta_llama_405b,
|
2356 |
personalized_output_text_meta_llama_405b,
|
|
|
2361 |
prompt_display,
|
2362 |
output_text_meta_llama_405b,
|
2363 |
personalization_prompt,
|
2364 |
+
selections[0],
|
2365 |
+
selections[1],
|
2366 |
+
selections[2],
|
2367 |
+
selections[3],
|
2368 |
+
selections[4],
|
2369 |
+
selections[5],
|
2370 |
+
key_message_input,
|
2371 |
+
approach_input
|
2372 |
],
|
2373 |
outputs=None
|
2374 |
).then(
|