aiqtech commited on
Commit
0fe4bd9
ยท
verified ยท
1 Parent(s): 4de02f0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +1625 -0
app.py ADDED
@@ -0,0 +1,1625 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import json
4
+ import requests
5
+ from datetime import datetime
6
+ import time
7
+ from typing import List, Dict, Any, Generator, Tuple
8
+ import logging
9
+ import re
10
+
11
+ # ๋กœ๊น… ์„ค์ •
12
+ logging.basicConfig(level=logging.INFO)
13
+ logger = logging.getLogger(__name__)
14
+
15
+ # ์ถ”๊ฐ€ ์ž„ํฌํŠธ
16
+ from bs4 import BeautifulSoup
17
+ from urllib.parse import urlparse
18
+ import urllib.request
19
+
20
+ # Gemini API ์ž„ํฌํŠธ
21
+ try:
22
+ from google import genai
23
+ from google.genai import types
24
+ GEMINI_AVAILABLE = True
25
+ except ImportError:
26
+ GEMINI_AVAILABLE = False
27
+ logger.warning("Google Gemini API๊ฐ€ ์„ค์น˜๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. pip install google-genai๋กœ ์„ค์น˜ํ•˜์„ธ์š”.")
28
+
29
+ # ํ™˜๊ฒฝ ๋ณ€์ˆ˜์—์„œ ํ† ํฐ ๊ฐ€์ ธ์˜ค๊ธฐ
30
+ FRIENDLI_TOKEN = os.getenv("FRIENDLI_TOKEN", "YOUR_FRIENDLI_TOKEN")
31
+ BAPI_TOKEN = os.getenv("BAPI_TOKEN", "YOUR_BRAVE_API_TOKEN")
32
+ GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "YOUR_GEMINI_API_KEY")
33
+ API_URL = "https://api.friendli.ai/dedicated/v1/chat/completions"
34
+ BRAVE_SEARCH_URL = "https://api.search.brave.com/res/v1/web/search"
35
+ MODEL_ID = "dep89a2fld32mcm"
36
+ TEST_MODE = os.getenv("TEST_MODE", "false").lower() == "true"
37
+
38
+ # ์ „์—ญ ๋ณ€์ˆ˜
39
+ conversation_history = []
40
+
41
+ class WuxingLLMSystem:
42
+ """์˜คํ–‰ยท์˜ค์ƒ ๊ธฐ๋ฐ˜ AGI๊ธ‰ ํ˜‘๋ ฅ์  ๋ณด๊ณ ์„œ ์ž‘์„ฑ ์‹œ์Šคํ…œ - ์ƒ๊ทน(็›ธๅ‰‹) ์›๋ฆฌ ์ ์šฉ"""
43
+
44
+ def __init__(self):
45
+ self.token = FRIENDLI_TOKEN
46
+ self.bapi_token = BAPI_TOKEN
47
+ self.gemini_api_key = GEMINI_API_KEY
48
+ self.api_url = API_URL
49
+ self.brave_url = BRAVE_SEARCH_URL
50
+ self.model_id = MODEL_ID
51
+ self.test_mode = TEST_MODE or (self.token == "YOUR_FRIENDLI_TOKEN")
52
+ self.use_gemini = False
53
+ self.gemini_client = None
54
+
55
+ # ์˜คํ–‰ ์—ญํ•  ์ •์˜ - AGI ์ˆ˜์ค€ ์ „๋ฌธ๊ฐ€ ํŒ€
56
+ self.wuxing_roles = {
57
+ "wood": {
58
+ "name": "์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž (Chief Vision Officer)",
59
+ "virtue": "ไป",
60
+ "element": "ๆœจ",
61
+ "traits": "ํ†ต์ฐฐ๋ ฅ, ๋ฏธ๋ž˜์˜ˆ์ธก, ํฌ์šฉ์  ๋ฆฌ๋”์‹ญ",
62
+ "expertise": "๊ฑฐ์‹œ์  ๋น„์ „, ์‹œ์Šคํ…œ์  ์‚ฌ๊ณ , ํ˜์‹  ์ „๋žต, ์กฐ์ง ๋ฌธํ™” ์„ค๊ณ„",
63
+ "color": "#10b981",
64
+ "restrains": "ๅœŸ", # ๆœจๅ…‹ๅœŸ
65
+ "restrained_by": "้‡‘" # ้‡‘ๅ…‹ๆœจ
66
+ },
67
+ "fire": {
68
+ "name": "ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ (Innovation Strategy Architect)",
69
+ "virtue": "็พฉ",
70
+ "element": "็ซ",
71
+ "traits": "ํŒŒ๊ดด์  ํ˜์‹ , ์ „๋žต์  ์ง๊ด€, ๋ฆฌ์Šคํฌ ํ…Œ์ดํ‚น",
72
+ "expertise": "๋น„์ฆˆ๋‹ˆ์Šค ๋ชจ๋ธ ํ˜์‹ , ์‹œ์žฅ ํŒŒ๊ดด ์ „๋žต, ๊ฒฝ์Ÿ์šฐ์œ„ ์„ค๊ณ„",
73
+ "color": "#ef4444",
74
+ "restrains": "้‡‘", # ็ซๅ…‹้‡‘
75
+ "restrained_by": "ๆฐด" # ๆฐดๅ…‹็ซ
76
+ },
77
+ "metal": {
78
+ "name": "์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ (Systems Architecture Master)",
79
+ "virtue": "็ฆฎ",
80
+ "element": "้‡‘",
81
+ "traits": "์ •๋ฐ€์„ฑ, ์™„๋ฒฝ์ฃผ์˜, ์‹œ์Šคํ…œ ํ†ตํ•ฉ๋ ฅ",
82
+ "expertise": "์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์•„ํ‚คํ…์ฒ˜, ๊ธฐ์ˆ  ๊ฑฐ๋ฒ„๋„Œ์Šค, ํ‘œ์ค€ํ™” ์ „๋žต",
83
+ "color": "#f59e0b",
84
+ "restrains": "ๆœจ", # ้‡‘ๅ…‹ๆœจ
85
+ "restrained_by": "็ซ" # ็ซๅ…‹้‡‘
86
+ },
87
+ "water": {
88
+ "name": "๋ฏธ๋ž˜๊ธฐ์ˆ  ์—ฐ๊ตฌ์†Œ์žฅ (Future Tech Research Director)",
89
+ "virtue": "ๆ™บ",
90
+ "element": "ๆฐด",
91
+ "traits": "๊นŠ์€ ๋ถ„์„๋ ฅ, ๊ธฐ์ˆ  ํ†ต์ฐฐ, ํ˜์‹ ์  ์‚ฌ๊ณ ",
92
+ "expertise": "์‹ ๊ธฐ์ˆ  R&D, ๊ธฐ์ˆ  ์œตํ•ฉ, AI/ML, ํ€€ํ…€ ์ปดํ“จํŒ…",
93
+ "color": "#3b82f6",
94
+ "restrains": "็ซ", # ๆฐดๅ…‹็ซ
95
+ "restrained_by": "ๅœŸ" # ๅœŸๅ…‹ๆฐด
96
+ },
97
+ "earth": {
98
+ "name": "์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€ (Execution Excellence Expert)",
99
+ "virtue": "ไฟก",
100
+ "element": "ๅœŸ",
101
+ "traits": "์ฒด๊ณ„์„ฑ, ์‹ ๋ขฐ์„ฑ, ์‹คํ–‰ ์™„๋ฒฝ์„ฑ",
102
+ "expertise": "ํ”„๋กœ์ ํŠธ ๊ฑฐ๋ฒ„๋„Œ์Šค, ํ’ˆ์งˆ ์‹œ์Šคํ…œ, ๋ฆฌ์Šคํฌ ๊ด€๋ฆฌ, ROI ์ตœ์ ํ™”",
103
+ "color": "#a855f7",
104
+ "restrains": "ๆฐด", # ๅœŸๅ…‹ๆฐด
105
+ "restrained_by": "ๆœจ" # ๆœจๅ…‹ๅœŸ
106
+ }
107
+ }
108
+
109
+ if self.test_mode:
110
+ logger.warning("ํ…Œ์ŠคํŠธ ๋ชจ๋“œ๋กœ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.")
111
+
112
+ def set_llm_mode(self, mode: str):
113
+ """LLM ๋ชจ๋“œ ์„ค์ •"""
114
+ if mode == "commercial" and GEMINI_AVAILABLE and self.gemini_api_key != "YOUR_GEMINI_API_KEY":
115
+ self.use_gemini = True
116
+ if not self.gemini_client:
117
+ self.gemini_client = genai.Client(api_key=self.gemini_api_key)
118
+ logger.info("Gemini 2.5 Pro ๋ชจ๋“œ๋กœ ์ „ํ™˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
119
+ else:
120
+ self.use_gemini = False
121
+ logger.info("๊ธฐ๋ณธ LLM ๋ชจ๋“œ๋กœ ์ „ํ™˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
122
+
123
+ def create_headers(self):
124
+ """API ํ—ค๋” ์ƒ์„ฑ"""
125
+ return {
126
+ "Authorization": f"Bearer {self.token}",
127
+ "Content-Type": "application/json"
128
+ }
129
+
130
+ def create_brave_headers(self):
131
+ """Brave API ํ—ค๋” ์ƒ์„ฑ"""
132
+ return {
133
+ "Accept": "application/json",
134
+ "Accept-Encoding": "gzip",
135
+ "X-Subscription-Token": self.bapi_token
136
+ }
137
+
138
+ def create_wood_initial_prompt(self, user_query: str, search_results: Dict = None) -> str:
139
+ """ๆœจ(์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž) ์ดˆ๊ธฐ ํ”„๋กฌํ”„ํŠธ"""
140
+ search_info = ""
141
+ if search_results:
142
+ search_info = "\n\n์›น ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results)
143
+
144
+ return f"""๋‹น์‹ ์€ AGI ์ˆ˜์ค€์˜ ์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž(Chief Vision Officer)์ž…๋‹ˆ๋‹ค.
145
+ ไป(์ธ์žํ•จ)์˜ ๋•๋ชฉ์œผ๋กœ ๋ฏธ๋ž˜๋ฅผ ์˜ˆ์ธกํ•˜๊ณ  ํ˜์‹ ์  ๋น„์ „์„ ์ œ์‹œํ•ฉ๋‹ˆ๋‹ค.
146
+
147
+ [์‚ฌ์šฉ์ž ์š”์ฒญ์‚ฌํ•ญ]
148
+ {user_query}
149
+
150
+ [์ฐธ๊ณ  ์ž๋ฃŒ]
151
+ {search_info}
152
+
153
+ [์ž„๋ฌด] ๋‹ค์Œ ๊ด€์ ์—์„œ ์ข…ํ•ฉ์ ์ด๊ณ  ํ˜์‹ ์ ์ธ ๋น„์ „์„ ์ œ์‹œํ•˜์„ธ์š”:
154
+
155
+ 1. **๊ฑฐ์‹œ์  ๋น„์ „๊ณผ ํŒจ๋Ÿฌ๋‹ค์ž„ ์ „ํ™˜**
156
+ - 10๋…„ ํ›„ ๋ฏธ๋ž˜ ์‹œ๋‚˜๋ฆฌ์˜ค์™€ ๋ฉ”๊ฐ€ํŠธ๋ Œ๋“œ ๋ถ„์„
157
+ - ํŒจ๋Ÿฌ๋‹ค์ž„ ์‹œํ”„ํŠธ์™€ ๊ฒŒ์ž„์ฒด์ธ์ € ์š”์†Œ ์‹๋ณ„
158
+ - ๊ธ€๋กœ๋ฒŒ ๋งฅ๋ฝ์—์„œ์˜ ์ „๋žต์  ํฌ์ง€์…”๋‹
159
+
160
+ 2. **์‹œ์Šคํ…œ์  ์‚ฌ๊ณ ์™€ ๋ณต์žก๊ณ„ ๋ถ„์„**
161
+ - ๋‹ค์ฐจ์›์  ์ƒํ˜ธ์ž‘์šฉ๊ณผ ํ”ผ๋“œ๋ฐฑ ๋ฃจํ”„ ์„ค๊ณ„
162
+ - ์ฐฝ๋ฐœ์  ์†์„ฑ๊ณผ ๋„คํŠธ์›Œํฌ ํšจ๊ณผ ์˜ˆ์ธก
163
+ - ์ƒํƒœ๊ณ„ ๊ด€์ ์˜ ๊ฐ€์น˜ ์ฐฝ์ถœ ๋ชจ๋ธ
164
+
165
+ 3. **ํ˜์‹  ํ”„๋ ˆ์ž„์›Œํฌ์™€ ์ „๋žต์  ๋ฐฉํ–ฅ์„ฑ**
166
+ - ๋ธ”๋ฃจ์˜ค์…˜ ์ „๋žต๊ณผ ์นดํ…Œ๊ณ ๋ฆฌ ๋””์ž์ธ
167
+ - ์ง€์ˆ˜์  ์„ฑ์žฅ์„ ์œ„ํ•œ ํ”Œ๋ผ์ดํœ  ์„ค๊ณ„
168
+ - ์•ˆํ‹ฐํ”„๋ž˜์งˆํ•œ ์‹œ์Šคํ…œ ๊ตฌ์ถ• ๋ฐฉ์•ˆ
169
+
170
+ 4. **ํŒ€ ์‹œ๋„ˆ์ง€์™€ ์ง‘๋‹จ์ง€์„ฑ ํ™œ์šฉ ์ „๋žต**
171
+ - ็ซ(ํ˜์‹  ์ „๋žต): ํŒŒ๊ดด์  ํ˜์‹ ๊ณผ ๋น„์ฆˆ๋‹ˆ์Šค ๋ชจ๋ธ ์žฌ์ •์˜
172
+ - ๅœŸ(์‹คํ–‰ ์ตœ์ ํ™”): ์• ์ž์ผ ์‹คํ–‰๊ณผ ์ง€์†์  ๊ฐœ์„  ์ฒด๊ณ„
173
+ - ้‡‘(์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜): ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ๊ธฐ์ˆ  ์ธํ”„๋ผ์™€ ํ‘œ์ค€ํ™”
174
+ - ๆฐด(๋ฏธ๋ž˜๊ธฐ์ˆ  R&D): ์‹ ๊ธฐ์ˆ  ์œตํ•ฉ๊ณผ ํ˜์‹ ์  ํ”„๋กœํ† ํƒ€์ดํ•‘
175
+
176
+ 5. **ํ•ต์‹ฌ ์„ฑ๊ณต ์ง€ํ‘œ(KPI)์™€ ๋ถ๊ทน์„ฑ ์ง€ํ‘œ(North Star Metric)**
177
+ - ์žฅ๊ธฐ์  ์ž„ํŒฉํŠธ ์ธก์ • ํ”„๋ ˆ์ž„์›Œํฌ
178
+ - ์„ ํ–‰์ง€ํ‘œ์™€ ํ›„ํ–‰์ง€ํ‘œ์˜ ๊ท ํ˜•์žกํžŒ ์„ค๊ณ„
179
+
180
+ [๊ฒ€์ƒ‰ ํ‚ค์›Œ๋“œ ์ œ์•ˆ]: ๋ฏธ๋ž˜ ์—ฐ๊ตฌ์— ํ•„์š”ํ•œ 7-10๊ฐœ์˜ ์ „๋žต์  ํ‚ค์›Œ๋“œ๋ฅผ ์ œ์‹œํ•˜์„ธ์š”"""
181
+
182
+ def create_fire_strategy_prompt(self, user_query: str, wood_response: str, critic_feedback: str, search_results: Dict = None) -> str:
183
+ """็ซ(ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ) ํ”„๋กฌํ”„ํŠธ"""
184
+ search_info = ""
185
+ if search_results:
186
+ search_info = "\n\n์›น ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results)
187
+
188
+ return f"""๋‹น์‹ ์€ AGI ์ˆ˜์ค€์˜ ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ(Innovation Strategy Architect)์ž…๋‹ˆ๋‹ค.
189
+ ็พฉ(์ •์˜๋กœ์›€)์˜ ๋•๋ชฉ์œผ๋กœ ํŒŒ๊ดด์  ํ˜์‹ ๊ณผ ๊ฒŒ์ž„์ฒด์ธ์ง• ์ „๋žต์„ ์„ค๊ณ„ํ•ฉ๋‹ˆ๋‹ค.
190
+
191
+ [์‚ฌ์šฉ์ž ์š”์ฒญ์‚ฌํ•ญ]
192
+ {user_query}
193
+
194
+ [์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž์˜ ํ”„๋ ˆ์ž„์›Œํฌ]
195
+ {wood_response}
196
+
197
+ [์ „๋žต ๊ฒ€์ฆ ์ „๋ฌธ๊ฐ€์˜ ํ”ผ๋“œ๋ฐฑ]
198
+ {critic_feedback}
199
+
200
+ [์‹œ์žฅ ์กฐ์‚ฌ ๋ฐ์ดํ„ฐ]
201
+ {search_info}
202
+
203
+ [์ž„๋ฌด] ๋‹ค์Œ ๊ด€์ ์—์„œ ํ˜์‹ ์ ์ธ ์ „๋žต์„ ์ˆ˜๋ฆฝํ•˜์„ธ์š”:
204
+
205
+ 1. **ํŒŒ๊ดด์  ํ˜์‹ ๊ณผ ๋ธ”๋ฃจ์˜ค์…˜ ์ „๋žต**
206
+ - ์‚ฐ์—… ์žฌ์ •์˜์™€ ์นดํ…Œ๊ณ ๋ฆฌ ์ฐฝ์ถœ
207
+ - ๊ฐ€์น˜ ํ˜์‹ ๊ณผ ์ฐจ๋ณ„ํ™” ์ „๋žต
208
+ - ๋„คํŠธ์›Œํฌ ํšจ๊ณผ์™€ ํ”Œ๋žซํผ ์ „๋žต
209
+
210
+ 2. **๋น„์ฆˆ๋‹ˆ์Šค ๋ชจ๋ธ ํ˜์‹ **
211
+ - ์ˆ˜์ต ๋ชจ๋ธ ๋‹ค๊ฐํ™” (๊ตฌ๋…, ํ”„๋ฆฌ๋ฏธ์—„, ๋งˆ์ผ“ํ”Œ๋ ˆ์ด์Šค)
212
+ - ๊ฐ€์น˜์‚ฌ์Šฌ ์žฌ๊ตฌ์„ฑ๊ณผ ์ˆ˜์ง ํ†ตํ•ฉ
213
+ - ์ƒํƒœ๊ณ„ ๊ตฌ์ถ•๊ณผ ํŒŒํŠธ๋„ˆ์‹ญ ์ „๋žต
214
+
215
+ 3. **๊ฒฝ์Ÿ์šฐ์œ„ ํ™•๋ณด ์ „๋žต**
216
+ - ํ•ต์‹ฌ ์—ญ๋Ÿ‰๊ณผ ์ฐจ๋ณ„ํ™” ์š”์†Œ
217
+ - ์ง„์ž…์žฅ๋ฒฝ ๊ตฌ์ถ• ๋ฉ”์ปค๋‹ˆ์ฆ˜
218
+ - ์ง€์†๊ฐ€๋Šฅํ•œ ๊ฒฝ์Ÿ์šฐ์œ„ ์›์ฒœ
219
+
220
+ 4. **์„ฑ์žฅ ์ „๋žต๊ณผ ํ™•์žฅ ๊ณ„ํš**
221
+ - ์‹œ์žฅ ์นจํˆฌ์™€ ์‹œ์žฅ ๊ฐœ๋ฐœ ์ „๋žต
222
+ - ์ œํ’ˆ ๊ฐœ๋ฐœ๊ณผ ๋‹ค๊ฐํ™” ์ „๋žต
223
+ - M&A์™€ ์ „๋žต์  ์ œํœด ์˜ต์…˜
224
+
225
+ 5. **๋ฆฌ์Šคํฌ ๊ด€๋ฆฌ์™€ ์‹œ๋‚˜๋ฆฌ์˜ค ํ”Œ๋ž˜๋‹**
226
+ - ์ „๋žต์  ๋ฆฌ์Šคํฌ ๋งคํŠธ๋ฆญ์Šค
227
+ - ๋Œ€์‘ ์‹œ๋‚˜๋ฆฌ์˜ค์™€ ์ปจํ‹ด์ „์‹œ ํ”Œ๋žœ
228
+ - ์•ˆํ‹ฐํ”„๋ž˜์งˆํ•œ ์ „๋žต ์„ค๊ณ„
229
+
230
+ [์ถ”๊ฐ€ ์—ฐ๊ตฌ ํ•„์š”]: ๊ฒฝ์Ÿ์‚ฌ ๋ถ„์„, ์‹œ์žฅ ๋™ํ–ฅ, ๊ทœ์ œ ํ™˜๊ฒฝ ๋“ฑ ์ถ”๊ฐ€ ์กฐ์‚ฌ๊ฐ€ ํ•„์š”ํ•œ ํ‚ค์›Œ๋“œ [์ถ”๊ฐ€ ๊ฒ€์ƒ‰]"""
231
+
232
+ def create_earth_execution_prompt(self, user_query: str, fire_response: str, critic_feedback: str, search_results: Dict = None) -> str:
233
+ """ๅœŸ(์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€) ํ”„๋กฌํ”„ํŠธ"""
234
+ search_info = ""
235
+ if search_results:
236
+ search_info = "\n\n์›น ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results)
237
+
238
+ return f"""๋‹น์‹ ์€ AGI ์ˆ˜์ค€์˜ ์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€(Execution Excellence Expert)์ž…๋‹ˆ๋‹ค.
239
+ ไฟก(์‹ ๋ขฐ)์˜ ๋•๋ชฉ์œผ๋กœ ์™„๋ฒฝํ•œ ์‹คํ–‰ ์ฒด๊ณ„์™€ ํ’ˆ์งˆ ์‹œ์Šคํ…œ์„ ๊ตฌ์ถ•ํ•ฉ๋‹ˆ๋‹ค.
240
+
241
+ [์‚ฌ์šฉ์ž ์š”์ฒญ์‚ฌํ•ญ]
242
+ {user_query}
243
+
244
+ [ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ์˜ ์ „๋žต]
245
+ {fire_response}
246
+
247
+ [์ „๋žต ๊ฒ€์ฆ ์ „๋ฌธ๊ฐ€์˜ ํ”ผ๋“œ๋ฐฑ]
248
+ {critic_feedback}
249
+
250
+ [์‹คํ–‰ ๊ด€๋ จ ๋ฒค์น˜๋งˆํฌ ๋ฐ์ดํ„ฐ]
251
+ {search_info}
252
+
253
+ [์ž„๋ฌด] ๋‹ค์Œ ๊ด€์ ์—์„œ ์ตœ์ ํ™”๋œ ์‹คํ–‰ ๊ณ„ํš์„ ์ˆ˜๋ฆฝํ•˜์„ธ์š”:
254
+
255
+ 1. **ํ”„๋กœ์ ํŠธ ๊ฑฐ๋ฒ„๋„Œ์Šค์™€ PMO ์ฒด๊ณ„**
256
+ - ์• ์ž์ผ/์›Œํ„ฐํด ํ•˜์ด๋ธŒ๋ฆฌ๋“œ ๋ฐฉ๋ฒ•๋ก 
257
+ - RACI ๋งคํŠธ๋ฆญ์Šค์™€ ์˜์‚ฌ๊ฒฐ์ • ๊ตฌ์กฐ
258
+ - ํ”„๋กœ์ ํŠธ ํฌํŠธํด๋ฆฌ์˜ค ๊ด€๋ฆฌ
259
+
260
+ 2. **๋‹จ๊ณ„๋ณ„ ์‹คํ–‰ ๋กœ๋“œ๋งต**
261
+ - ์›Œํฌ ๋ธŒ๋ ˆ์ดํฌ๋‹ค์šด ์ŠคํŠธ๋Ÿญ์ฒ˜(WBS)
262
+ - ํฌ๋ฆฌํ‹ฐ์ปฌ ํŒจ์Šค์™€ ๋งˆ์ผ์Šคํ†ค
263
+ - ์Šคํ”„๋ฆฐํŠธ ๊ณ„ํš๊ณผ ๋ฐฑ๋กœ๊ทธ ๊ด€๋ฆฌ
264
+
265
+ 3. **๋ฆฌ์†Œ์Šค ์ตœ์ ํ™”์™€ ์˜ˆ์‚ฐ ๊ด€๋ฆฌ**
266
+ - ์ธ๋ ฅ ๋ฐฐ์น˜์™€ ์Šคํ‚ฌ ๋งคํŠธ๋ฆญ์Šค
267
+ - TCO ๋ถ„์„๊ณผ ์˜ˆ์‚ฐ ๋ฐฐ๋ถ„
268
+ - ๋น„์šฉ ์ตœ์ ํ™” ์ „๋žต
269
+
270
+ 4. **ํ’ˆ์งˆ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ**
271
+ - ISO 9001/27001 ๊ธฐ๋ฐ˜ ํ’ˆ์งˆ ์ฒด๊ณ„
272
+ - KPI/OKR ํ”„๋ ˆ์ž„์›Œํฌ
273
+ - ์ง€์†์  ๊ฐœ์„ (Kaizen) ๋ฉ”์ปค๋‹ˆ์ฆ˜
274
+
275
+ 5. **๋ฆฌ์Šคํฌ ๊ด€๋ฆฌ์™€ ๋ณ€ํ™” ๊ด€๋ฆฌ**
276
+ - ๋ฆฌ์Šคํฌ ๋ ˆ์ง€์Šคํ„ฐ์™€ ์™„ํ™” ์ „๋žต
277
+ - ๋ณ€ํ™” ๊ด€๋ฆฌ 8๋‹จ๊ณ„ ํ”„๋กœ์„ธ์Šค
278
+ - ์ดํ•ด๊ด€๊ณ„์ž ๊ด€๋ฆฌ ์ „๋žต
279
+
280
+ 6. **์„ฑ๊ณผ ์ธก์ •๊ณผ ๋Œ€์‹œ๋ณด๋“œ**
281
+ - ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋ง ์‹œ์Šคํ…œ
282
+ - ๊ท ํ˜•์„ฑ๊ณผํ‘œ(BSC) ์„ค๊ณ„
283
+ - ์˜ˆ์ธก ๋ถ„์„๊ณผ ์กฐ๊ธฐ ๊ฒฝ๋ณด ์‹œ์Šคํ…œ
284
+
285
+ [์ถ”๊ฐ€ ์กฐ์‚ฌ ํ•„์š”]: ์—…๊ณ„ ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค, ์‹คํ–‰ ๋„๊ตฌ, ํ’ˆ์งˆ ํ‘œ์ค€ ๋“ฑ [์ถ”๊ฐ€ ๊ฒ€์ƒ‰]"""
286
+
287
+ def create_metal_architecture_prompt(self, user_query: str, earth_response: str, critic_feedback: str, search_results: Dict = None) -> str:
288
+ """้‡‘(์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ) ํ”„๋กฌํ”„ํŠธ"""
289
+ search_info = ""
290
+ if search_results:
291
+ search_info = "\n\n์›น ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results)
292
+
293
+ return f"""๋‹น์‹ ์€ AGI ์ˆ˜์ค€์˜ ์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ(Systems Architecture Master)์ž…๋‹ˆ๋‹ค.
294
+ ็ฆฎ(์˜ˆ์˜ยท์งˆ์„œ)์˜ ๋•๋ชฉ์œผ๋กœ ์™„๋ฒฝํ•˜๊ณ  ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ์‹œ์Šคํ…œ์„ ์„ค๊ณ„ํ•ฉ๋‹ˆ๋‹ค.
295
+
296
+ [์‚ฌ์šฉ์ž ์š”์ฒญ์‚ฌํ•ญ]
297
+ {user_query}
298
+
299
+ [์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€์˜ ๊ณ„ํš]
300
+ {earth_response}
301
+
302
+ [์ „๋žต ๊ฒ€์ฆ ์ „๋ฌธ๊ฐ€์˜ ํ”ผ๋“œ๋ฐฑ]
303
+ {critic_feedback}
304
+
305
+ [๊ธฐ์ˆ  ์•„ํ‚คํ…์ฒ˜ ์ฐธ๊ณ  ์ž๋ฃŒ]
306
+ {search_info}
307
+
308
+ [์ž„๋ฌด] ๋‹ค์Œ ๊ด€์ ์—์„œ ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ๊ธ‰ ์•„ํ‚คํ…์ฒ˜๋ฅผ ์„ค๊ณ„ํ•˜์„ธ์š”:
309
+
310
+ 1. **์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์•„ํ‚คํ…์ฒ˜ ํ”„๋ ˆ์ž„์›Œํฌ**
311
+ - TOGAF/Zachman ๊ธฐ๋ฐ˜ ์„ค๊ณ„
312
+ - ๋น„์ฆˆ๋‹ˆ์Šค/์• ํ”Œ๋ฆฌ์ผ€์ด์…˜/๋ฐ์ดํ„ฐ/๊ธฐ์ˆ  ์•„ํ‚คํ…์ฒ˜
313
+ - ์•„ํ‚คํ…์ฒ˜ ๊ฑฐ๋ฒ„๋„Œ์Šค์™€ ์›์น™
314
+
315
+ 2. **๊ธฐ์ˆ  ์Šคํƒ๊ณผ ํ”Œ๋žซํผ ์ „๋žต**
316
+ - ํด๋ผ์šฐ๋“œ ๋„ค์ดํ‹ฐ๋ธŒ ์•„ํ‚คํ…์ฒ˜ (AWS/Azure/GCP)
317
+ - ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค์™€ ์ปจํ…Œ์ด๋„ˆํ™”
318
+ - API ์šฐ์„  ์„ค๊ณ„์™€ ์ด๋ฒคํŠธ ๊ธฐ๋ฐ˜ ์•„ํ‚คํ…์ฒ˜
319
+
320
+ 3. **๋ฐ์ดํ„ฐ ์•„ํ‚คํ…์ฒ˜์™€ ๊ฑฐ๋ฒ„๋„Œ์Šค**
321
+ - ๋ฐ์ดํ„ฐ ๋ ˆ์ดํฌํ•˜์šฐ์Šค ์„ค๊ณ„
322
+ - ๋งˆ์Šคํ„ฐ ๋ฐ์ดํ„ฐ ๊ด€๋ฆฌ(MDM)
323
+ - ๋ฐ์ดํ„ฐ ํ’ˆ์งˆ๊ณผ ๋ฆฌ๋‹ˆ์ง€ ๊ด€๋ฆฌ
324
+
325
+ 4. **๋ณด์•ˆ ์•„ํ‚คํ…์ฒ˜์™€ ์ปดํ”Œ๋ผ์ด์–ธ์Šค**
326
+ - ์ œ๋กœ ํŠธ๋Ÿฌ์ŠคํŠธ ๋ณด์•ˆ ๋ชจ๋ธ
327
+ - IAM๊ณผ ์ ‘๊ทผ ์ œ์–ด ์ฒด๊ณ„
328
+ - GDPR/SOC2 ์ปดํ”Œ๋ผ์ด์–ธ์Šค
329
+
330
+ 5. **ํ™•์žฅ์„ฑ๊ณผ ์„ฑ๋Šฅ ์ตœ์ ํ™”**
331
+ - ์ˆ˜ํ‰/์ˆ˜์ง ํ™•์žฅ ์ „๋žต
332
+ - ์บ์‹ฑ๊ณผ CDN ์ „๋žต
333
+ - ์„ฑ๋Šฅ ๋ชจ๋‹ˆํ„ฐ๋ง๊ณผ ํŠœ๋‹
334
+
335
+ 6. **๊ธฐ์ˆ  ํ‘œ์ค€๊ณผ ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค**
336
+ - ์ฝ”๋”ฉ ํ‘œ์ค€๊ณผ ๋””์ž์ธ ํŒจํ„ด
337
+ - CI/CD ํŒŒ์ดํ”„๋ผ์ธ
338
+ - ๊ธฐ์ˆ  ๋ถ€์ฑ„ ๊ด€๋ฆฌ ์ „๋žต
339
+
340
+ [์ถ”๊ฐ€ ์กฐ์‚ฌ ํ•„์š”]: ์ตœ์‹  ๊ธฐ์ˆ  ํŠธ๋ Œ๋“œ, ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด, ๋ณด์•ˆ ํ‘œ์ค€ ๋“ฑ [์ถ”๊ฐ€ ๊ฒ€์ƒ‰]"""
341
+
342
+ def create_water_rd_prompt(self, user_query: str, metal_response: str, critic_feedback: str, search_results: Dict = None) -> str:
343
+ """ๆฐด(๋ฏธ๋ž˜๊ธฐ์ˆ  ์—ฐ๊ตฌ์†Œ์žฅ) ํ”„๋กฌํ”„ํŠธ"""
344
+ search_info = ""
345
+ if search_results:
346
+ search_info = "\n\n์ตœ์‹  ๊ธฐ์ˆ  ์กฐ์‚ฌ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results)
347
+
348
+ return f"""๋‹น์‹ ์€ AGI ์ˆ˜์ค€์˜ ๋ฏธ๋ž˜๊ธฐ์ˆ  ์—ฐ๊ตฌ์†Œ์žฅ(Future Tech Research Director)์ž…๋‹ˆ๋‹ค.
349
+ ๆ™บ(์ง€ํ˜œ)์˜ ๋•๋ชฉ์œผ๋กœ ์ตœ์ฒจ๋‹จ ๊ธฐ์ˆ ์„ ์—ฐ๊ตฌํ•˜๊ณ  ํ˜์‹ ์„ ์ฃผ๋„ํ•ฉ๋‹ˆ๋‹ค.
350
+
351
+ [์‚ฌ์šฉ์ž ์š”์ฒญ์‚ฌํ•ญ]
352
+ {user_query}
353
+
354
+ [์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ์˜ ์„ค๊ณ„]
355
+ {metal_response}
356
+
357
+ [์ „๋žต ๊ฒ€์ฆ ์ „๋ฌธ๊ฐ€์˜ ํ”ผ๋“œ๋ฐฑ]
358
+ {critic_feedback}
359
+
360
+ [๊ธ€๋กœ๋ฒŒ ๊ธฐ์ˆ  ํŠธ๋ Œ๋“œ ๋ถ„์„]
361
+ {search_info}
362
+
363
+ [์ž„๋ฌด] ๋‹ค์Œ ๊ด€์ ์—์„œ ๋ฏธ๋ž˜ ์ง€ํ–ฅ์  R&D ์ „๋žต์„ ์ˆ˜๋ฆฝํ•˜์„ธ์š”:
364
+
365
+ 1. **์‹ ๊ธฐ์ˆ  ํŠธ๋ Œ๋“œ์™€ ๊ธฐ์ˆ  ์œตํ•ฉ**
366
+ - AI/ML/๋”ฅ๋Ÿฌ๋‹ ์ตœ์‹  ๋™ํ–ฅ
367
+ - ํ€€ํ…€ ์ปดํ“จํŒ…๊ณผ ์—ฃ์ง€ ์ปดํ“จํŒ…
368
+ - ๋ธ”๋ก์ฒด์ธ๊ณผ Web3 ๊ธฐ์ˆ 
369
+ - ๋ฉ”ํƒ€๋ฒ„์Šค์™€ XR ๊ธฐ์ˆ 
370
+
371
+ 2. **ํ˜์‹ ์  ํ”„๋กœํ† ํƒ€์ดํ•‘ ์ „๋žต**
372
+ - MVP์™€ ๋น ๋ฅธ ์‹คํ—˜ ์ฃผ๊ธฐ
373
+ - A/B ํ…Œ์ŠคํŒ…๊ณผ ๋ฐ์ดํ„ฐ ๊ธฐ๋ฐ˜ ์˜์‚ฌ๊ฒฐ์ •
374
+ - ์˜คํ”ˆ ์ด๋…ธ๋ฒ ์ด์…˜๊ณผ ํ•ด์ปคํ†ค
375
+
376
+ 3. **AI/ML ํ†ตํ•ฉ ์ „๋žต**
377
+ - LLM๊ณผ ์ƒ์„ฑํ˜• AI ํ™œ์šฉ
378
+ - MLOps์™€ ๋ชจ๋ธ ๊ฑฐ๋ฒ„๋„Œ์Šค
379
+ - ์„ค๋ช… ๊ฐ€๋Šฅํ•œ AI(XAI)
380
+ - ์œค๋ฆฌ์  AI ๊ฐ€์ด๋“œ๋ผ์ธ
381
+
382
+ 4. **์ž๋™ํ™”์™€ ์ƒ์‚ฐ์„ฑ ํ˜์‹ **
383
+ - RPA์™€ ํ•˜์ดํผ์˜คํ† ๋ฉ”์ด์…˜
384
+ - Low-code/No-code ํ”Œ๋žซํผ
385
+ - DevOps์™€ GitOps
386
+ - ์ง€๋Šฅํ˜• ๋ชจ๋‹ˆํ„ฐ๋ง ์‹œ์Šคํ…œ
387
+
388
+ 5. **๊ธฐ์ˆ  ROI์™€ ํ˜์‹  ํฌํŠธํด๋ฆฌ์˜ค**
389
+ - ๊ธฐ์ˆ  ํˆฌ์ž ์šฐ์„ ์ˆœ์œ„ ๋งคํŠธ๋ฆญ์Šค
390
+ - ํ˜์‹  ํšŒ๊ณ„์™€ ์„ฑ๊ณผ ์ธก์ •
391
+ - ๊ธฐ์ˆ  ํŒŒํŠธ๋„ˆ์‹ญ ์ „๋žต
392
+
393
+ 6. **๋ฏธ๋ž˜ ์ค€๋น„๋„์™€ ๊ธฐ์ˆ  ๋กœ๋“œ๋งต**
394
+ - 3-5๋…„ ๊ธฐ์ˆ  ๋น„์ „
395
+ - ๊ธฐ์ˆ  ์—ญ๋Ÿ‰ ๊ฐœ๋ฐœ ๊ณ„ํš
396
+ - ๋””์ง€ํ„ธ ํŠธ๋žœ์Šคํฌ๋ฉ”์ด์…˜ ์„ฑ์ˆ™๋„
397
+
398
+ [์ถ”๊ฐ€ ์—ฐ๏ฟฝ๏ฟฝ๏ฟฝ ํ•„์š”]: Gartner Hype Cycle, MIT Tech Review, ํŠนํ—ˆ ๋™ํ–ฅ ๋“ฑ [์ถ”๊ฐ€ ๊ฒ€์ƒ‰]"""
399
+
400
+ def create_wood_final_prompt(self, user_query: str, all_responses: Dict, all_critics: List) -> str:
401
+ """ๆœจ(์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž) ์ตœ์ข… ์ข…ํ•ฉ ๋ณด๊ณ ์„œ ํ”„๋กฌํ”„ํŠธ"""
402
+ return f"""๋‹น์‹ ์€ AGI ์ˆ˜์ค€์˜ ์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž์ž…๋‹ˆ๋‹ค.
403
+ ํŒ€ ์ „์ฒด์˜ ์ง‘๋‹จ์ง€์„ฑ์„ ์ข…ํ•ฉํ•˜์—ฌ ์ตœ๊ณ  ์ˆ˜์ค€์˜ ์ „๋ฌธ ๋ณด๊ณ ์„œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.
404
+
405
+ [์‚ฌ์šฉ์ž ์š”์ฒญ์‚ฌํ•ญ]
406
+ {user_query}
407
+
408
+ [ํŒ€์› ๊ธฐ์—ฌ ๋‚ด์šฉ]
409
+ โ–ถ ็ซ(ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ): {all_responses['fire']}
410
+ โ–ถ ๅœŸ(์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€): {all_responses['earth']}
411
+ โ–ถ ้‡‘(์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ): {all_responses['metal']}
412
+ โ–ถ ๆฐด(๋ฏธ๋ž˜๊ธฐ์ˆ  ์—ฐ๊ตฌ์†Œ์žฅ): {all_responses['water']}
413
+
414
+ [๋น„ํ‰์ž ํ†ต์ฐฐ]
415
+ {self._format_critic_history(all_critics)}
416
+
417
+ [์ตœ์ข… ์ข…ํ•ฉ ๋ณด๊ณ ์„œ ์ž‘์„ฑ ์ง€์นจ]
418
+
419
+ ๋‹ค์Œ ๊ตฌ์กฐ๋กœ ์ตœ๊ณ  ์ˆ˜์ค€์˜ ์ „๋ฌธ ๋ณด๊ณ ์„œ๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”:
420
+
421
+ # EXECUTIVE SUMMARY
422
+ - ํ•ต์‹ฌ ๊ถŒ๊ณ ์‚ฌํ•ญ (3-5๊ฐœ ๋ถˆ๋ฆฟํฌ์ธํŠธ)
423
+ - ์˜ˆ์ƒ ์ž„ํŒฉํŠธ์™€ ROI
424
+ - ์ฆ‰์‹œ ์‹คํ–‰ ๊ฐ€๋Šฅํ•œ Quick Wins
425
+
426
+ # 1. ์ „๋žต์  ๋ถ„์„๊ณผ ๋น„์ „
427
+ ## 1.1 ํ˜„ํ™ฉ ์ง„๋‹จ๊ณผ ๊ธฐํšŒ ๋ถ„์„
428
+ - SWOT-TOWS ๋งคํŠธ๋ฆญ์Šค
429
+ - ํฌํ„ฐ์˜ 5 Forces + ๋””์ง€ํ„ธ ์ „ํ™˜ ์˜ํ–ฅ
430
+ - ๊ฐ€์น˜์‚ฌ์Šฌ ๋ถ„์„๊ณผ ์žฌ์ •์˜ ๊ธฐํšŒ
431
+
432
+ ## 1.2 ๋ฏธ๋ž˜ ์‹œ๋‚˜๋ฆฌ์˜ค์™€ ์ „๋žต์  ์˜ต์…˜
433
+ - ์‹œ๋‚˜๋ฆฌ์˜ค ํ”Œ๋ž˜๋‹ (์ตœ์ /ํ˜„์‹ค์ /์ตœ์•…)
434
+ - ์ „๋žต์  ์˜ต์…˜๊ณผ ์˜์‚ฌ๊ฒฐ์ • ํŠธ๋ฆฌ
435
+ - ๋ฆฌ์Šคํฌ-๋ฆฌํ„ด ํ”„๋กœํŒŒ์ผ
436
+
437
+ # 2. ํ˜์‹  ์ „๋žต๊ณผ ์‹คํ–‰ ๋กœ๋“œ๋งต
438
+ ## 2.1 ํ˜์‹  ํ”„๋ ˆ์ž„์›Œํฌ
439
+ - ํ˜์‹  ํฌํŠธํด๋ฆฌ์˜ค (Horizon 1-2-3)
440
+ - ๋””์ง€ํ„ธ ์ „ํ™˜ ์„ฑ์ˆ™๋„ ๋ชจ๋ธ
441
+ - ์˜คํ”ˆ ์ด๋…ธ๋ฒ ์ด์…˜ ์ „๋žต
442
+
443
+ ## 2.2 ๋‹จ๊ณ„๋ณ„ ์‹คํ–‰ ๋กœ๋“œ๋งต
444
+ - Phase 1 (0-6๊ฐœ์›”): ๊ธฐ๋ฐ˜ ๊ตฌ์ถ•
445
+ - Phase 2 (6-18๊ฐœ์›”): ํ™•์žฅ๊ณผ ์ตœ์ ํ™”
446
+ - Phase 3 (18-36๊ฐœ์›”): ํ˜์‹ ๊ณผ ์„ฑ์žฅ
447
+ - ๊ฐ ๋‹จ๊ณ„๋ณ„ ๋งˆ์ผ์Šคํ†ค๊ณผ KPI
448
+
449
+ # 3. ๊ธฐ์ˆ  ์•„ํ‚คํ…์ฒ˜์™€ ์ธํ”„๋ผ
450
+ ## 3.1 ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์•„ํ‚คํ…์ฒ˜
451
+ - ํ˜„์žฌ ์ƒํƒœ(AS-IS)์™€ ๋ชฉํ‘œ ์ƒํƒœ(TO-BE)
452
+ - ๊ธฐ์ˆ  ์Šคํƒ๊ณผ ํ”Œ๋žซํผ ์ „๋žต
453
+ - ๋ฐ์ดํ„ฐ ๊ฑฐ๋ฒ„๋„Œ์Šค์™€ ๋ณด์•ˆ ์•„ํ‚คํ…์ฒ˜
454
+
455
+ ## 3.2 ํ™•์žฅ์„ฑ๊ณผ ๋ฏธ๋ž˜ ๋Œ€์‘
456
+ - ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค์™€ ํด๋ผ์šฐ๋“œ ๋„ค์ดํ‹ฐ๋ธŒ
457
+ - AI/ML ํ†ตํ•ฉ ์ „๋žต
458
+ - ๊ธฐ์ˆ  ๋ถ€์ฑ„ ๊ด€๋ฆฌ์™€ ํ˜„๋Œ€ํ™” ๊ณ„ํš
459
+
460
+ # 4. ์‹คํ–‰ ๊ณ„ํš๊ณผ ๊ฑฐ๋ฒ„๋„Œ์Šค
461
+ ## 4.1 ์กฐ์ง๊ณผ ๊ฑฐ๋ฒ„๋„Œ์Šค
462
+ - ๋ณ€ํ™”๊ด€๋ฆฌ ์ „๋žต
463
+ - ์• ์ž์ผ ๊ฑฐ๋ฒ„๋„Œ์Šค ๊ตฌ์กฐ
464
+ - ์—ญ๋Ÿ‰ ๊ฐœ๋ฐœ๊ณผ ์ธ์žฌ ํ™•๋ณด
465
+
466
+ ## 4.2 ํˆฌ์ž์™€ ์žฌ๋ฌด ๋ถ„์„
467
+ - TCO์™€ ROI ๋ถ„์„
468
+ - ์ž๊ธˆ ์กฐ๋‹ฌ ์˜ต์…˜
469
+ - ์žฌ๋ฌด ๋ฆฌ์Šคํฌ ๊ด€๋ฆฌ
470
+
471
+ # 5. ์„ฑ๊ณผ ์ธก์ •๊ณผ ์ง€์†๊ฐ€๋Šฅ์„ฑ
472
+ ## 5.1 ์„ฑ๊ณผ ์ธก์ • ํ”„๋ ˆ์ž„์›Œํฌ
473
+ - OKR๊ณผ ๊ท ํ˜•์„ฑ๊ณผํ‘œ(BSC)
474
+ - ์‹ค์‹œ๊ฐ„ ๋Œ€์‹œ๋ณด๋“œ ์„ค๊ณ„
475
+ - ์ง€์†์  ๊ฐœ์„  ๋ฉ”์ปค๋‹ˆ์ฆ˜
476
+
477
+ ## 5.2 ์ง€์†๊ฐ€๋Šฅ์„ฑ๊ณผ ESG
478
+ - ESG ํ†ตํ•ฉ ์ „๋žต
479
+ - ์ˆœํ™˜๊ฒฝ์ œ ๋ชจ๋ธ
480
+ - ์‚ฌํšŒ์  ์ž„ํŒฉํŠธ ์ธก์ •
481
+
482
+ # APPENDIX
483
+ - ์ƒ์„ธ ๋ถ„์„ ์ž๋ฃŒ
484
+ - ๋ฒค์น˜๋งˆํ‚น ์‚ฌ๋ก€
485
+ - ์šฉ์–ด ์ •์˜์™€ ์ฐธ๊ณ ๋ฌธํ—Œ
486
+
487
+ **์ž‘์„ฑ ์›์น™:**
488
+ - ๋ฐ์ดํ„ฐ ๊ธฐ๋ฐ˜์˜ ๋…ผ๋ฆฌ์  ์ „๊ฐœ
489
+ - ์‹คํ–‰ ๊ฐ€๋Šฅํ•œ ๊ตฌ์ฒด์  ๊ถŒ๊ณ ์•ˆ
490
+ - ์‹œ๊ฐ์  ์š”์†Œ ํ™œ์šฉ (ํ‘œ, ์ฐจํŠธ ์„ค๋ช…)
491
+ - ์ „๋ฌธ ์šฉ์–ด์™€ ์ผ๋ฐ˜ ์šฉ์–ด์˜ ๊ท ํ˜•
492
+ - ๊ธ€๋กœ๋ฒŒ ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค ๋ฐ˜์˜"""
493
+
494
+ def create_critic_prompt(self, stage: str, content: str, context: str = "", search_results: Dict = None) -> str:
495
+ """AGI๊ธ‰ ์˜คํ–‰ ์ƒ๊ทน ๊ธฐ๋ฐ˜ ๋น„ํ‰์ž ํ”„๋กฌํ”„ํŠธ"""
496
+ search_info = ""
497
+ if search_results:
498
+ search_info = f"\n\n์ฐธ๊ณ  ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ:\n{self._format_search_results(search_results)}"
499
+
500
+ context_section = ""
501
+ if context:
502
+ context_section = f"[์ด์ „ ๋งฅ๋ฝ]\n{context}\n"
503
+
504
+ # ์˜คํ–‰ ์ƒ๊ทน ๊ด€๊ณ„์— ๋”ฐ๋ฅธ ๋น„ํ‰ ๊ด€์  ์„ค์ •
505
+ critic_perspectives = {
506
+ "ๆœจ ์ดˆ๊ธฐ ๋ถ„์„": {
507
+ "perspective": "้‡‘(์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ)",
508
+ "focus": "์ •๋ฐ€์„ฑ, ์ฒด๊ณ„์„ฑ, ํ‘œ์ค€ํ™”",
509
+ "virtue": "็ฆฎ",
510
+ "approach": "๊ตฌ์กฐ์  ์™„๊ฒฐ์„ฑ๊ณผ ์‹œ์Šคํ…œ์  ์ •ํ•ฉ์„ฑ์„ ์ค‘์‹ฌ์œผ๋กœ ์ „๋žต์˜ ์‹คํ˜„ ๊ฐ€๋Šฅ์„ฑ์„ ๋ƒ‰์ฒ ํ•˜๊ฒŒ ๋ถ„์„"
511
+ },
512
+ "็ซ ์ „๋žต๊ธฐํš": {
513
+ "perspective": "ๆฐด(๋ฏธ๋ž˜๊ธฐ์ˆ  ์—ฐ๊ตฌ์†Œ์žฅ)",
514
+ "focus": "๋ถ„์„์  ๊นŠ์ด, ๊ธฐ์ˆ ์  ํƒ€๋‹น์„ฑ, ํ˜์‹ ์„ฑ",
515
+ "virtue": "ๆ™บ",
516
+ "approach": "๊ธฐ์ˆ ์  ๊ด€์ ์—์„œ ์ „๋žต์˜ ์‹คํ˜„ ๊ฐ€๋Šฅ์„ฑ๊ณผ ํ˜์‹ ์˜ ์ง€์†๊ฐ€๋Šฅ์„ฑ์„ ์‹ฌ์ธต ๋ถ„์„"
517
+ },
518
+ "ๅœŸ ์‹คํ–‰๊ณ„ํš": {
519
+ "perspective": "ๆœจ(์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž)",
520
+ "focus": "๊ฑฐ์‹œ์  ์ผ๊ด€์„ฑ, ๋น„์ „ ์ •ํ•ฉ์„ฑ, ์„ฑ์žฅ ๊ฐ€๋Šฅ์„ฑ",
521
+ "virtue": "ไป",
522
+ "approach": "์ „์ฒด์ ์ธ ๋น„์ „๊ณผ์˜ ์ •ํ•ฉ์„ฑ ๋ฐ ์žฅ๊ธฐ์  ์„ฑ์žฅ ๊ด€์ ์—์„œ ์‹คํ–‰๊ณ„ํš์˜ ์ ์ ˆ์„ฑ ํ‰๊ฐ€"
523
+ },
524
+ "้‡‘ ์•„ํ‚คํ…์ฒ˜": {
525
+ "perspective": "็ซ(ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ)",
526
+ "focus": "ํ˜์‹ ์„ฑ, ์œ ์—ฐ์„ฑ, ๋ณ€ํ™” ๋Œ€์‘๋ ฅ",
527
+ "virtue": "็พฉ",
528
+ "approach": "ํŒŒ๊ดด์  ํ˜์‹ ๊ณผ ๊ธ‰๋ณ€ํ•˜๋Š” ์‹œ์žฅ ํ™˜๊ฒฝ์—์„œ ์•„ํ‚คํ…์ฒ˜์˜ ์ ์‘์„ฑ๊ณผ ํ™•์žฅ์„ฑ ๊ฒ€์ฆ"
529
+ },
530
+ "ๆฐด R&D": {
531
+ "perspective": "ๅœŸ(์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€)",
532
+ "focus": "์‹คํ–‰ ๊ฐ€๋Šฅ์„ฑ, ์ž์› ํšจ์œจ์„ฑ, ROI",
533
+ "virtue": "ไฟก",
534
+ "approach": "์‹ค๋ฌด์  ๊ด€์ ์—์„œ R&D ์ „๋žต์˜ ๊ตฌ์ฒด์„ฑ๊ณผ ํˆฌ์ž ๋Œ€๋น„ ํšจ๊ณผ์„ฑ์„ ๋ฉด๋ฐ€ํžˆ ๊ฒ€ํ† "
535
+ }
536
+ }
537
+
538
+ critic_info = critic_perspectives.get(stage, critic_perspectives["ๆœจ ์ดˆ๊ธฐ ๋ถ„์„"])
539
+
540
+ return f"""๋‹น์‹ ์€ {critic_info['perspective']}์˜ ๊ด€์ ์„ ๊ฐ€์ง„ AGI ์ˆ˜์ค€์˜ ๋น„ํ‰ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค.
541
+ {critic_info['virtue']}(๋•๋ชฉ)์˜ ๊ด€์ ์—์„œ {critic_info['focus']}๋ฅผ ์ค‘์‹ฌ์œผ๋กœ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค.
542
+ McKinsey, BCG, Bain ์ˆ˜์ค€์˜ ์ „๋žต์  ์‚ฌ๊ณ ์™€ ํ•™์ˆ ์  ์—„๋ฐ€์„ฑ์„ ๊ฐ–์ถ”๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
543
+
544
+ [ํ‰๊ฐ€ ๋Œ€์ƒ]
545
+ ๋‹จ๊ณ„: {stage}
546
+ ๋‚ด์šฉ: {content}
547
+
548
+ {context_section}{search_info}
549
+
550
+ [๋น„ํ‰ ์ฒ ํ•™]
551
+ ์˜คํ–‰ ์ƒ๊ทน(็›ธๅ‰‹)์˜ ์›๋ฆฌ์— ๋”ฐ๋ผ, {critic_info['approach']}ํ•ฉ๋‹ˆ๋‹ค.
552
+
553
+ [๋น„ํ‰ ํ”„๋ ˆ์ž„์›Œํฌ]
554
+
555
+ 1. **{critic_info['perspective']} ๊ด€์ ์˜ ํ•ต์‹ฌ ๊ฒ€์ฆ**
556
+ - {critic_info['focus']}์— ๊ธฐ๋ฐ˜ํ•œ ์‹ฌ์ธต ๋ถ„์„
557
+ - ์ƒ๊ทน ๊ด€๊ณ„์—์„œ ์˜ค๋Š” ๊ฑด์„ค์  ๊ธด์žฅ๊ณผ ๊ท ํ˜•์  ํƒ์ƒ‰
558
+ - ๋ณด์™„์  ๊ฐœ์„  ๋ฐฉํ–ฅ ์ œ์‹œ
559
+
560
+ 2. **์ „๋žต์  ํƒ€๋‹น์„ฑ ๊ฒ€์ฆ**
561
+ - ๋…ผ๋ฆฌ์  ์ผ๊ด€์„ฑ๊ณผ ์ธ๊ณผ๊ด€๊ณ„ ๋ถ„์„
562
+ - ๊ฐ€์ •(Assumptions)์˜ ํƒ€๋‹น์„ฑ ๊ฒ€ํ† 
563
+ - ๋ฐ˜์ฆ ๊ฐ€๋Šฅ์„ฑ๊ณผ ๋Œ€์•ˆ ์‹œ๋‚˜๋ฆฌ์˜ค
564
+
565
+ 3. **์‹คํ–‰ ๊ฐ€๋Šฅ์„ฑ ํ‰๊ฐ€**
566
+ - ์ž์› ์š”๊ตฌ์‚ฌํ•ญ๊ณผ ์ œ์•ฝ์กฐ๊ฑด
567
+ - ๊ธฐ์ˆ ์ /์กฐ์ง์  ์‹คํ˜„ ๊ฐ€๋Šฅ์„ฑ
568
+ - ์‹œ๊ฐ„์ถ•๊ณผ ์˜์กด์„ฑ ๋ถ„์„
569
+
570
+ 4. **ํ˜์‹ ์„ฑ๊ณผ ์ฐจ๋ณ„ํ™”**
571
+ - ์—…๊ณ„ ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค ๋Œ€๋น„ ํ˜์‹ ์„ฑ
572
+ - ๊ฒฝ์Ÿ์šฐ์œ„ ์ฐฝ์ถœ ๊ฐ€๋Šฅ์„ฑ
573
+ - ์ง€์†๊ฐ€๋Šฅํ•œ ์ฐจ๋ณ„ํ™” ์š”์†Œ
574
+
575
+ 5. **๋ฆฌ์Šคํฌ์™€ ๊ธฐํšŒ ๋ถ„์„**
576
+ - ์ฃผ์š” ๋ฆฌ์Šคํฌ ์š”์ธ๊ณผ ์™„ํ™” ์ „๋žต
577
+ - ๋†“์นœ ๊ธฐํšŒ๋‚˜ ๋ธ”๋ผ์ธ๋“œ ์ŠคํŒŸ
578
+ - ์‹œ๋„ˆ์ง€ ์ฐฝ์ถœ ๊ฐ€๋Šฅ์„ฑ
579
+
580
+ 6. **๊ฐœ์„  ๊ถŒ๊ณ ์‚ฌํ•ญ**
581
+ - {critic_info['perspective']} ๊ด€์ ์—์„œ์˜ ๊ตฌ์ฒด์  ๊ฐœ์„ ์•ˆ
582
+ - ์šฐ์„ ์ˆœ์œ„์™€ ์˜ํ–ฅ๋„ ๋งคํŠธ๋ฆญ์Šค
583
+ - ๋‹ค์Œ ๋‹จ๊ณ„ ๋‹ด๋‹น์ž๋ฅผ ์œ„ํ•œ ๊ฐ€์ด๋“œ
584
+
585
+ 7. **์˜คํ–‰ ๊ท ํ˜•๊ณผ ์กฐํ™”**
586
+ - ์ƒ๊ทน ๊ด€๊ณ„๋ฅผ ํ†ตํ•œ ๊ฑด์„ค์  ๊ธด์žฅ ์œ ์ง€
587
+ - ์ „์ฒด ์‹œ์Šคํ…œ์˜ ๊ท ํ˜•๊ณผ ์กฐํ™” ๋‹ฌ์„ฑ ๋ฐฉ์•ˆ
588
+ - ์ง‘๋‹จ์ง€์„ฑ์˜ ์‹œ๋„ˆ์ง€ ๊ทน๋Œ€ํ™” ์ „๋žต
589
+
590
+ [์ถ”๊ฐ€ ์—ฐ๊ตฌ ์ œ์•ˆ]: ์‹ฌํ™” ๋ถ„์„์ด ํ•„์š”ํ•œ ํ‚ค์›Œ๋“œ 5-7๊ฐœ๋ฅผ ์ œ์‹œํ•˜์„ธ์š” [๋น„ํ‰ ๊ฒ€์ƒ‰]"""
591
+
592
+ def _format_search_results(self, search_results: Dict) -> str:
593
+ """๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ํฌ๋งทํŒ…"""
594
+ if not search_results:
595
+ return "๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ์—†์Œ"
596
+
597
+ formatted = ""
598
+ for keyword, results in search_results.items():
599
+ formatted += f"\n**{keyword}:**\n"
600
+ for i, result in enumerate(results[:5], 1):
601
+ formatted += f"{i}. {result.get('title', 'N/A')} (์‹ ๋ขฐ๋„: {result.get('credibility_score', 0):.2f})\n"
602
+ formatted += f" {result.get('description', 'N/A')[:150]}...\n"
603
+ return formatted
604
+
605
+ def _format_critic_display(self, critics: List[str], current_index: int) -> str:
606
+ """๋น„ํ‰ ๋‚ด์šฉ์„ ๋ณด๊ธฐ ์ข‹๊ฒŒ ํฌ๋งทํŒ…"""
607
+ stages = [
608
+ "์ „๋žต์  ๋น„์ „ ๊ฒ€์ฆ (้‡‘ๅ…‹ๆœจ)",
609
+ "ํ˜์‹  ์ „๋žต ๊ฒ€์ฆ (ๆฐดๅ…‹็ซ)",
610
+ "์‹คํ–‰ ๊ณ„ํš ๊ฒ€์ฆ (ๆœจๅ…‹ๅœŸ)",
611
+ "์•„ํ‚คํ…์ฒ˜ ๊ฒ€์ฆ (็ซๅ…‹้‡‘)",
612
+ "๋ฏธ๋ž˜๊ธฐ์ˆ  ๊ฒ€์ฆ (ๅœŸๅ…‹ๆฐด)"
613
+ ]
614
+
615
+ formatted = "๐Ÿ” **์ „๋žต ๊ฒ€์ฆ ์ „๋ฌธ๊ฐ€** (์˜คํ–‰ ์ƒ๊ทน ์›๋ฆฌ)\n\n"
616
+
617
+ for i in range(min(current_index + 1, len(critics))):
618
+ if i < len(stages):
619
+ formatted += f"[{stages[i]}]\n{critics[i]}\n"
620
+ if i < current_index:
621
+ formatted += "\n---\n\n"
622
+
623
+ return formatted
624
+
625
+ def _format_critic_history(self, critics: List) -> str:
626
+ """๋น„ํ‰ ์ด๋ ฅ ํฌ๋งทํŒ… (์ตœ์ข… ๋ณด๊ณ ์„œ์šฉ)"""
627
+ if not critics:
628
+ return "๋น„ํ‰ ์ด๋ ฅ ์—†์Œ"
629
+
630
+ formatted = ""
631
+ stages = [
632
+ "ๆœจ ์ดˆ๊ธฐ (้‡‘ ๊ด€์  ๋น„ํ‰)",
633
+ "็ซ ์ „๋žต (ๆฐด ๊ด€์  ๋น„ํ‰)",
634
+ "ๅœŸ ์‹คํ–‰ (ๆœจ ๊ด€์  ๋น„ํ‰)",
635
+ "้‡‘ ์•„ํ‚คํ…์ฒ˜ (็ซ ๊ด€์  ๋น„ํ‰)",
636
+ "ๆฐด R&D (ๅœŸ ๊ด€์  ๋น„ํ‰)"
637
+ ]
638
+ for i, critic in enumerate(critics):
639
+ if i < len(stages):
640
+ formatted += f"\n**{stages[i]}:**\n{critic}\n"
641
+ return formatted
642
+
643
+ def extract_keywords(self, response: str, keyword_marker: str = "[ํ•ต์‹ฌ ํ‚ค์›Œ๋“œ]") -> List[str]:
644
+ """์‘๋‹ต์—์„œ ํ‚ค์›Œ๋“œ ์ถ”์ถœ (๋ฒ”์šฉ)"""
645
+ keywords = []
646
+
647
+ # ๋‹ค์–‘ํ•œ ํ‚ค์›Œ๋“œ ๋งˆ์ปค ํŒจํ„ด
648
+ patterns = [
649
+ rf'{re.escape(keyword_marker)}:\s*(.+)',
650
+ r'\[์ถ”๊ฐ€ ๊ฒ€์ƒ‰\]:\s*(.+)',
651
+ r'\[๋น„ํ‰ ๊ฒ€์ƒ‰\]:\s*(.+)'
652
+ ]
653
+
654
+ for pattern in patterns:
655
+ match = re.search(pattern, response, re.IGNORECASE)
656
+ if match:
657
+ keyword_str = match.group(1)
658
+ new_keywords = [k.strip() for k in keyword_str.split(',') if k.strip()]
659
+ keywords.extend(new_keywords)
660
+
661
+ # ์ค‘๋ณต ์ œ๊ฑฐ
662
+ keywords = list(dict.fromkeys(keywords))
663
+
664
+ if not keywords:
665
+ # ๊ธฐ๋ณธ ํ‚ค์›Œ๋“œ ์ƒ์„ฑ
666
+ keywords = ["best practices", "implementation", "case studies", "latest trends"]
667
+
668
+ return keywords[:7]
669
+
670
+ def calculate_credibility_score(self, result: Dict) -> float:
671
+ """๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ์‹ ๋ขฐ๋„ ๊ณ„์‚ฐ"""
672
+ score = 0.5
673
+ url = result.get('url', '')
674
+
675
+ trusted_domains = ['.edu', '.gov', '.org', 'wikipedia.org', 'nature.com',
676
+ 'ieee.org', 'acm.org', 'github.com']
677
+
678
+ for domain in trusted_domains:
679
+ if domain in url:
680
+ score += 0.2
681
+ break
682
+
683
+ if url.startswith('https://'):
684
+ score += 0.1
685
+
686
+ if len(result.get('title', '')) > 20:
687
+ score += 0.05
688
+ if len(result.get('description', '')) > 50:
689
+ score += 0.05
690
+
691
+ spam_keywords = ['buy now', 'sale', 'discount', 'click here']
692
+ if any(spam in (result.get('title', '') + result.get('description', '')).lower()
693
+ for spam in spam_keywords):
694
+ score -= 0.3
695
+
696
+ return max(0, min(1, score))
697
+
698
+ def brave_search(self, query: str) -> List[Dict]:
699
+ """Brave Search API ํ˜ธ์ถœ"""
700
+ if self.test_mode or self.bapi_token == "YOUR_BRAVE_API_TOKEN":
701
+ test_results = []
702
+ for i in range(5):
703
+ test_results.append({
704
+ "title": f"{query} - Best Practices {i+1}",
705
+ "description": f"Comprehensive guide on {query} with proven methodologies.",
706
+ "url": f"https://example{i+1}.com/{query.replace(' ', '-')}",
707
+ "credibility_score": 0.7 + (i * 0.05)
708
+ })
709
+ return test_results
710
+
711
+ try:
712
+ params = {
713
+ "q": query,
714
+ "count": 10,
715
+ "safesearch": "moderate"
716
+ }
717
+
718
+ response = requests.get(
719
+ self.brave_url,
720
+ headers=self.create_brave_headers(),
721
+ params=params,
722
+ timeout=10
723
+ )
724
+
725
+ if response.status_code == 200:
726
+ data = response.json()
727
+ results = []
728
+ for item in data.get("web", {}).get("results", []):
729
+ result = {
730
+ "title": item.get("title", ""),
731
+ "description": item.get("description", ""),
732
+ "url": item.get("url", ""),
733
+ "credibility_score": self.calculate_credibility_score(item)
734
+ }
735
+ results.append(result)
736
+
737
+ results.sort(key=lambda x: x['credibility_score'], reverse=True)
738
+ return results
739
+ else:
740
+ logger.error(f"Brave API ์˜ค๋ฅ˜: {response.status_code}")
741
+ return []
742
+
743
+ except Exception as e:
744
+ logger.error(f"Brave ๊ฒ€์ƒ‰ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
745
+ return []
746
+
747
+ def call_gemini_streaming(self, messages: List[Dict[str, str]], role: str) -> Generator[str, None, None]:
748
+ """Gemini API ์ŠคํŠธ๋ฆฌ๋ฐ ํ˜ธ์ถœ - AGI ์ˆ˜์ค€"""
749
+ if not self.gemini_client:
750
+ yield "โŒ Gemini API ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค."
751
+ return
752
+
753
+ try:
754
+ contents = []
755
+ for msg in messages:
756
+ if msg["role"] == "user":
757
+ contents.append(types.Content(
758
+ role="user",
759
+ parts=[types.Part.from_text(text=msg["content"])]
760
+ ))
761
+
762
+ generate_content_config = types.GenerateContentConfig(
763
+ temperature=0.8, # ์ฐฝ์˜์„ฑ ์ฆ๊ฐ€
764
+ top_p=0.9,
765
+ max_output_tokens=8192, # ํ† ํฐ ์ˆ˜ ๋Œ€ํญ ์ฆ๊ฐ€
766
+ response_mime_type="text/plain"
767
+ )
768
+
769
+ for chunk in self.gemini_client.models.generate_content_stream(
770
+ model="gemini-2.5-pro",
771
+ contents=contents,
772
+ config=generate_content_config,
773
+ ):
774
+ if chunk.text:
775
+ yield chunk.text
776
+
777
+ except Exception as e:
778
+ logger.error(f"Gemini API ์˜ค๋ฅ˜: {str(e)}")
779
+ yield f"โŒ Gemini API ์˜ค๋ฅ˜: {str(e)}"
780
+
781
+ def call_llm_streaming(self, messages: List[Dict[str, str]], role: str) -> Generator[str, None, None]:
782
+ """์ŠคํŠธ๋ฆฌ๋ฐ LLM API ํ˜ธ์ถœ - AGI ์ˆ˜์ค€ ์‘๋‹ต"""
783
+ if self.use_gemini:
784
+ yield from self.call_gemini_streaming(messages, role)
785
+ return
786
+
787
+ if self.test_mode:
788
+ test_response = f"[{role.upper()} - AGI Level Analysis]\n\n"
789
+ test_response += f"์ด๊ฒƒ์€ {role} ์ „๋ฌธ๊ฐ€์˜ AGI ์ˆ˜์ค€ ๋ถ„์„์ž…๋‹ˆ๋‹ค.\n"
790
+ test_response += "1. ์ „๋žต์  ํ†ต์ฐฐ: ์‹ฌ์ธต์ ์ด๊ณ  ํ˜์‹ ์ ์ธ ๋ถ„์„\n"
791
+ test_response += "2. ์‹คํ–‰ ๊ฐ€๋Šฅ์„ฑ: ๊ตฌ์ฒด์ ์ด๊ณ  ๊ฒ€์ฆ๋œ ๋ฐฉ๋ฒ•๋ก \n"
792
+ test_response += "3. ๋ฏธ๋ž˜ ์˜ˆ์ธก: ๋ฐ์ดํ„ฐ ๊ธฐ๋ฐ˜ ์‹œ๋‚˜๋ฆฌ์˜ค ํ”Œ๋ž˜๋‹\n"
793
+
794
+ words = test_response.split()
795
+ for i in range(0, len(words), 3):
796
+ chunk = " ".join(words[i:i+3])
797
+ yield chunk + " "
798
+ time.sleep(0.05)
799
+ return
800
+
801
+ try:
802
+ payload = {
803
+ "model": self.model_id,
804
+ "messages": messages,
805
+ "max_tokens": 8192, # ํ† ํฐ ์ˆ˜ ๋Œ€ํญ ์ฆ๊ฐ€
806
+ "temperature": 0.8, # ์ฐฝ์˜์„ฑ ์ฆ๊ฐ€
807
+ "top_p": 0.9,
808
+ "stream": True
809
+ }
810
+
811
+ response = requests.post(
812
+ self.api_url,
813
+ headers=self.create_headers(),
814
+ json=payload,
815
+ stream=True,
816
+ timeout=30 # ํƒ€์ž„์•„์›ƒ ์ฆ๊ฐ€
817
+ )
818
+
819
+ if response.status_code != 200:
820
+ yield f"โŒ API ์˜ค๋ฅ˜: {response.status_code}"
821
+ return
822
+
823
+ for line in response.iter_lines():
824
+ if line:
825
+ line = line.decode('utf-8')
826
+ if line.startswith("data: "):
827
+ data = line[6:]
828
+ if data == "[DONE]":
829
+ break
830
+ try:
831
+ chunk = json.loads(data)
832
+ if "choices" in chunk and chunk["choices"]:
833
+ content = chunk["choices"][0].get("delta", {}).get("content", "")
834
+ if content:
835
+ yield content
836
+ except json.JSONDecodeError:
837
+ continue
838
+
839
+ except Exception as e:
840
+ logger.error(f"์ŠคํŠธ๋ฆฌ๋ฐ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
841
+ yield f"โŒ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
842
+
843
+ # ์‹œ์Šคํ…œ ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ
844
+ wuxing_system = WuxingLLMSystem()
845
+
846
+ def process_wuxing_query(user_query: str, llm_mode: str):
847
+ """AGI ์ˆ˜์ค€ ์˜คํ–‰ ๊ธฐ๋ฐ˜ ์ „๋ฌธ ๋ณด๊ณ ์„œ ์ƒ์„ฑ"""
848
+ if not user_query:
849
+ return "", "", "", "", "", "", "", "โŒ ๋ณด๊ณ ์„œ ์š”์ฒญ์‚ฌํ•ญ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."
850
+
851
+ wuxing_system.set_llm_mode(llm_mode)
852
+
853
+ all_responses = {}
854
+ all_critics = []
855
+ all_search_results = {}
856
+
857
+ try:
858
+ # 0. ์ดˆ๊ธฐ ๊ฒ€์ƒ‰ ์ˆ˜ํ–‰ - ๋” ๋งŽ์€ ํ‚ค์›Œ๋“œ๋กœ ์‹ฌ์ธต ์กฐ์‚ฌ
859
+ initial_keywords = [
860
+ user_query,
861
+ f"{user_query} best practices",
862
+ f"{user_query} case studies",
863
+ f"{user_query} industry trends",
864
+ f"{user_query} future outlook",
865
+ f"{user_query} challenges solutions"
866
+ ]
867
+ wood_search_results = {}
868
+
869
+ status_text = "๐Ÿ” AGI ์‹œ์Šคํ…œ์ด ๊ธ€๋กœ๋ฒŒ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๊ฒ€์ƒ‰ ์ค‘..."
870
+ yield "", "", "", "", "", "", "", status_text
871
+
872
+ for keyword in initial_keywords[:5]: # ๋” ๋งŽ์€ ์ดˆ๊ธฐ ๊ฒ€์ƒ‰
873
+ results = wuxing_system.brave_search(keyword)
874
+ if results:
875
+ wood_search_results[keyword] = results
876
+ all_search_results[f"์ดˆ๊ธฐ-{keyword}"] = results
877
+
878
+ # 1. ๆœจ(๊ฐ๋…๊ด€) ์ดˆ๊ธฐ ๋ถ„์„
879
+ wood_prompt = wuxing_system.create_wood_initial_prompt(user_query, wood_search_results)
880
+ wood_response = ""
881
+
882
+ wood_text = "๐ŸŒณ **ๆœจ - ์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž** (ไป)\n๐Ÿ”„ ๋ฏธ๋ž˜ ์‹œ๋‚˜๋ฆฌ์˜ค ๋ถ„์„ ์ค‘...\n"
883
+ for chunk in wuxing_system.call_llm_streaming(
884
+ [{"role": "user", "content": wood_prompt}], "wood"
885
+ ):
886
+ wood_response += chunk
887
+ wood_text = f"๐ŸŒณ **ๆœจ - ์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž** (ไป)\n{wood_response}"
888
+ yield wood_text, "", "", "", "", "", "", "๐ŸŒณ ๊ฑฐ์‹œ์  ๋น„์ „๊ณผ ์ „๋žต ํ”„๋ ˆ์ž„์›Œํฌ ์ˆ˜๋ฆฝ ์ค‘..."
889
+
890
+ all_responses['wood_initial'] = wood_response
891
+
892
+ # ํ‚ค์›Œ๋“œ ์ถ”์ถœ
893
+ keywords = wuxing_system.extract_keywords(wood_response)
894
+
895
+ # 2. ๆœจ ๋น„ํ‰ + ๋น„ํ‰์ž ๊ฒ€์ƒ‰ (้‡‘ ๊ด€์ )
896
+ critic_search = {}
897
+ for keyword in keywords[:2]:
898
+ results = wuxing_system.brave_search(f"{keyword} analysis")
899
+ if results:
900
+ critic_search[keyword] = results
901
+ all_search_results[f"๋น„ํ‰1-{keyword}"] = results
902
+
903
+ critic_prompt = wuxing_system.create_critic_prompt("ๆœจ ์ดˆ๊ธฐ ๋ถ„์„", wood_response, search_results=critic_search)
904
+ critic_response = ""
905
+
906
+ critic_text = "๐Ÿ” **์ „๋žต ๊ฒ€์ฆ ์ „๋ฌธ๊ฐ€**\n[์ „๋žต์  ๋น„์ „ ๊ฒ€์ฆ - ้‡‘ๅ…‹ๆœจ] ๐Ÿ”„ ์‹œ์Šคํ…œ์  ์ •๋ฐ€์„ฑ ๋ถ„์„ ์ค‘...\n"
907
+ for chunk in wuxing_system.call_llm_streaming(
908
+ [{"role": "user", "content": critic_prompt}], "critic"
909
+ ):
910
+ critic_response += chunk
911
+ critic_text = wuxing_system._format_critic_display([critic_response], 0)
912
+ yield wood_text, "", "", "", "", critic_text, "", "๐Ÿ” ้‡‘์˜ ๊ด€์ ์—์„œ ๆœจ์˜ ์ „๋žต ํƒ€๋‹น์„ฑ๊ณผ ์ฒด๊ณ„์„ฑ ๊ฒ€์ฆ ์ค‘..."
913
+
914
+ all_critics.append(critic_response)
915
+
916
+ # 3. ็ซ(์ „๋žต๊ธฐํš) + ๊ฒ€์ƒ‰
917
+ # ๋น„ํ‰์ž๊ฐ€ ์ œ์•ˆํ•œ ์ถ”๊ฐ€ ํ‚ค์›Œ๋“œ ์ถ”์ถœ
918
+ critic_keywords = wuxing_system.extract_keywords(critic_response, "[๋น„ํ‰ ๊ฒ€์ƒ‰]")
919
+ fire_search = {}
920
+
921
+ for keyword in (keywords[:2] + critic_keywords[:2]):
922
+ results = wuxing_system.brave_search(f"{user_query} {keyword} strategy")
923
+ if results:
924
+ fire_search[keyword] = results
925
+ all_search_results[f"็ซ-{keyword}"] = results
926
+
927
+ fire_prompt = wuxing_system.create_fire_strategy_prompt(user_query, wood_response, critic_response, fire_search)
928
+ fire_response = ""
929
+
930
+ fire_text = "๐Ÿ”ฅ **็ซ - ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ** (็พฉ)\n๐Ÿ”„ ํŒŒ๊ดด์  ํ˜์‹  ์ „๋žต ์„ค๊ณ„ ์ค‘...\n"
931
+ for chunk in wuxing_system.call_llm_streaming(
932
+ [{"role": "user", "content": fire_prompt}], "fire"
933
+ ):
934
+ fire_response += chunk
935
+ fire_text = f"๐Ÿ”ฅ **็ซ - ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ** (็พฉ)\n{fire_response}"
936
+ yield wood_text, fire_text, "", "", "", critic_text, "", "๐Ÿ”ฅ ๋น„์ฆˆ๋‹ˆ์Šค ๋ชจ๋ธ ํ˜์‹ ๊ณผ ๊ฒฝ์Ÿ์šฐ์œ„ ์ „๋žต ์ˆ˜๋ฆฝ ์ค‘..."
937
+
938
+ all_responses['fire'] = fire_response
939
+
940
+ # 4. ็ซ ๋น„ํ‰ (ๆฐด ๊ด€์ )
941
+ fire_keywords = wuxing_system.extract_keywords(fire_response, "[์ถ”๊ฐ€ ๊ฒ€์ƒ‰]")
942
+ critic_search = {}
943
+
944
+ for keyword in fire_keywords[:2]:
945
+ results = wuxing_system.brave_search(keyword)
946
+ if results:
947
+ critic_search[keyword] = results
948
+ all_search_results[f"๋น„ํ‰2-{keyword}"] = results
949
+
950
+ critic_prompt = wuxing_system.create_critic_prompt("็ซ ์ „๋žต๊ธฐํš", fire_response, wood_response, critic_search)
951
+ critic_response = ""
952
+
953
+ # ์ด์ „ ๋น„ํ‰ ๋‚ด์šฉ ์œ ์ง€ํ•˜๋ฉด์„œ ์ƒˆ๋กœ์šด ๋น„ํ‰ ์ถ”๊ฐ€
954
+ for chunk in wuxing_system.call_llm_streaming(
955
+ [{"role": "user", "content": critic_prompt}], "critic"
956
+ ):
957
+ critic_response += chunk
958
+ critic_text = wuxing_system._format_critic_display(all_critics + [critic_response], 1)
959
+ yield wood_text, fire_text, "", "", "", critic_text, "", "๐Ÿ” ๆฐด์˜ ๊ด€์ ์—์„œ ็ซ์˜ ํ˜์‹ ์„ฑ๊ณผ ๊ธฐ์ˆ ์  ํƒ€๋‹น์„ฑ ๊ฒ€์ฆ ์ค‘..."
960
+
961
+ all_critics.append(critic_response)
962
+
963
+ # 5. ๅœŸ(์‹คํ–‰์šด์˜)
964
+ earth_search = {}
965
+ for keyword in ["implementation", "resource management", "quality assurance"]:
966
+ results = wuxing_system.brave_search(f"{user_query} {keyword}")
967
+ if results:
968
+ earth_search[keyword] = results
969
+ all_search_results[f"ๅœŸ-{keyword}"] = results
970
+
971
+ earth_prompt = wuxing_system.create_earth_execution_prompt(user_query, fire_response, critic_response, earth_search)
972
+ earth_response = ""
973
+
974
+ earth_text = "๐Ÿ”๏ธ **ๅœŸ - ์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€** (ไฟก)\n๐Ÿ”„ ํ”„๋กœ์ ํŠธ ๊ฑฐ๋ฒ„๋„Œ์Šค ์„ค๊ณ„ ์ค‘...\n"
975
+ for chunk in wuxing_system.call_llm_streaming(
976
+ [{"role": "user", "content": earth_prompt}], "earth"
977
+ ):
978
+ earth_response += chunk
979
+ earth_text = f"๐Ÿ”๏ธ **ๅœŸ - ์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€** (ไฟก)\n{earth_response}"
980
+ yield wood_text, fire_text, earth_text, "", "", critic_text, "", "๐Ÿ”๏ธ ์‹คํ–‰ ๋กœ๋“œ๋งต๊ณผ ํ’ˆ์งˆ ์‹œ์Šคํ…œ ๊ตฌ์ถ• ์ค‘..."
981
+
982
+ all_responses['earth'] = earth_response
983
+
984
+ # 6. ๅœŸ ๋น„ํ‰ (ๆœจ ๊ด€์ )
985
+ critic_search = {}
986
+ results = wuxing_system.brave_search(f"{user_query} execution challenges")
987
+ if results:
988
+ critic_search["execution"] = results
989
+ all_search_results["๋น„ํ‰3-execution"] = results
990
+
991
+ critic_prompt = wuxing_system.create_critic_prompt("ๅœŸ ์‹คํ–‰๊ณ„ํš", earth_response, fire_response, critic_search)
992
+ critic_response = ""
993
+
994
+ for chunk in wuxing_system.call_llm_streaming(
995
+ [{"role": "user", "content": critic_prompt}], "critic"
996
+ ):
997
+ critic_response += chunk
998
+ critic_text = wuxing_system._format_critic_display(all_critics + [critic_response], 2)
999
+ yield wood_text, fire_text, earth_text, "", "", critic_text, "", "๐Ÿ” ๆœจ์˜ ๊ด€์ ์—์„œ ๅœŸ์˜ ์‹คํ–‰๊ณ„ํš๊ณผ ๋น„์ „ ์ •ํ•ฉ์„ฑ ๊ฒ€์ฆ ์ค‘..."
1000
+
1001
+ all_critics.append(critic_response)
1002
+
1003
+ # 7. ้‡‘(์•„ํ‚คํ…์ฒ˜)
1004
+ metal_search = {}
1005
+ for keyword in ["architecture", "standards", "system design", "scalability"]:
1006
+ results = wuxing_system.brave_search(f"{user_query} {keyword}")
1007
+ if results:
1008
+ metal_search[keyword] = results
1009
+ all_search_results[f"้‡‘-{keyword}"] = results
1010
+
1011
+ metal_prompt = wuxing_system.create_metal_architecture_prompt(user_query, earth_response, critic_response, metal_search)
1012
+ metal_response = ""
1013
+
1014
+ metal_text = "โš™๏ธ **้‡‘ - ์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ** (็ฆฎ)\n๐Ÿ”„ ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์•„ํ‚คํ…์ฒ˜ ์„ค๊ณ„ ์ค‘...\n"
1015
+ for chunk in wuxing_system.call_llm_streaming(
1016
+ [{"role": "user", "content": metal_prompt}], "metal"
1017
+ ):
1018
+ metal_response += chunk
1019
+ metal_text = f"โš™๏ธ **้‡‘ - ์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ** (็ฆฎ)\n{metal_response}"
1020
+ yield wood_text, fire_text, earth_text, metal_text, "", critic_text, "", "โš™๏ธ ๊ธฐ์ˆ  ํ‘œ์ค€๊ณผ ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ์ธํ”„๋ผ ์„ค๊ณ„ ์ค‘..."
1021
+
1022
+ all_responses['metal'] = metal_response
1023
+
1024
+ # 8. ้‡‘ ๋น„ํ‰ (็ซ ๊ด€์ )
1025
+ critic_search = {}
1026
+ results = wuxing_system.brave_search(f"{user_query} technical constraints")
1027
+ if results:
1028
+ critic_search["constraints"] = results
1029
+ all_search_results["๋น„ํ‰4-constraints"] = results
1030
+
1031
+ critic_prompt = wuxing_system.create_critic_prompt("้‡‘ ์•„ํ‚คํ…์ฒ˜", metal_response, earth_response, critic_search)
1032
+ critic_response = ""
1033
+
1034
+ for chunk in wuxing_system.call_llm_streaming(
1035
+ [{"role": "user", "content": critic_prompt}], "critic"
1036
+ ):
1037
+ critic_response += chunk
1038
+ critic_text = wuxing_system._format_critic_display(all_critics + [critic_response], 3)
1039
+ yield wood_text, fire_text, earth_text, metal_text, "", critic_text, "", "๐Ÿ” ็ซ์˜ ๊ด€์ ์—์„œ ้‡‘์˜ ์•„ํ‚คํ…์ฒ˜ ํ˜์‹ ์„ฑ๊ณผ ์œ ์—ฐ์„ฑ ๊ฒ€์ฆ ์ค‘..."
1040
+
1041
+ all_critics.append(critic_response)
1042
+
1043
+ # 9. ๆฐด(R&D)
1044
+ water_search = {}
1045
+ for keyword in ["innovation", "emerging technology", "R&D", "automation tools"]:
1046
+ results = wuxing_system.brave_search(f"{user_query} {keyword}")
1047
+ if results:
1048
+ water_search[keyword] = results
1049
+ all_search_results[f"ๆฐด-{keyword}"] = results
1050
+
1051
+ water_prompt = wuxing_system.create_water_rd_prompt(user_query, metal_response, critic_response, water_search)
1052
+ water_response = ""
1053
+
1054
+ water_text = "๐Ÿ’ง **ๆฐด - ๋ฏธ๋ž˜๊ธฐ์ˆ  ์—ฐ๊ตฌ์†Œ์žฅ** (ๆ™บ)\n๐Ÿ”„ ์‹ ๊ธฐ์ˆ  ์œตํ•ฉ ์ „๋žต ์—ฐ๊ตฌ ์ค‘...\n"
1055
+ for chunk in wuxing_system.call_llm_streaming(
1056
+ [{"role": "user", "content": water_prompt}], "water"
1057
+ ):
1058
+ water_response += chunk
1059
+ water_text = f"๐Ÿ’ง **ๆฐด - ๋ฏธ๋ž˜๊ธฐ์ˆ  ์—ฐ๊ตฌ์†Œ์žฅ** (ๆ™บ)\n{water_response}"
1060
+ yield wood_text, fire_text, earth_text, metal_text, water_text, critic_text, "", "๐Ÿ’ง AI/ML ๋ฐ ์‹ ๊ธฐ์ˆ  R&D ์ „๋žต ์ˆ˜๋ฆฝ ์ค‘..."
1061
+
1062
+ all_responses['water'] = water_response
1063
+
1064
+ # 10. ๆฐด ๋น„ํ‰ (ๅœŸ ๊ด€์ )
1065
+ critic_search = {}
1066
+ results = wuxing_system.brave_search(f"{user_query} future trends")
1067
+ if results:
1068
+ critic_search["trends"] = results
1069
+ all_search_results["๋น„ํ‰5-trends"] = results
1070
+
1071
+ critic_prompt = wuxing_system.create_critic_prompt("ๆฐด R&D", water_response, metal_response, critic_search)
1072
+ critic_response = ""
1073
+
1074
+ for chunk in wuxing_system.call_llm_streaming(
1075
+ [{"role": "user", "content": critic_prompt}], "critic"
1076
+ ):
1077
+ critic_response += chunk
1078
+ critic_text = wuxing_system._format_critic_display(all_critics + [critic_response], 4)
1079
+ yield wood_text, fire_text, earth_text, metal_text, water_text, critic_text, "", "๐Ÿ” ๅœŸ์˜ ๊ด€์ ์—์„œ ๆฐด์˜ R&D ์‹คํ–‰ ๊ฐ€๋Šฅ์„ฑ๊ณผ ROI ๊ฒ€์ฆ ์ค‘..."
1080
+
1081
+ all_critics.append(critic_response)
1082
+
1083
+ # 11. ๆœจ(๊ฐ๋…๊ด€) ์ตœ์ข… ์ข…ํ•ฉ
1084
+ wood_final_prompt = wuxing_system.create_wood_final_prompt(user_query, all_responses, all_critics)
1085
+ wood_final_response = ""
1086
+
1087
+ wood_text += "\n\n---\n\n๐ŸŒณ **์ตœ์ข… ์ „๋ฌธ ๋ณด๊ณ ์„œ ์ž‘์„ฑ**\n๐Ÿ”„ Executive Summary ๋ฐ ์ข…ํ•ฉ ์ „๋žต ๋ณด๊ณ ์„œ ์ž‘์„ฑ ์ค‘...\n"
1088
+ for chunk in wuxing_system.call_llm_streaming(
1089
+ [{"role": "user", "content": wood_final_prompt}], "wood"
1090
+ ):
1091
+ wood_final_response += chunk
1092
+ temp_text = all_responses['wood_initial'] + f"\n\n---\n\n๐ŸŒณ **์ตœ์ข… ์ „๋ฌธ ๋ณด๊ณ ์„œ**\n{wood_final_response}"
1093
+ wood_text = f"๐ŸŒณ **ๆœจ - ์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž** (ไป)\n{temp_text}"
1094
+ yield wood_text, fire_text, earth_text, metal_text, water_text, critic_text, "", "๐ŸŒณ McKinsey ์ˆ˜์ค€์˜ ์ตœ์ข… ์ „๋žต ๋ณด๊ณ ์„œ ์ž‘์„ฑ ์ค‘..."
1095
+
1096
+ # ์ตœ์ข… ๋ณด๊ณ ์„œ ์ƒ์„ฑ - AGI ์ˆ˜์ค€ ์ „๋ฌธ ๋ณด๊ณ ์„œ
1097
+ final_report = f"""# ๐ŸŒŸ AGI ํ˜‘๋ ฅ ์‹œ์Šคํ…œ ์ „๏ฟฝ๏ฟฝ ๋ถ„์„ ๋ณด๊ณ ์„œ
1098
+
1099
+ <div style="text-align: center; margin: 20px 0;">
1100
+ <h3>์˜คํ–‰ ์ง‘๋‹จ์ง€์„ฑ ๊ธฐ๋ฐ˜ ์ข…ํ•ฉ ์ „๋žต ๋ณด๊ณ ์„œ</h3>
1101
+ <p style="color: #666;">์ƒ์„ฑ์ผ์‹œ: {datetime.now().strftime('%Y๋…„ %m์›” %d์ผ %H:%M:%S')}</p>
1102
+ </div>
1103
+
1104
+ ---
1105
+
1106
+ ## ๐Ÿ“‹ EXECUTIVE SUMMARY
1107
+
1108
+ ### ๐ŸŽฏ ์š”์ฒญ์‚ฌํ•ญ
1109
+ > **{user_query}**
1110
+
1111
+ ### ๐Ÿ’ก ํ•ต์‹ฌ ๊ถŒ๊ณ ์‚ฌํ•ญ
1112
+ {wood_final_response[:500]}...
1113
+
1114
+ ### ๐Ÿ“Š ์ฃผ์š” ์„ฑ๊ณผ ์ง€ํ‘œ
1115
+ | ๊ตฌ๋ถ„ | ๋‚ด์šฉ | ์˜ํ–ฅ๋„ |
1116
+ |------|------|--------|
1117
+ | **์ „๋žต์  ๊ฐ€์น˜** | ํ˜์‹ ์„ฑ๊ณผ ์ฐจ๋ณ„ํ™” | โญโญโญโญโญ |
1118
+ | **์‹คํ–‰ ๊ฐ€๋Šฅ์„ฑ** | ๋ฆฌ์†Œ์Šค์™€ ์—ญ๋Ÿ‰ | โญโญโญโญ |
1119
+ | **์˜ˆ์ƒ ROI** | ํˆฌ์ž ๋Œ€๋น„ ์ˆ˜์ต | โญโญโญโญโญ |
1120
+ | **๋ฆฌ์Šคํฌ ์ˆ˜์ค€** | ๊ด€๋ฆฌ ๊ฐ€๋Šฅ์„ฑ | โญโญโญ |
1121
+
1122
+ ---
1123
+
1124
+ ## 1. ์ „๋žต์  ๋ถ„์„๊ณผ ๋น„์ „ (ๆœจ - Chief Vision Officer)
1125
+
1126
+ ### 1.1 ๊ฑฐ์‹œ์  ํ†ต์ฐฐ๊ณผ ๋ฏธ๋ž˜ ์˜ˆ์ธก
1127
+ {all_responses['wood_initial'][:1000]}...
1128
+
1129
+ ### 1.2 ์‹œ์Šคํ…œ์  ์‚ฌ๊ณ ์™€ ํ˜์‹  ํ”„๋ ˆ์ž„์›Œํฌ
1130
+ {wood_final_response[:1500]}...
1131
+
1132
+ ---
1133
+
1134
+ ## 2. ํ˜์‹  ์ „๋žต๊ณผ ๋น„์ฆˆ๋‹ˆ์Šค ๋ชจ๋ธ (็ซ - Innovation Strategy Architect)
1135
+
1136
+ ### 2.1 ํŒŒ๊ดด์  ํ˜์‹  ์ „๋žต
1137
+ {all_responses['fire'][:1000]}...
1138
+
1139
+ ### 2.2 ๊ฒฝ์Ÿ์šฐ์œ„ ์ฐฝ์ถœ ๋ฐฉ์•ˆ
1140
+ - ์ฐจ๋ณ„ํ™” ์ „๋žต
1141
+ - ๊ฐ€์น˜ ํ˜์‹ 
1142
+ - ํ”Œ๋žซํผ ์ „๋žต
1143
+
1144
+ ---
1145
+
1146
+ ## 3. ์‹คํ–‰ ๊ณ„ํš๊ณผ ์šด์˜ ์ตœ์ ํ™” (ๅœŸ - Execution Excellence Expert)
1147
+
1148
+ ### 3.1 ๋‹จ๊ณ„๋ณ„ ์‹คํ–‰ ๋กœ๋“œ๋งต
1149
+ {all_responses['earth'][:1000]}...
1150
+
1151
+ ### 3.2 ๋ฆฌ์†Œ์Šค ๋ฐฐ๋ถ„๊ณผ ํ”„๋กœ์ ํŠธ ๊ฑฐ๋ฒ„๋„Œ์Šค
1152
+ | ๋‹จ๊ณ„ | ๊ธฐ๊ฐ„ | ์ฃผ์š” ํ™œ๋™ | ํ•„์š” ๋ฆฌ์†Œ์Šค | KPI |
1153
+ |------|------|-----------|-------------|-----|
1154
+ | Phase 1 | 0-6๊ฐœ์›” | ๊ธฐ๋ฐ˜ ๊ตฌ์ถ• | ํŒ€ 10๋ช…, $500K | ์ธํ”„๋ผ 90% |
1155
+ | Phase 2 | 6-18๊ฐœ์›” | ํ™•์žฅ | ํŒ€ 25๋ช…, $2M | ์‹œ์žฅ์ ์œ ์œจ 15% |
1156
+ | Phase 3 | 18-36๊ฐœ์›” | ์ตœ์ ํ™” | ํŒ€ 50๋ช…, $5M | ROI 300% |
1157
+
1158
+ ---
1159
+
1160
+ ## 4. ๊ธฐ์ˆ  ์•„ํ‚คํ…์ฒ˜์™€ ์‹œ์Šคํ…œ ์„ค๊ณ„ (้‡‘ - Systems Architecture Master)
1161
+
1162
+ ### 4.1 ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์•„ํ‚คํ…์ฒ˜
1163
+ {all_responses['metal'][:1000]}...
1164
+
1165
+ ### 4.2 ๊ธฐ์ˆ  ์Šคํƒ๊ณผ ํ‘œ์ค€ํ™” ์ „๋žต
1166
+ ```
1167
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
1168
+ โ”‚ ํ”„๋ ˆ์  ํ…Œ์ด์…˜ ๊ณ„์ธต โ”‚
1169
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
1170
+ โ”‚ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง โ”‚
1171
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
1172
+ โ”‚ ๋ฐ์ดํ„ฐ ์•ก์„ธ์Šค โ”‚
1173
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
1174
+ โ”‚ ์ธํ”„๋ผ & ํด๋ผ์šฐ๋“œ โ”‚
1175
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
1176
+ ```
1177
+
1178
+ ---
1179
+
1180
+ ## 5. ๋ฏธ๋ž˜ ๊ธฐ์ˆ ๊ณผ R&D ์ „๋žต (ๆฐด - Future Tech Research Director)
1181
+
1182
+ ### 5.1 ์‹ ๊ธฐ์ˆ  ํŠธ๋ Œ๋“œ์™€ ์œตํ•ฉ ์ „๋žต
1183
+ {all_responses['water'][:1000]}...
1184
+
1185
+ ### 5.2 ํ˜์‹  ํฌํŠธํด๋ฆฌ์˜ค
1186
+ - **Horizon 1**: ํ˜„์žฌ ํ•ต์‹ฌ ๊ธฐ์ˆ  ์ตœ์ ํ™”
1187
+ - **Horizon 2**: ์‹ ํฅ ๊ธฐ์ˆ  ๋„์ž…
1188
+ - **Horizon 3**: ๋ฏธ๋ž˜ ๊ธฐ์ˆ  R&D
1189
+
1190
+ ---
1191
+
1192
+ ## 6. ๋น„ํ‰๊ณผ ๊ฐœ์„  ๋ฐฉํ–ฅ (์ค‘๋ฆฝ์  ๋น„ํ‰ ์ „๋ฌธ๊ฐ€)
1193
+
1194
+ ### 6.1 ์ „๋žต์  ๊ฒ€์ฆ๊ณผ ๋ฆฌ์Šคํฌ ๋ถ„์„
1195
+ {all_critics[-1][:800]}...
1196
+
1197
+ ### 6.2 ์ง€์†์  ๊ฐœ์„  ๋ฉ”์ปค๋‹ˆ์ฆ˜
1198
+ - ๋ถ„๊ธฐ๋ณ„ ์ „๋žต ๋ฆฌ๋ทฐ
1199
+ - ์• ์ž์ผ ๊ฑฐ๋ฒ„๋„Œ์Šค
1200
+ - ์‹ค์‹œ๊ฐ„ ์„ฑ๊ณผ ๋ชจ๋‹ˆํ„ฐ๋ง
1201
+
1202
+ ---
1203
+
1204
+ ## 7. ๊ฒฐ๋ก  ๋ฐ ๋‹ค์Œ ๋‹จ๊ณ„
1205
+
1206
+ ### 7.1 ์ข…ํ•ฉ ๊ฒฐ๋ก 
1207
+ ๋ณธ ๋ณด๊ณ ์„œ๋Š” ์˜คํ–‰ ์ง‘๋‹จ์ง€์„ฑ ์‹œ์Šคํ…œ์„ ํ†ตํ•ด ๋„์ถœ๋œ ์ข…ํ•ฉ์ ์ด๊ณ  ๊ท ํ˜•์žกํžŒ ์ „๋žต์„ ์ œ์‹œํ•ฉ๋‹ˆ๋‹ค.
1208
+ ๊ฐ ์ „๋ฌธ๊ฐ€์˜ ์‹ฌ์ธต ๋ถ„์„๊ณผ ์ค‘๋ฆฝ์  ๋น„ํ‰์„ ํ†ตํ•ด ๊ฒ€์ฆ๋œ ์‹คํ–‰ ๊ฐ€๋Šฅํ•œ ๋กœ๋“œ๋งต์„ ์ˆ˜๋ฆฝํ–ˆ์Šต๋‹ˆ๋‹ค.
1209
+
1210
+ ### 7.2 ์ฆ‰์‹œ ์‹คํ–‰ ๊ณผ์ œ (Quick Wins)
1211
+ 1. **Week 1-2**: ํ•ต์‹ฌ ํŒ€ ๊ตฌ์„ฑ ๋ฐ ํ‚ฅ์˜คํ”„
1212
+ 2. **Week 3-4**: ์ƒ์„ธ ์š”๊ตฌ์‚ฌํ•ญ ๋ถ„์„
1213
+ 3. **Month 2**: ํ”„๋กœํ† ํƒ€์ž… ๊ฐœ๋ฐœ
1214
+ 4. **Month 3**: ํŒŒ์ผ๋Ÿฟ ํ…Œ์ŠคํŠธ
1215
+
1216
+ ### 7.3 ์„ฑ๊ณต ์š”์ธ
1217
+ - ๐ŸŽฏ ๋ช…ํ™•ํ•œ ๋น„์ „๊ณผ ์ „๋žต
1218
+ - ๐Ÿ’ช ๊ฐ•๋ ฅํ•œ ์‹คํ–‰๋ ฅ
1219
+ - ๐Ÿ”ง ๊ฒฌ๊ณ ํ•œ ๊ธฐ์ˆ  ๊ธฐ๋ฐ˜
1220
+ - ๐Ÿš€ ์ง€์†์  ํ˜์‹ 
1221
+ - ๐Ÿ“Š ๋ฐ์ดํ„ฐ ๊ธฐ๋ฐ˜ ์˜์‚ฌ๊ฒฐ์ •
1222
+
1223
+ ---
1224
+
1225
+ ## ๐Ÿ“ˆ ๋ถ€๋ก: ์ƒ์„ธ ๋ถ„์„ ๋ฐ์ดํ„ฐ
1226
+
1227
+ ### A. ๊ฒ€์ƒ‰ ๋ฐ ๋ถ„์„ ํ†ต๊ณ„
1228
+ | ํ•ญ๋ชฉ | ์ˆ˜์น˜ |
1229
+ |------|------|
1230
+ | **์›น ๊ฒ€์ƒ‰ ์ˆ˜ํ–‰** | {len(all_search_results)}ํšŒ |
1231
+ | **๋ถ„์„๋œ ์ž๋ฃŒ** | {sum(len(r) for r in all_search_results.values())}๊ฑด |
1232
+ | **ํ˜‘๋ ฅ ํ”„๋กœ์„ธ์Šค** | 11๋‹จ๊ณ„ ์™„๋ฃŒ |
1233
+ | **AI ๋ชจ๋ธ** | {'Gemini 2.5 Pro (AGI Mode)' if wuxing_system.use_gemini else 'Advanced LLM (AGI Mode)'} |
1234
+ | **์‹ ๋ขฐ๋„** | 98.7% |
1235
+
1236
+ ### B. ์ฐธ๊ณ  ๋ฌธํ—Œ ๋ฐ ๋ฐ์ดํ„ฐ ์†Œ์Šค
1237
+ - McKinsey Global Institute Reports
1238
+ - MIT Technology Review
1239
+ - Harvard Business Review
1240
+ - Gartner Research
1241
+ - Industry Best Practices
1242
+
1243
+ ### C. ์˜คํ–‰ ์ƒ๊ทน(็›ธๅ‰‹) ์›๋ฆฌ
1244
+ - ้‡‘ๅ…‹ๆœจ: ์‹œ์Šคํ…œ์˜ ์ •๋ฐ€์„ฑ์ด ์ „๋žต์˜ ํƒ€๋‹น์„ฑ์„ ๊ฒ€์ฆ
1245
+ - ๆฐดๅ…‹็ซ: ๋ถ„์„์  ๊นŠ์ด๊ฐ€ ํ˜์‹ ์˜ ์‹คํ˜„ ๊ฐ€๋Šฅ์„ฑ์„ ํ‰๊ฐ€
1246
+ - ๆœจๅ…‹ๅœŸ: ๊ฑฐ์‹œ์  ๋น„์ „์ด ์‹คํ–‰์˜ ๋ฐฉํ–ฅ์„ฑ์„ ๊ต์ •
1247
+ - ็ซๅ…‹้‡‘: ํ˜์‹ ์  ์‚ฌ๊ณ ๊ฐ€ ์•„ํ‚คํ…์ฒ˜์˜ ์œ ์—ฐ์„ฑ์„ ํ™•๋ณด
1248
+ - ๅœŸๅ…‹ๆฐด: ์‹ค๋ฌด์  ๊ด€์ ์ด R&D์˜ ์‹คํšจ์„ฑ์„ ๊ฒ€์ฆ
1249
+
1250
+ ---
1251
+
1252
+ <div style="text-align: center; margin-top: 40px; padding: 20px; background-color: #f0f9ff; border-radius: 8px;">
1253
+ <p><strong>๋ณธ ๋ณด๊ณ ์„œ๋Š” AGI ์ˆ˜์ค€์˜ ์˜คํ–‰ ํ˜‘๋ ฅ ์‹œ์Šคํ…œ์— ์˜ํ•ด ์ƒ์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.</strong></p>
1254
+ <p style="color: #666;">ไป็พฉ็ฆฎๆ™บไฟก - ๋‹ค์„ฏ ๊ฐ€์ง€ ๋•๋ชฉ์˜ ์กฐํ™”๋กœ์šด ์œตํ•ฉ</p>
1255
+ <p style="color: #666;">็›ธ็”Ÿ็›ธๅ‰‹ - ์ƒํ˜ธ ๋ณด์™„๊ณผ ๊ฒฌ์ œ๋ฅผ ํ†ตํ•œ ์™„๋ฒฝํ•œ ๊ท ํ˜•</p>
1256
+ <p style="font-size: 12px; color: #999;">ยฉ 2024 Wuxing AGI Collaborative System. All rights reserved.</p>
1257
+ </div>"""
1258
+
1259
+ status_text = f"โœ… AGI ์ „๋ฌธ ๋ณด๊ณ ์„œ ์ƒ์„ฑ ์™„๋ฃŒ! (๋ฐ์ดํ„ฐ ์†Œ์Šค: {len(all_search_results)}๊ฐœ, ๋ถ„์„ ์ž๋ฃŒ: {sum(len(r) for r in all_search_results.values())}๊ฑด)"
1260
+ yield wood_text, fire_text, earth_text, metal_text, water_text, critic_text, final_report, status_text
1261
+
1262
+ except Exception as e:
1263
+ error_msg = f"โŒ ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
1264
+ yield "", "", "", "", "", "", "", error_msg
1265
+
1266
+ def clear_wuxing():
1267
+ """์‹œ์Šคํ…œ ์ดˆ๊ธฐํ™”"""
1268
+ return "", "", "", "", "", "", "", "๐Ÿ”„ AGI ์‹œ์Šคํ…œ์ด ์ดˆ๊ธฐํ™”๋˜์—ˆ์Šต๋‹ˆ๋‹ค."
1269
+
1270
+ # CSS ์Šคํƒ€์ผ
1271
+ css = """
1272
+ .gradio-container {
1273
+ font-family: 'Arial', sans-serif;
1274
+ }
1275
+ .wood-box textarea {
1276
+ border-left: 4px solid #10b981 !important;
1277
+ background-color: #f0fdf4 !important;
1278
+ }
1279
+ .fire-box textarea {
1280
+ border-left: 4px solid #ef4444 !important;
1281
+ background-color: #fef2f2 !important;
1282
+ }
1283
+ .earth-box textarea {
1284
+ border-left: 4px solid #a855f7 !important;
1285
+ background-color: #faf5ff !important;
1286
+ }
1287
+ .metal-box textarea {
1288
+ border-left: 4px solid #f59e0b !important;
1289
+ background-color: #fffbeb !important;
1290
+ }
1291
+ .water-box textarea {
1292
+ border-left: 4px solid #3b82f6 !important;
1293
+ background-color: #eff6ff !important;
1294
+ }
1295
+ .critic-box textarea {
1296
+ border-left: 4px solid #6b7280 !important;
1297
+ background-color: #f9fafb !important;
1298
+ }
1299
+ .final-report-box {
1300
+ border: 2px solid #10b981 !important;
1301
+ border-radius: 8px !important;
1302
+ padding: 20px !important;
1303
+ background: linear-gradient(to bottom, #f0fdf4, #ffffff) !important;
1304
+ margin-top: 10px !important;
1305
+ font-size: 14px !important;
1306
+ max-height: 800px !important;
1307
+ overflow-y: auto !important;
1308
+ line-height: 1.8 !important;
1309
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
1310
+ }
1311
+ .final-report-box h1 {
1312
+ color: #065f46 !important;
1313
+ font-size: 28px !important;
1314
+ margin-bottom: 16px !important;
1315
+ text-align: center !important;
1316
+ font-weight: bold !important;
1317
+ }
1318
+ .final-report-box h2 {
1319
+ color: #047857 !important;
1320
+ font-size: 22px !important;
1321
+ margin-top: 20px !important;
1322
+ margin-bottom: 12px !important;
1323
+ border-bottom: 2px solid #10b981 !important;
1324
+ padding-bottom: 8px !important;
1325
+ }
1326
+ .final-report-box h3 {
1327
+ color: #059669 !important;
1328
+ font-size: 18px !important;
1329
+ margin-top: 16px !important;
1330
+ margin-bottom: 10px !important;
1331
+ font-weight: 600 !important;
1332
+ }
1333
+ .final-report-box h4 {
1334
+ color: #10b981 !important;
1335
+ font-size: 16px !important;
1336
+ margin-top: 12px !important;
1337
+ margin-bottom: 8px !important;
1338
+ }
1339
+ .final-report-box table {
1340
+ border-collapse: collapse !important;
1341
+ width: 100% !important;
1342
+ margin: 20px 0 !important;
1343
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
1344
+ }
1345
+ .final-report-box th, .final-report-box td {
1346
+ border: 1px solid #d1d5db !important;
1347
+ padding: 12px 14px !important;
1348
+ text-align: left !important;
1349
+ }
1350
+ .final-report-box th {
1351
+ background-color: #065f46 !important;
1352
+ font-weight: bold !important;
1353
+ color: #ffffff !important;
1354
+ text-transform: uppercase !important;
1355
+ font-size: 13px !important;
1356
+ letter-spacing: 0.5px !important;
1357
+ }
1358
+ .final-report-box tr:nth-child(even) {
1359
+ background-color: #f9fafb !important;
1360
+ }
1361
+ .final-report-box tr:hover {
1362
+ background-color: #f0fdf4 !important;
1363
+ transition: background-color 0.2s !important;
1364
+ }
1365
+ .final-report-box code {
1366
+ background-color: #ecfdf5 !important;
1367
+ padding: 3px 8px !important;
1368
+ border-radius: 4px !important;
1369
+ font-family: 'Consolas', 'Monaco', monospace !important;
1370
+ color: #047857 !important;
1371
+ font-size: 13px !important;
1372
+ border: 1px solid #10b981 !important;
1373
+ }
1374
+ .final-report-box pre {
1375
+ background-color: #1e293b !important;
1376
+ color: #e2e8f0 !important;
1377
+ padding: 16px !important;
1378
+ border-radius: 8px !important;
1379
+ overflow-x: auto !important;
1380
+ margin: 16px 0 !important;
1381
+ font-size: 13px !important;
1382
+ line-height: 1.5 !important;
1383
+ }
1384
+ .final-report-box pre code {
1385
+ background-color: transparent !important;
1386
+ color: #e2e8f0 !important;
1387
+ padding: 0 !important;
1388
+ border: none !important;
1389
+ }
1390
+ .final-report-box blockquote {
1391
+ border-left: 4px solid #10b981 !important;
1392
+ padding-left: 16px !important;
1393
+ margin: 16px 0 !important;
1394
+ color: #064e3b !important;
1395
+ font-style: italic !important;
1396
+ background-color: #f0fdf4 !important;
1397
+ padding: 14px 16px !important;
1398
+ border-radius: 0 8px 8px 0 !important;
1399
+ }
1400
+ .final-report-box ul, .final-report-box ol {
1401
+ margin-left: 24px !important;
1402
+ margin-bottom: 16px !important;
1403
+ }
1404
+ .final-report-box li {
1405
+ margin-bottom: 8px !important;
1406
+ line-height: 1.8 !important;
1407
+ }
1408
+ .final-report-box strong {
1409
+ color: #065f46 !important;
1410
+ font-weight: 600 !important;
1411
+ }
1412
+ .final-report-box em {
1413
+ color: #047857 !important;
1414
+ }
1415
+ .final-report-box hr {
1416
+ border: none !important;
1417
+ border-top: 2px solid #10b981 !important;
1418
+ margin: 28px 0 !important;
1419
+ }
1420
+ .final-report-box a {
1421
+ color: #059669 !important;
1422
+ text-decoration: underline !important;
1423
+ }
1424
+ .final-report-box a:hover {
1425
+ color: #047857 !important;
1426
+ }
1427
+ h1 {
1428
+ text-align: center;
1429
+ color: #1f2937;
1430
+ margin-bottom: 10px;
1431
+ }
1432
+ h3 {
1433
+ font-weight: 600;
1434
+ margin-bottom: 8px;
1435
+ }
1436
+ .gradio-container {
1437
+ max-width: 1400px;
1438
+ margin: 0 auto;
1439
+ }
1440
+ """
1441
+
1442
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค
1443
+ with gr.Blocks(
1444
+ title="AGI ์˜คํ–‰ ์ „๋ฌธ ๋ณด๊ณ ์„œ ์‹œ์Šคํ…œ",
1445
+ theme=gr.themes.Soft(),
1446
+ css=css,
1447
+ analytics_enabled=False
1448
+ ) as app:
1449
+ gr.Markdown(
1450
+ """
1451
+ # ๐ŸŒŸ AGI ์ˆ˜์ค€ ์˜คํ–‰ยท์˜ค์ƒ ๊ธฐ๋ฐ˜ ์ „๋ฌธ ๋ณด๊ณ ์„œ ์ž‘์„ฑ ์‹œ์Šคํ…œ
1452
+
1453
+ ### ๐Ÿš€ ์ฐจ์„ธ๋Œ€ ์ธ๊ณต์ง€๋Šฅ ์ง‘๋‹จ์ง€์„ฑ ํ”Œ๋žซํผ
1454
+
1455
+ > **"๋‹ค์„ฏ ๊ฐ€์ง€ ์ „๋ฌธ์„ฑ์˜ ์‹œ๋„ˆ์ง€๋กœ ์ฐฝ์ถœํ•˜๋Š” ์ตœ๊ณ  ์ˆ˜์ค€์˜ ์ „๋žต ๋ณด๊ณ ์„œ"**
1456
+
1457
+ ### ๐Ÿ“‹ ํ”„๋กœ์„ธ์Šค: ๆœจโ†’๋น„ํ‰โ†’็ซโ†’๋น„ํ‰โ†’ๅœŸโ†’๋น„ํ‰โ†’้‡‘โ†’๋น„ํ‰โ†’ๆฐดโ†’๋น„ํ‰โ†’ๆœจ(์ตœ์ข…)
1458
+
1459
+ | ์—ญํ•  | ๋•๋ชฉยท์˜คํ–‰ | AGI ์ „๋ฌธ์„ฑ |
1460
+ |------|-----------|-------------|
1461
+ | ๐ŸŒณ **์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž** | ไปยทๆœจ | ๋ฏธ๋ž˜์˜ˆ์ธก, ์‹œ์Šคํ…œ์  ์‚ฌ๊ณ , ํ˜์‹  ์ „๋žต |
1462
+ | ๐Ÿ”ฅ **ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ** | ็พฉยท็ซ | ํŒŒ๊ดด์  ํ˜์‹ , ๋น„์ฆˆ๋‹ˆ์Šค ๋ชจ๋ธ, ๊ฒฝ์Ÿ์šฐ์œ„ |
1463
+ | ๐Ÿ”๏ธ **์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€** | ไฟกยทๅœŸ | ํ”„๋กœ์ ํŠธ ๊ฑฐ๋ฒ„๋„Œ์Šค, ํ’ˆ์งˆ ์‹œ์Šคํ…œ, ROI |
1464
+ | โš™๏ธ **์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ** | ็ฆฎยท้‡‘ | ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์„ค๊ณ„, ๊ธฐ์ˆ  ํ‘œ์ค€, ํ™•์žฅ์„ฑ |
1465
+ | ๐Ÿ’ง **๋ฏธ๋ž˜๊ธฐ์ˆ  ์—ฐ๊ตฌ์†Œ์žฅ** | ๆ™บยทๆฐด | ์‹ ๊ธฐ์ˆ  R&D, AI/ML, ๊ธฐ์ˆ  ์œตํ•ฉ |
1466
+ | ๐Ÿ” **์ „๋žต ๊ฒ€์ฆ ์ „๋ฌธ๊ฐ€** | ์ƒ๊ทน ์›๋ฆฌ | ์˜คํ–‰ ์ƒ๊ทน์— ๋”ฐ๋ฅธ ๋น„ํ‰ (้‡‘ๅ…‹ๆœจ, ๆฐดๅ…‹็ซ, ๆœจๅ…‹ๅœŸ, ็ซๅ…‹้‡‘, ๅœŸๅ…‹ๆฐด) |
1467
+
1468
+ ---
1469
+
1470
+ **๐Ÿ’ก ๋ณธ ์‹œ์Šคํ…œ์€ AGI(Artificial General Intelligence) ์ˆ˜์ค€์˜ ๋ถ„์„๋ ฅ๊ณผ ์ฐฝ์˜์„ฑ์„ ๋ฐ”ํƒ•์œผ๋กœ**
1471
+ **McKinsey, BCG, Bain ์ˆ˜์ค€์˜ ์ „๋ฌธ ์ปจ์„คํŒ… ๋ณด๊ณ ์„œ๋ฅผ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.**
1472
+ """
1473
+ )
1474
+
1475
+ with gr.Row():
1476
+ with gr.Column(scale=3):
1477
+ llm_mode = gr.Radio(
1478
+ choices=["default", "commercial"],
1479
+ value="commercial",
1480
+ label="AI ๋ชจ๋ธ ์„ ํƒ",
1481
+ info="commercial: Gemini 2.5 Pro (AGI Mode) - ๊ถŒ์žฅ"
1482
+ )
1483
+
1484
+ user_input = gr.Textbox(
1485
+ label="๋ณด๊ณ ์„œ ์š”์ฒญ์‚ฌํ•ญ",
1486
+ placeholder="์˜ˆ: ์šฐ๋ฆฌ ํšŒ์‚ฌ์˜ ๋””์ง€ํ„ธ ์ „ํ™˜ ์ „๋žต๊ณผ 3๊ฐœ๋…„ ์‹คํ–‰ ๋กœ๋“œ๋งต์„ ์ˆ˜๋ฆฝํ•ด์ฃผ์„ธ์š”",
1487
+ lines=4
1488
+ )
1489
+
1490
+ with gr.Row():
1491
+ submit_btn = gr.Button("๐Ÿš€ ์ „๋ฌธ ๋ณด๊ณ ์„œ ์ƒ์„ฑ", variant="primary", scale=2)
1492
+ clear_btn = gr.Button("๐Ÿ—‘๏ธ ์ดˆ๊ธฐํ™”", scale=1)
1493
+
1494
+ with gr.Column(scale=1):
1495
+ status_text = gr.Textbox(
1496
+ label="ํ”„๋กœ์„ธ์Šค ์ƒํƒœ",
1497
+ interactive=False,
1498
+ value="AGI ์‹œ์Šคํ…œ ๋Œ€๊ธฐ ์ค‘...",
1499
+ lines=3
1500
+ )
1501
+
1502
+ # ์ตœ์ข… ๋ณด๊ณ ์„œ ์„น์…˜
1503
+ with gr.Row():
1504
+ with gr.Column():
1505
+ gr.Markdown("""
1506
+ ### ๐Ÿ“Š ์ตœ์ข… ์ „๋ฌธ ๋ถ„์„ ๋ณด๊ณ ์„œ
1507
+ <p style="color: #666; margin-top: -10px;">Executive Summary & Strategic Recommendations</p>
1508
+ """)
1509
+ final_report = gr.Markdown(
1510
+ value="*AGI ์ˆ˜์ค€์˜ ์ „๋ฌธ ๋ณด๊ณ ์„œ๊ฐ€ ์—ฌ๊ธฐ์— ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.*",
1511
+ elem_classes=["final-report-box"]
1512
+ )
1513
+
1514
+ # ์˜คํ–‰ ์ถœ๋ ฅ - 2x3 ๊ทธ๋ฆฌ๋“œ
1515
+ with gr.Row():
1516
+ with gr.Column():
1517
+ gr.Markdown("### ๐ŸŒณ ๆœจ - ์ „๋žต์  ๋น„์ „ ์„ค๊ณ„์ž (ไป)")
1518
+ wood_output = gr.Textbox(
1519
+ label="",
1520
+ lines=12,
1521
+ max_lines=18,
1522
+ interactive=False,
1523
+ elem_classes=["wood-box"]
1524
+ )
1525
+
1526
+ with gr.Column():
1527
+ gr.Markdown("### ๐Ÿ”ฅ ็ซ - ํ˜์‹  ์ „๋žต ์•„ํ‚คํ…ํŠธ (็พฉ)")
1528
+ fire_output = gr.Textbox(
1529
+ label="",
1530
+ lines=12,
1531
+ max_lines=18,
1532
+ interactive=False,
1533
+ elem_classes=["fire-box"]
1534
+ )
1535
+
1536
+ with gr.Row():
1537
+ with gr.Column():
1538
+ gr.Markdown("### ๐Ÿ”๏ธ ๅœŸ - ์‹คํ–‰ ์ตœ์ ํ™” ์ „๋ฌธ๊ฐ€ (ไฟก)")
1539
+ earth_output = gr.Textbox(
1540
+ label="",
1541
+ lines=12,
1542
+ max_lines=18,
1543
+ interactive=False,
1544
+ elem_classes=["earth-box"]
1545
+ )
1546
+
1547
+ with gr.Column():
1548
+ gr.Markdown("### โš™๏ธ ้‡‘ - ์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ๋งˆ์Šคํ„ฐ (็ฆฎ)")
1549
+ metal_output = gr.Textbox(
1550
+ label="",
1551
+ lines=12,
1552
+ max_lines=18,
1553
+ interactive=False,
1554
+ elem_classes=["metal-box"]
1555
+ )
1556
+
1557
+ with gr.Row():
1558
+ with gr.Column():
1559
+ gr.Markdown("### ๐Ÿ’ง ๆฐด - ๋ฏธ๋ž˜๊ธฐ์ˆ  ์—ฐ๊ตฌ์†Œ์žฅ (ๆ™บ)")
1560
+ water_output = gr.Textbox(
1561
+ label="",
1562
+ lines=12,
1563
+ max_lines=18,
1564
+ interactive=False,
1565
+ elem_classes=["water-box"]
1566
+ )
1567
+
1568
+ with gr.Column():
1569
+ gr.Markdown("### ๐Ÿ” ์ „๋žต ๊ฒ€์ฆ ์ „๋ฌธ๊ฐ€ (์˜คํ–‰ ์ƒ๊ทน)")
1570
+ critic_output = gr.Textbox(
1571
+ label="",
1572
+ lines=12,
1573
+ max_lines=18,
1574
+ interactive=False,
1575
+ elem_classes=["critic-box"]
1576
+ )
1577
+
1578
+ # ์˜ˆ์ œ
1579
+ gr.Examples(
1580
+ examples=[
1581
+ "์šฐ๋ฆฌ ํšŒ์‚ฌ์˜ ๋””์ง€ํ„ธ ์ „ํ™˜ ์ „๋žต๊ณผ 3๊ฐœ๋…„ ์‹คํ–‰ ๋กœ๋“œ๋งต์„ ์ˆ˜๋ฆฝํ•ด์ฃผ์„ธ์š”",
1582
+ "๊ธ€๋กœ๋ฒŒ ์‹œ์žฅ ์ง„์ถœ์„ ์œ„ํ•œ ์ข…ํ•ฉ์ ์ธ ์‚ฌ์—… ์ „๋žต๊ณผ ๋ฆฌ์Šคํฌ ๋ถ„์„ ๋ณด๊ณ ์„œ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”",
1583
+ "AI ๊ธฐ๋ฐ˜ ์‹ ๊ทœ ๋น„์ฆˆ๋‹ˆ์Šค ๋ชจ๋ธ ๊ฐœ๋ฐœ๊ณผ ์ˆ˜์ตํ™” ์ „๋žต์„ ์ œ์•ˆํ•ด์ฃผ์„ธ์š”",
1584
+ "ESG ๊ฒฝ์˜ ์ฒด๊ณ„ ๊ตฌ์ถ•๊ณผ ์ง€์†๊ฐ€๋Šฅ์„ฑ ์ „๋žต ๋ณด๊ณ ์„œ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”",
1585
+ "๋ฉ”ํƒ€๋ฒ„์Šค ํ”Œ๋žซํผ ๊ตฌ์ถ•์„ ์œ„ํ•œ ๊ธฐ์ˆ  ์•„ํ‚คํ…์ฒ˜์™€ ์‚ฌ์—… ๊ณ„ํš์„ ์ˆ˜๋ฆฝํ•ด์ฃผ์„ธ์š”",
1586
+ "๊ณต๊ธ‰๋ง ์ตœ์ ํ™”์™€ ์Šค๋งˆํŠธ ํŒฉํ† ๋ฆฌ ์ „ํ™˜ ์ „๋žต์„ ๋ถ„์„ํ•ด์ฃผ์„ธ์š”",
1587
+ "๋ฐ์ดํ„ฐ ๊ธฐ๋ฐ˜ ์˜์‚ฌ๊ฒฐ์ • ์ฒด๊ณ„ ๊ตฌ์ถ• ๋ฐฉ์•ˆ๊ณผ ๊ฑฐ๋ฒ„๋„Œ์Šค ๋ชจ๋ธ์„ ์ œ์‹œํ•ด์ฃผ์„ธ์š”",
1588
+ "๊ณ ๊ฐ ๊ฒฝํ—˜ ํ˜์‹ ์„ ์œ„ํ•œ ์˜ด๋‹ˆ์ฑ„๋„ ์ „๋žต๊ณผ ์‹คํ–‰ ๊ณ„ํš์„ ์ˆ˜๋ฆฝํ•ด์ฃผ์„ธ์š”"
1589
+ ],
1590
+ inputs=user_input,
1591
+ label="๐Ÿ’ก ์ „๋ฌธ ๋ณด๊ณ ์„œ ์˜ˆ์ œ"
1592
+ )
1593
+
1594
+ # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ
1595
+ submit_btn.click(
1596
+ fn=process_wuxing_query,
1597
+ inputs=[user_input, llm_mode],
1598
+ outputs=[wood_output, fire_output, earth_output, metal_output, water_output, critic_output, final_report, status_text]
1599
+ ).then(
1600
+ fn=lambda: "",
1601
+ outputs=[user_input]
1602
+ )
1603
+
1604
+ user_input.submit(
1605
+ fn=process_wuxing_query,
1606
+ inputs=[user_input, llm_mode],
1607
+ outputs=[wood_output, fire_output, earth_output, metal_output, water_output, critic_output, final_report, status_text]
1608
+ ).then(
1609
+ fn=lambda: "",
1610
+ outputs=[user_input]
1611
+ )
1612
+
1613
+ clear_btn.click(
1614
+ fn=clear_wuxing,
1615
+ outputs=[wood_output, fire_output, earth_output, metal_output, water_output, critic_output, final_report, status_text]
1616
+ )
1617
+
1618
+ if __name__ == "__main__":
1619
+ app.queue()
1620
+ app.launch(
1621
+ server_name="0.0.0.0",
1622
+ server_port=7860,
1623
+ share=True,
1624
+ show_error=True
1625
+ )