haepada commited on
Commit
0dcaf7c
ยท
1 Parent(s): 7be6999

๐ŸŽจ ์™„์„ฑ: ์ด๋ฏธ์ง€ ํŠน์„ฑ ๋ฐ˜์˜ AI ๊ตฌ์ฒดํ™” ์‹œ์Šคํ…œ - ๊ธฐ๋ณธ ํ•จ์ˆ˜ + AI ์ƒ์„ธํ™” 2๋‹จ๊ณ„ ๊ตฌ์กฐ ๊ตฌํ˜„, ์‚ฌ๋ฌผ๋ณ„ ๊ณ ์œ  ํŠน์„ฑ๊ณผ ์„ฑ๊ฒฉ ์กฐํ•ฉ์œผ๋กœ ํ˜„์‹ค์  ๊ฒฐํ•จ ์ƒ์„ฑ

Browse files
Files changed (2) hide show
  1. app.py +114 -0
  2. app_backup.py +0 -0
app.py CHANGED
@@ -2359,6 +2359,120 @@ def get_object_specific_concerns(object_type, material, purpose):
2359
 
2360
  return concerns
2361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2362
  if __name__ == "__main__":
2363
  app = create_main_interface()
2364
  app.launch(server_name="0.0.0.0", server_port=7860)
 
2359
 
2360
  return concerns
2361
 
2362
+ def refine_flaws_with_ai_and_image_analysis(basic_flaws, basic_contradictions, image_analysis, personality_traits):
2363
+ """AI๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์ด๋ฏธ์ง€ ๋ถ„์„ ๊ฒฐ๊ณผ์— ๋งž๊ฒŒ ๊ฒฐํ•จ๊ณผ ๋ชจ์ˆœ์„ ๊ตฌ์ฒดํ™”"""
2364
+ global persona_generator
2365
+
2366
+ if not persona_generator or not hasattr(persona_generator, 'api_key') or not persona_generator.api_key:
2367
+ print("โš ๏ธ API ํ‚ค ์—†์Œ - ๊ธฐ๋ณธ ๊ฒฐํ•จ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ")
2368
+ return basic_flaws, basic_contradictions
2369
+
2370
+ try:
2371
+ # ์ด๋ฏธ์ง€ ๋ถ„์„์—์„œ ๊ตฌ์ฒด์  ํŠน์„ฑ ์ถ”์ถœ
2372
+ object_type = image_analysis.get("object_type", "์‚ฌ๋ฌผ")
2373
+ distinctive_features = image_analysis.get("distinctive_features", [])
2374
+ shape = image_analysis.get("shape", "์ผ๋ฐ˜์ ์ธ ํ˜•ํƒœ")
2375
+ size = image_analysis.get("size", "๋ณดํ†ต ํฌ๊ธฐ")
2376
+ materials = image_analysis.get("materials", ["์•Œ ์ˆ˜ ์—†๋Š” ์žฌ์งˆ"])
2377
+ colors = image_analysis.get("colors", ["ํšŒ์ƒ‰"])
2378
+ condition = image_analysis.get("condition", "๋ณดํ†ต")
2379
+
2380
+ # ์„ฑ๊ฒฉ ํŠน์„ฑ ์š”์•ฝ
2381
+ warmth = personality_traits.get("์˜จ๊ธฐ", 50)
2382
+ competence = personality_traits.get("๋Šฅ๋ ฅ", 50)
2383
+ extraversion = personality_traits.get("์™ธํ–ฅ์„ฑ", 50)
2384
+
2385
+ # AI ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ
2386
+ ai_prompt = f"""
2387
+ ๋‹ค์Œ ๊ธฐ๋ณธ ๋งค๋ ฅ์  ๊ฒฐํ•จ๋“ค์„ ์‹ค์ œ ์ด๋ฏธ์ง€ ๋ถ„์„ ๊ฒฐ๊ณผ์— ๋งž๊ฒŒ ๊ตฌ์ฒดํ™”ํ•ด์ฃผ์„ธ์š”.
2388
+
2389
+ **์‹ค์ œ ์ด๋ฏธ์ง€ ๋ถ„์„ ๊ฒฐ๊ณผ:**
2390
+ - ์‚ฌ๋ฌผ: {object_type}
2391
+ - ํŠน์ง•์  ์š”์†Œ: {', '.join(distinctive_features)}
2392
+ - ํ˜•ํƒœ: {shape}
2393
+ - ํฌ๊ธฐ: {size}
2394
+ - ์žฌ์งˆ: {', '.join(materials)}
2395
+ - ์ƒ‰์ƒ: {', '.join(colors)}
2396
+ - ์ƒํƒœ: {condition}
2397
+
2398
+ **์„ฑ๊ฒฉ ํŠน์„ฑ:**
2399
+ - ์˜จ๊ธฐ: {warmth}/100
2400
+ - ๋Šฅ๋ ฅ: {competence}/100
2401
+ - ์™ธํ–ฅ์„ฑ: {extraversion}/100
2402
+
2403
+ **๊ธฐ๋ณธ ๊ฒฐํ•จ๋“ค (์ˆ˜์ • ํ•„์š”):**
2404
+ {chr(10).join([f"{i+1}. {flaw}" for i, flaw in enumerate(basic_flaws)])}
2405
+
2406
+ **์š”์ฒญ์‚ฌํ•ญ:**
2407
+ 1. ์‹ค์ œ ์ด๋ฏธ์ง€์— ์—†๋Š” ํŠน์„ฑ(์˜ˆ: ์†์žก์ด ์—†๋Š”๋ฐ ์†์žก์ด ๊ฑฑ์ •)์€ ์ œ๊ฑฐํ•˜๊ณ  ์‹ค์ œ ํŠน์„ฑ์œผ๋กœ ๋Œ€์ฒด
2408
+ 2. ๊ตฌ์ฒด์ ์ธ ์žฌ์งˆ, ์ƒ‰์ƒ, ํฌ๊ธฐ, ํ˜•ํƒœ๋ฅผ ๋ฐ˜์˜ํ•œ ๊ฑฑ์ •๊ฑฐ๋ฆฌ๋กœ ๋ณ€๊ฒฝ
2409
+ 3. ํŠน์ง•์  ์š”์†Œ๋“ค์„ ํ™œ์šฉํ•œ ๊ฐœ์„ฑ ์žˆ๋Š” ๊ฒฐํ•จ์œผ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ
2410
+ 4. ๊ฐ ๊ฒฐํ•จ์€ 15-30์ž ๋‚ด์™ธ๋กœ ๊ตฌ์ฒด์ ์ด๊ณ  ๋งค๋ ฅ์ ์œผ๋กœ
2411
+
2412
+ **์˜ˆ์‹œ:**
2413
+ - "์†์žก์ด๊ฐ€ ํŽธํ•œ์ง€ ์‹ ๊ฒฝ ์“ฐ์ž„" โ†’ (์†์žก์ด ์—†์œผ๋ฉด) "๋‘ฅ๊ทผ ๋ชจ์–‘์ด๋ผ ๋ฏธ๋„๋Ÿฌ์ ธ ๋–จ์–ด์งˆ๊นŒ ๋ด ๊ฑฑ์ •"
2414
+ - "์ƒ‰์ด ๋ฐ”๋ž„๊นŒ ๊ฑฑ์ •" โ†’ "ํŒŒ๋ž€์ƒ‰์ด ๋„ˆ๋ฌด ์„ ๋ช…ํ•ด์„œ ํŠ€์–ด ๋ณด์ผ๊นŒ ๊ฑฑ์ •"
2415
+
2416
+ ๊ฐœ์„ ๋œ ๋งค๋ ฅ์  ๊ฒฐํ•จ 4๊ฐœ๋ฅผ ๋ฒˆํ˜ธ ์—†์ด ์ค„๋ฐ”๊ฟˆ์œผ๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ƒ์„ฑ:
2417
+ """
2418
+
2419
+ # AI๋กœ ๊ฒฐํ•จ ๊ตฌ์ฒดํ™”
2420
+ refined_flaws_text = persona_generator._generate_text_with_api(ai_prompt)
2421
+
2422
+ if refined_flaws_text and len(refined_flaws_text.strip()) > 20:
2423
+ refined_flaws = []
2424
+ lines = refined_flaws_text.strip().split('\n')
2425
+ for line in lines:
2426
+ cleaned_line = line.strip().lstrip('1234567890.-โ€ข ')
2427
+ if cleaned_line and len(cleaned_line) > 5:
2428
+ refined_flaws.append(cleaned_line)
2429
+
2430
+ if len(refined_flaws) >= 4:
2431
+ final_flaws = refined_flaws[:4]
2432
+ else:
2433
+ # ๋ถ€์กฑํ•˜๋ฉด ๊ธฐ๋ณธ ๊ฒฐํ•จ์œผ๋กœ ์ฑ„์šฐ๊ธฐ
2434
+ final_flaws = refined_flaws + basic_flaws[len(refined_flaws):4]
2435
+ else:
2436
+ final_flaws = basic_flaws
2437
+
2438
+ # ๋ชจ์ˆœ์  ํŠน์„ฑ๋„ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ๊ตฌ์ฒดํ™”
2439
+ contradiction_prompt = f"""
2440
+ ๋‹ค์Œ ๊ธฐ๋ณธ ๋ชจ์ˆœ์  ํŠน์„ฑ๋“ค์„ ์‹ค์ œ ์ด๋ฏธ์ง€ ํŠน์„ฑ์— ๋งž๊ฒŒ ๊ตฌ์ฒดํ™”ํ•ด์ฃผ์„ธ์š”.
2441
+
2442
+ **์‹ค์ œ ์ด๋ฏธ์ง€:**
2443
+ {object_type} - {shape}, {size}, {', '.join(materials)}, {', '.join(colors)}
2444
+ ํŠน์ง•: {', '.join(distinctive_features)}
2445
+
2446
+ **๊ธฐ๋ณธ ๋ชจ์ˆœ๋“ค:**
2447
+ {chr(10).join([f"{i+1}. {cont}" for i, cont in enumerate(basic_contradictions)])}
2448
+
2449
+ ์‹ค์ œ ํŠน์„ฑ์„ ๋ฐ˜์˜ํ•œ ๊ตฌ์ฒด์ ์ธ ๋ชจ์ˆœ 2๊ฐœ๋ฅผ ์ƒ์„ฑ:
2450
+ """
2451
+
2452
+ refined_contradictions_text = persona_generator._generate_text_with_api(contradiction_prompt)
2453
+
2454
+ if refined_contradictions_text and len(refined_contradictions_text.strip()) > 20:
2455
+ refined_contradictions = []
2456
+ lines = refined_contradictions_text.strip().split('\n')
2457
+ for line in lines:
2458
+ cleaned_line = line.strip().lstrip('1234567890.-โ€ข ')
2459
+ if cleaned_line and len(cleaned_line) > 5:
2460
+ refined_contradictions.append(cleaned_line)
2461
+
2462
+ if len(refined_contradictions) >= 2:
2463
+ final_contradictions = refined_contradictions[:2]
2464
+ else:
2465
+ final_contradictions = refined_contradictions + basic_contradictions[len(refined_contradictions):2]
2466
+ else:
2467
+ final_contradictions = basic_contradictions
2468
+
2469
+ print(f"๐ŸŽจ AI๊ฐ€ ์ด๋ฏธ์ง€ ํŠน์„ฑ ๋ฐ˜์˜ํ•˜์—ฌ ๊ฒฐํ•จ/๋ชจ์ˆœ ๊ตฌ์ฒดํ™” ์™„๋ฃŒ")
2470
+ return final_flaws, final_contradictions
2471
+
2472
+ except Exception as e:
2473
+ print(f"โš ๏ธ AI ๊ตฌ์ฒดํ™” ์‹คํŒจ: {e} - ๊ธฐ๋ณธ ๊ฒฐํ•จ ์‚ฌ์šฉ")
2474
+ return basic_flaws, basic_contradictions
2475
+
2476
  if __name__ == "__main__":
2477
  app = create_main_interface()
2478
  app.launch(server_name="0.0.0.0", server_port=7860)
app_backup.py CHANGED
The diff for this file is too large to render. See raw diff