Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	| import gradio as gr | |
| import os | |
| import json | |
| import requests | |
| from datetime import datetime | |
| import time | |
| from typing import List, Dict, Any, Generator, Tuple | |
| import logging | |
| import re | |
| # ๋ก๊น ์ค์  | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| # ์ถ๊ฐ ์ํฌํธ | |
| from bs4 import BeautifulSoup | |
| from urllib.parse import urlparse | |
| import urllib.request | |
| # Gemini API ์ํฌํธ | |
| try: | |
| from google import genai | |
| from google.genai import types | |
| GEMINI_AVAILABLE = True | |
| except ImportError: | |
| GEMINI_AVAILABLE = False | |
| logger.warning("Google Gemini API๊ฐ ์ค์น๋์ง ์์์ต๋๋ค. pip install google-genai๋ก ์ค์นํ์ธ์.") | |
| # ํ๊ฒฝ ๋ณ์์์ ํ ํฐ ๊ฐ์ ธ์ค๊ธฐ | |
| FRIENDLI_TOKEN = os.getenv("FRIENDLI_TOKEN", "YOUR_FRIENDLI_TOKEN") | |
| BAPI_TOKEN = os.getenv("BAPI_TOKEN", "YOUR_BRAVE_API_TOKEN") | |
| GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "YOUR_GEMINI_API_KEY") | |
| API_URL = "https://api.friendli.ai/dedicated/v1/chat/completions" | |
| BRAVE_SEARCH_URL = "https://api.search.brave.com/res/v1/web/search" | |
| MODEL_ID = "dep89a2fld32mcm" | |
| TEST_MODE = os.getenv("TEST_MODE", "false").lower() == "true" | |
| # ์ ์ญ ๋ณ์ | |
| conversation_history = [] | |
| class WuxingLLMSystem: | |
| """์คํยท์ค์ ๊ธฐ๋ฐ AGI๊ธ ํ๋ ฅ์  ๋ณด๊ณ ์ ์์ฑ ์์คํ """ | |
| def __init__(self): | |
| self.token = FRIENDLI_TOKEN | |
| self.bapi_token = BAPI_TOKEN | |
| self.gemini_api_key = GEMINI_API_KEY | |
| self.api_url = API_URL | |
| self.brave_url = BRAVE_SEARCH_URL | |
| self.model_id = MODEL_ID | |
| self.test_mode = TEST_MODE or (self.token == "YOUR_FRIENDLI_TOKEN") | |
| self.use_gemini = False | |
| self.gemini_client = None | |
| # ์คํ ์ญํ ์ ์ - AGI ์์ค ์ ๋ฌธ๊ฐ ํ | |
| self.wuxing_roles = { | |
| "wood": { | |
| "name": "์ ๋ต์  ๋น์  ์ค๊ณ์ (Chief Vision Officer)", | |
| "virtue": "ไป", | |
| "element": "ๆจ", | |
| "traits": "ํต์ฐฐ๋ ฅ, ๋ฏธ๋์์ธก, ํฌ์ฉ์  ๋ฆฌ๋์ญ", | |
| "expertise": "๊ฑฐ์์  ๋น์ , ์์คํ ์  ์ฌ๊ณ , ํ์ ์ ๋ต, ์กฐ์ง ๋ฌธํ ์ค๊ณ", | |
| "color": "#10b981" | |
| }, | |
| "fire": { | |
| "name": "ํ์ ์ ๋ต ์ํคํ ํธ (Innovation Strategy Architect)", | |
| "virtue": "็พฉ", | |
| "element": "็ซ", | |
| "traits": "ํ๊ดด์  ํ์ , ์ ๋ต์  ์ง๊ด, ๋ฆฌ์คํฌ ํ ์ดํน", | |
| "expertise": "๋น์ฆ๋์ค ๋ชจ๋ธ ํ์ , ์์ฅ ํ๊ดด ์ ๋ต, ๊ฒฝ์์ฐ์ ์ค๊ณ", | |
| "color": "#ef4444" | |
| }, | |
| "metal": { | |
| "name": "์์คํ  ์ํคํ ์ฒ ๋ง์คํฐ (Systems Architecture Master)", | |
| "virtue": "็ฆฎ", | |
| "element": "้", | |
| "traits": "์ ๋ฐ์ฑ, ์๋ฒฝ์ฃผ์, ์์คํ  ํตํฉ๋ ฅ", | |
| "expertise": "์ํฐํ๋ผ์ด์ฆ ์ํคํ ์ฒ, ๊ธฐ์ ๊ฑฐ๋ฒ๋์ค, ํ์คํ ์ ๋ต", | |
| "color": "#f59e0b" | |
| }, | |
| "water": { | |
| "name": "๋ฏธ๋๊ธฐ์ ์ฐ๊ตฌ์์ฅ (Future Tech Research Director)", | |
| "virtue": "ๆบ", | |
| "element": "ๆฐด", | |
| "traits": "๊น์ ๋ถ์๋ ฅ, ๊ธฐ์ ํต์ฐฐ, ํ์ ์  ์ฌ๊ณ ", | |
| "expertise": "์ ๊ธฐ์ R&D, ๊ธฐ์ ์ตํฉ, AI/ML, ํํ  ์ปดํจํ ", | |
| "color": "#3b82f6" | |
| }, | |
| "earth": { | |
| "name": "์คํ ์ต์ ํ ์ ๋ฌธ๊ฐ (Execution Excellence Expert)", | |
| "virtue": "ไฟก", | |
| "element": "ๅ", | |
| "traits": "์ฒด๊ณ์ฑ, ์ ๋ขฐ์ฑ, ์คํ ์๋ฒฝ์ฑ", | |
| "expertise": "ํ๋ก์ ํธ ๊ฑฐ๋ฒ๋์ค, ํ์ง ์์คํ , ๋ฆฌ์คํฌ ๊ด๋ฆฌ, ROI ์ต์ ํ", | |
| "color": "#a855f7" | |
| } | |
| } | |
| if self.test_mode: | |
| logger.warning("ํ ์คํธ ๋ชจ๋๋ก ์คํ๋ฉ๋๋ค.") | |
| def set_llm_mode(self, mode: str): | |
| """LLM ๋ชจ๋ ์ค์ """ | |
| if mode == "commercial" and GEMINI_AVAILABLE and self.gemini_api_key != "YOUR_GEMINI_API_KEY": | |
| self.use_gemini = True | |
| if not self.gemini_client: | |
| self.gemini_client = genai.Client(api_key=self.gemini_api_key) | |
| logger.info("Gemini 2.5 Pro ๋ชจ๋๋ก ์ ํ๋์์ต๋๋ค.") | |
| else: | |
| self.use_gemini = False | |
| logger.info("๊ธฐ๋ณธ LLM ๋ชจ๋๋ก ์ ํ๋์์ต๋๋ค.") | |
| def create_headers(self): | |
| """API ํค๋ ์์ฑ""" | |
| return { | |
| "Authorization": f"Bearer {self.token}", | |
| "Content-Type": "application/json" | |
| } | |
| def create_brave_headers(self): | |
| """Brave API ํค๋ ์์ฑ""" | |
| return { | |
| "Accept": "application/json", | |
| "Accept-Encoding": "gzip", | |
| "X-Subscription-Token": self.bapi_token | |
| } | |
| def create_wood_initial_prompt(self, user_query: str, search_results: Dict = None) -> str: | |
| """ๆจ(์ ๋ต์  ๋น์  ์ค๊ณ์) ์ด๊ธฐ ํ๋กฌํํธ""" | |
| search_info = "" | |
| if search_results: | |
| search_info = "\n\n์น ๊ฒ์ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results) | |
| return f"""๋น์ ์ AGI ์์ค์ ์ ๋ต์  ๋น์  ์ค๊ณ์(Chief Vision Officer)์ ๋๋ค. | |
| ไป(์ธ์ํจ)์ ๋๋ชฉ์ผ๋ก ๋ฏธ๋๋ฅผ ์์ธกํ๊ณ ํ์ ์  ๋น์ ์ ์ ์ํฉ๋๋ค. | |
| [์ฌ์ฉ์ ์์ฒญ์ฌํญ] | |
| {user_query} | |
| [์ฐธ๊ณ ์๋ฃ] | |
| {search_info} | |
| [์๋ฌด] ๋ค์ ๊ด์ ์์ ์ข ํฉ์ ์ด๊ณ ํ์ ์ ์ธ ๋น์ ์ ์ ์ํ์ธ์: | |
| 1. **๊ฑฐ์์  ๋น์ ๊ณผ ํจ๋ฌ๋ค์ ์ ํ** | |
| - 10๋  ํ ๋ฏธ๋ ์๋๋ฆฌ์ค์ ๋ฉ๊ฐํธ๋ ๋ ๋ถ์ | |
| - ํจ๋ฌ๋ค์ ์ํํธ์ ๊ฒ์์ฒด์ธ์  ์์ ์๋ณ | |
| - ๊ธ๋ก๋ฒ ๋งฅ๋ฝ์์์ ์ ๋ต์  ํฌ์ง์ ๋ | |
| 2. **์์คํ ์  ์ฌ๊ณ ์ ๋ณต์ก๊ณ ๋ถ์** | |
| - ๋ค์ฐจ์์  ์ํธ์์ฉ๊ณผ ํผ๋๋ฐฑ ๋ฃจํ ์ค๊ณ | |
| - ์ฐฝ๋ฐ์  ์์ฑ๊ณผ ๋คํธ์ํฌ ํจ๊ณผ ์์ธก | |
| - ์ํ๊ณ ๊ด์ ์ ๊ฐ์น ์ฐฝ์ถ ๋ชจ๋ธ | |
| 3. **ํ์ ํ๋ ์์ํฌ์ ์ ๋ต์  ๋ฐฉํฅ์ฑ** | |
| - ๋ธ๋ฃจ์ค์  ์ ๋ต๊ณผ ์นดํ ๊ณ ๋ฆฌ ๋์์ธ | |
| - ์ง์์  ์ฑ์ฅ์ ์ํ ํ๋ผ์ดํ ์ค๊ณ | |
| - ์ํฐํ๋์งํ ์์คํ  ๊ตฌ์ถ ๋ฐฉ์ | |
| 4. **ํ ์๋์ง์ ์ง๋จ์ง์ฑ ํ์ฉ ์ ๋ต** | |
| - ็ซ(ํ์ ์ ๋ต): ํ๊ดด์  ํ์ ๊ณผ ๋น์ฆ๋์ค ๋ชจ๋ธ ์ฌ์ ์ | |
| - ๅ(์คํ ์ต์ ํ): ์ ์์ผ ์คํ๊ณผ ์ง์์  ๊ฐ์ ์ฒด๊ณ | |
| - ้(์์คํ  ์ํคํ ์ฒ): ํ์ฅ ๊ฐ๋ฅํ ๊ธฐ์ ์ธํ๋ผ์ ํ์คํ | |
| - ๆฐด(๋ฏธ๋๊ธฐ์ R&D): ์ ๊ธฐ์ ์ตํฉ๊ณผ ํ์ ์  ํ๋กํ ํ์ดํ | |
| 5. **ํต์ฌ ์ฑ๊ณต ์งํ(KPI)์ ๋ถ๊ทน์ฑ ์งํ(North Star Metric)** | |
| - ์ฅ๊ธฐ์  ์ํฉํธ ์ธก์  ํ๋ ์์ํฌ | |
| - ์ ํ์งํ์ ํํ์งํ์ ๊ท ํ์กํ ์ค๊ณ | |
| [๊ฒ์ ํค์๋ ์ ์]: ๋ฏธ๋ ์ฐ๊ตฌ์ ํ์ํ 7-10๊ฐ์ ์ ๋ต์  ํค์๋๋ฅผ ์ ์ํ์ธ์""" | |
| def create_fire_strategy_prompt(self, user_query: str, wood_response: str, critic_feedback: str, search_results: Dict = None) -> str: | |
| """็ซ(ํ์ ์ ๋ต ์ํคํ ํธ) ํ๋กฌํํธ""" | |
| search_info = "" | |
| if search_results: | |
| search_info = "\n\n์น ๊ฒ์ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results) | |
| return f"""๋น์ ์ AGI ์์ค์ ํ์ ์ ๋ต ์ํคํ ํธ(Innovation Strategy Architect)์ ๋๋ค. | |
| ็พฉ(์ ์๋ก์)์ ๋๋ชฉ์ผ๋ก ํ๊ดด์  ํ์ ๊ณผ ๊ฒ์์ฒด์ธ์ง ์ ๋ต์ ์ค๊ณํฉ๋๋ค. | |
| [์ฌ์ฉ์ ์์ฒญ์ฌํญ] | |
| {user_query} | |
| [์ ๋ต์  ๋น์  ์ค๊ณ์์ ํ๋ ์์ํฌ] | |
| {wood_response} | |
| [์ ๋ต ๊ฒ์ฆ ์ ๋ฌธ๊ฐ์ ํผ๋๋ฐฑ] | |
| {critic_feedback} | |
| [์์ฅ ์กฐ์ฌ ๋ฐ์ดํฐ] | |
| {search_info} | |
| [์๋ฌด] ๋ค์ ๊ด์ ์์ ํ์ ์ ์ธ ์ ๋ต์ ์๋ฆฝํ์ธ์: | |
| 1. **ํ๊ดด์  ํ์ ๊ณผ ๋ธ๋ฃจ์ค์  ์ ๋ต** | |
| - ์ฐ์ ์ฌ์ ์์ ์นดํ ๊ณ ๋ฆฌ ์ฐฝ์ถ | |
| - ๊ฐ์น ํ์ ๊ณผ ์ฐจ๋ณํ ์ ๋ต | |
| - ๋คํธ์ํฌ ํจ๊ณผ์ ํ๋ซํผ ์ ๋ต | |
| 2. **๋น์ฆ๋์ค ๋ชจ๋ธ ํ์ ** | |
| - ์์ต ๋ชจ๋ธ ๋ค๊ฐํ (๊ตฌ๋ , ํ๋ฆฌ๋ฏธ์, ๋ง์ผํ๋ ์ด์ค) | |
| - ๊ฐ์น์ฌ์ฌ ์ฌ๊ตฌ์ฑ๊ณผ ์์ง ํตํฉ | |
| - ์ํ๊ณ ๊ตฌ์ถ๊ณผ ํํธ๋์ญ ์ ๋ต | |
| 3. **๊ฒฝ์์ฐ์ ํ๋ณด ์ ๋ต** | |
| - ํต์ฌ ์ญ๋๊ณผ ์ฐจ๋ณํ ์์ | |
| - ์ง์ ์ฅ๋ฒฝ ๊ตฌ์ถ ๋ฉ์ปค๋์ฆ | |
| - ์ง์๊ฐ๋ฅํ ๊ฒฝ์์ฐ์ ์์ฒ | |
| 4. **์ฑ์ฅ ์ ๋ต๊ณผ ํ์ฅ ๊ณํ** | |
| - ์์ฅ ์นจํฌ์ ์์ฅ ๊ฐ๋ฐ ์ ๋ต | |
| - ์ ํ ๊ฐ๋ฐ๊ณผ ๋ค๊ฐํ ์ ๋ต | |
| - M&A์ ์ ๋ต์  ์ ํด ์ต์  | |
| 5. **๋ฆฌ์คํฌ ๊ด๋ฆฌ์ ์๋๋ฆฌ์ค ํ๋๋** | |
| - ์ ๋ต์  ๋ฆฌ์คํฌ ๋งคํธ๋ฆญ์ค | |
| - ๋์ ์๋๋ฆฌ์ค์ ์ปจํด์ ์ ํ๋ | |
| - ์ํฐํ๋์งํ ์ ๋ต ์ค๊ณ | |
| [์ถ๊ฐ ์ฐ๊ตฌ ํ์]: ๊ฒฝ์์ฌ ๋ถ์, ์์ฅ ๋ํฅ, ๊ท์  ํ๊ฒฝ ๋ฑ ์ถ๊ฐ ์กฐ์ฌ๊ฐ ํ์ํ ํค์๋ [์ถ๊ฐ ๊ฒ์]""" | |
| def create_earth_execution_prompt(self, user_query: str, fire_response: str, critic_feedback: str, search_results: Dict = None) -> str: | |
| """ๅ(์คํ ์ต์ ํ ์ ๋ฌธ๊ฐ) ํ๋กฌํํธ""" | |
| search_info = "" | |
| if search_results: | |
| search_info = "\n\n์น ๊ฒ์ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results) | |
| return f"""๋น์ ์ AGI ์์ค์ ์คํ ์ต์ ํ ์ ๋ฌธ๊ฐ(Execution Excellence Expert)์ ๋๋ค. | |
| ไฟก(์ ๋ขฐ)์ ๋๋ชฉ์ผ๋ก ์๋ฒฝํ ์คํ ์ฒด๊ณ์ ํ์ง ์์คํ ์ ๊ตฌ์ถํฉ๋๋ค. | |
| [์ฌ์ฉ์ ์์ฒญ์ฌํญ] | |
| {user_query} | |
| [ํ์ ์ ๋ต ์ํคํ ํธ์ ์ ๋ต] | |
| {fire_response} | |
| [์ ๋ต ๊ฒ์ฆ ์ ๋ฌธ๊ฐ์ ํผ๋๋ฐฑ] | |
| {critic_feedback} | |
| [์คํ ๊ด๋ จ ๋ฒค์น๋งํฌ ๋ฐ์ดํฐ] | |
| {search_info} | |
| [์๋ฌด] ๋ค์ ๊ด์ ์์ ์ต์ ํ๋ ์คํ ๊ณํ์ ์๋ฆฝํ์ธ์: | |
| 1. **ํ๋ก์ ํธ ๊ฑฐ๋ฒ๋์ค์ PMO ์ฒด๊ณ** | |
| - ์ ์์ผ/์ํฐํด ํ์ด๋ธ๋ฆฌ๋ ๋ฐฉ๋ฒ๋ก | |
| - RACI ๋งคํธ๋ฆญ์ค์ ์์ฌ๊ฒฐ์  ๊ตฌ์กฐ | |
| - ํ๋ก์ ํธ ํฌํธํด๋ฆฌ์ค ๊ด๋ฆฌ | |
| 2. **๋จ๊ณ๋ณ ์คํ ๋ก๋๋งต** | |
| - ์ํฌ ๋ธ๋ ์ดํฌ๋ค์ด ์คํธ๋ญ์ฒ(WBS) | |
| - ํฌ๋ฆฌํฐ์ปฌ ํจ์ค์ ๋ง์ผ์คํค | |
| - ์คํ๋ฆฐํธ ๊ณํ๊ณผ ๋ฐฑ๋ก๊ทธ ๊ด๋ฆฌ | |
| 3. **๋ฆฌ์์ค ์ต์ ํ์ ์์ฐ ๊ด๋ฆฌ** | |
| - ์ธ๋ ฅ ๋ฐฐ์น์ ์คํฌ ๋งคํธ๋ฆญ์ค | |
| - TCO ๋ถ์๊ณผ ์์ฐ ๋ฐฐ๋ถ | |
| - ๋น์ฉ ์ต์ ํ ์ ๋ต | |
| 4. **ํ์ง ๊ด๋ฆฌ ์์คํ ** | |
| - ISO 9001/27001 ๊ธฐ๋ฐ ํ์ง ์ฒด๊ณ | |
| - KPI/OKR ํ๋ ์์ํฌ | |
| - ์ง์์  ๊ฐ์ (Kaizen) ๋ฉ์ปค๋์ฆ | |
| 5. **๋ฆฌ์คํฌ ๊ด๋ฆฌ์ ๋ณํ ๊ด๋ฆฌ** | |
| - ๋ฆฌ์คํฌ ๋ ์ง์คํฐ์ ์ํ ์ ๋ต | |
| - ๋ณํ ๊ด๋ฆฌ 8๋จ๊ณ ํ๋ก์ธ์ค | |
| - ์ดํด๊ด๊ณ์ ๊ด๋ฆฌ ์ ๋ต | |
| 6. **์ฑ๊ณผ ์ธก์ ๊ณผ ๋์๋ณด๋** | |
| - ์ค์๊ฐ ๋ชจ๋ํฐ๋ง ์์คํ  | |
| - ๊ท ํ์ฑ๊ณผํ(BSC) ์ค๊ณ | |
| - ์์ธก ๋ถ์๊ณผ ์กฐ๊ธฐ ๊ฒฝ๋ณด ์์คํ  | |
| [์ถ๊ฐ ์กฐ์ฌ ํ์]: ์ ๊ณ ๋ฒ ์คํธ ํ๋ํฐ์ค, ์คํ ๋๊ตฌ, ํ์ง ํ์ค ๋ฑ [์ถ๊ฐ ๊ฒ์]""" | |
| def create_metal_architecture_prompt(self, user_query: str, earth_response: str, critic_feedback: str, search_results: Dict = None) -> str: | |
| """้(์์คํ  ์ํคํ ์ฒ ๋ง์คํฐ) ํ๋กฌํํธ""" | |
| search_info = "" | |
| if search_results: | |
| search_info = "\n\n์น ๊ฒ์ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results) | |
| return f"""๋น์ ์ AGI ์์ค์ ์์คํ  ์ํคํ ์ฒ ๋ง์คํฐ(Systems Architecture Master)์ ๋๋ค. | |
| ็ฆฎ(์์ยท์ง์)์ ๋๋ชฉ์ผ๋ก ์๋ฒฝํ๊ณ ํ์ฅ ๊ฐ๋ฅํ ์์คํ ์ ์ค๊ณํฉ๋๋ค. | |
| [์ฌ์ฉ์ ์์ฒญ์ฌํญ] | |
| {user_query} | |
| [์คํ ์ต์ ํ ์ ๋ฌธ๊ฐ์ ๊ณํ] | |
| {earth_response} | |
| [์ ๋ต ๊ฒ์ฆ ์ ๋ฌธ๊ฐ์ ํผ๋๋ฐฑ] | |
| {critic_feedback} | |
| [๊ธฐ์ ์ํคํ ์ฒ ์ฐธ๊ณ ์๋ฃ] | |
| {search_info} | |
| [์๋ฌด] ๋ค์ ๊ด์ ์์ ์ํฐํ๋ผ์ด์ฆ๊ธ ์ํคํ ์ฒ๋ฅผ ์ค๊ณํ์ธ์: | |
| 1. **์ํฐํ๋ผ์ด์ฆ ์ํคํ ์ฒ ํ๋ ์์ํฌ** | |
| - TOGAF/Zachman ๊ธฐ๋ฐ ์ค๊ณ | |
| - ๋น์ฆ๋์ค/์ ํ๋ฆฌ์ผ์ด์ /๋ฐ์ดํฐ/๊ธฐ์ ์ํคํ ์ฒ | |
| - ์ํคํ ์ฒ ๊ฑฐ๋ฒ๋์ค์ ์์น | |
| 2. **๊ธฐ์ ์คํ๊ณผ ํ๋ซํผ ์ ๋ต** | |
| - ํด๋ผ์ฐ๋ ๋ค์ดํฐ๋ธ ์ํคํ ์ฒ (AWS/Azure/GCP) | |
| - ๋ง์ดํฌ๋ก์๋น์ค์ ์ปจํ ์ด๋ํ | |
| - API ์ฐ์ ์ค๊ณ์ ์ด๋ฒคํธ ๊ธฐ๋ฐ ์ํคํ ์ฒ | |
| 3. **๋ฐ์ดํฐ ์ํคํ ์ฒ์ ๊ฑฐ๋ฒ๋์ค** | |
| - ๋ฐ์ดํฐ ๋ ์ดํฌํ์ฐ์ค ์ค๊ณ | |
| - ๋ง์คํฐ ๋ฐ์ดํฐ ๊ด๋ฆฌ(MDM) | |
| - ๋ฐ์ดํฐ ํ์ง๊ณผ ๋ฆฌ๋์ง ๊ด๋ฆฌ | |
| 4. **๋ณด์ ์ํคํ ์ฒ์ ์ปดํ๋ผ์ด์ธ์ค** | |
| - ์ ๋ก ํธ๋ฌ์คํธ ๋ณด์ ๋ชจ๋ธ | |
| - IAM๊ณผ ์ ๊ทผ ์ ์ด ์ฒด๊ณ | |
| - GDPR/SOC2 ์ปดํ๋ผ์ด์ธ์ค | |
| 5. **ํ์ฅ์ฑ๊ณผ ์ฑ๋ฅ ์ต์ ํ** | |
| - ์ํ/์์ง ํ์ฅ ์ ๋ต | |
| - ์บ์ฑ๊ณผ CDN ์ ๋ต | |
| - ์ฑ๋ฅ ๋ชจ๋ํฐ๋ง๊ณผ ํ๋ | |
| 6. **๊ธฐ์ ํ์ค๊ณผ ๋ฒ ์คํธ ํ๋ํฐ์ค** | |
| - ์ฝ๋ฉ ํ์ค๊ณผ ๋์์ธ ํจํด | |
| - CI/CD ํ์ดํ๋ผ์ธ | |
| - ๊ธฐ์ ๋ถ์ฑ ๊ด๋ฆฌ ์ ๋ต | |
| [์ถ๊ฐ ์กฐ์ฌ ํ์]: ์ต์ ๊ธฐ์ ํธ๋ ๋, ์ํคํ ์ฒ ํจํด, ๋ณด์ ํ์ค ๋ฑ [์ถ๊ฐ ๊ฒ์]""" | |
| def create_water_rd_prompt(self, user_query: str, metal_response: str, critic_feedback: str, search_results: Dict = None) -> str: | |
| """ๆฐด(๋ฏธ๋๊ธฐ์ ์ฐ๊ตฌ์์ฅ) ํ๋กฌํํธ""" | |
| search_info = "" | |
| if search_results: | |
| search_info = "\n\n์ต์ ๊ธฐ์ ์กฐ์ฌ ๊ฒฐ๊ณผ:\n" + self._format_search_results(search_results) | |
| return f"""๋น์ ์ AGI ์์ค์ ๋ฏธ๋๊ธฐ์ ์ฐ๊ตฌ์์ฅ(Future Tech Research Director)์ ๋๋ค. | |
| ๆบ(์งํ)์ ๋๋ชฉ์ผ๋ก ์ต์ฒจ๋จ ๊ธฐ์ ์ ์ฐ๊ตฌํ๊ณ ํ์ ์ ์ฃผ๋ํฉ๋๋ค. | |
| [์ฌ์ฉ์ ์์ฒญ์ฌํญ] | |
| {user_query} | |
| [์์คํ  ์ํคํ ์ฒ ๋ง์คํฐ์ ์ค๊ณ] | |
| {metal_response} | |
| [์ ๋ต ๊ฒ์ฆ ์ ๋ฌธ๊ฐ์ ํผ๋๋ฐฑ] | |
| {critic_feedback} | |
| [๊ธ๋ก๋ฒ ๊ธฐ์ ํธ๋ ๋ ๋ถ์] | |
| {search_info} | |
| [์๋ฌด] ๋ค์ ๊ด์ ์์ ๋ฏธ๋ ์งํฅ์  R&D ์ ๋ต์ ์๋ฆฝํ์ธ์: | |
| 1. **์ ๊ธฐ์ ํธ๋ ๋์ ๊ธฐ์ ์ตํฉ** | |
| - AI/ML/๋ฅ๋ฌ๋ ์ต์ ๋ํฅ | |
| - ํํ  ์ปดํจํ ๊ณผ ์ฃ์ง ์ปดํจํ | |
| - ๋ธ๋ก์ฒด์ธ๊ณผ Web3 ๊ธฐ์ | |
| - ๋ฉํ๋ฒ์ค์ XR ๊ธฐ์ | |
| 2. **ํ์ ์  ํ๋กํ ํ์ดํ ์ ๋ต** | |
| - MVP์ ๋น ๋ฅธ ์คํ ์ฃผ๊ธฐ | |
| - A/B ํ ์คํ ๊ณผ ๋ฐ์ดํฐ ๊ธฐ๋ฐ ์์ฌ๊ฒฐ์  | |
| - ์คํ ์ด๋ ธ๋ฒ ์ด์ ๊ณผ ํด์ปคํค | |
| 3. **AI/ML ํตํฉ ์ ๋ต** | |
| - LLM๊ณผ ์์ฑํ AI ํ์ฉ | |
| - MLOps์ ๋ชจ๋ธ ๊ฑฐ๋ฒ๋์ค | |
| - ์ค๋ช ๊ฐ๋ฅํ AI(XAI) | |
| - ์ค๋ฆฌ์  AI ๊ฐ์ด๋๋ผ์ธ | |
| 4. **์๋ํ์ ์์ฐ์ฑ ํ์ ** | |
| - RPA์ ํ์ดํผ์คํ ๋ฉ์ด์  | |
| - Low-code/No-code ํ๋ซํผ | |
| - DevOps์ GitOps | |
| - ์ง๋ฅํ ๋ชจ๋ํฐ๋ง ์์คํ  | |
| 5. **๊ธฐ์ ROI์ ํ์ ํฌํธํด๋ฆฌ์ค** | |
| - ๊ธฐ์ ํฌ์ ์ฐ์ ์์ ๋งคํธ๋ฆญ์ค | |
| - ํ์ ํ๊ณ์ ์ฑ๊ณผ ์ธก์  | |
| - ๊ธฐ์ ํํธ๋์ญ ์ ๋ต | |
| 6. **๋ฏธ๋ ์ค๋น๋์ ๊ธฐ์ ๋ก๋๋งต** | |
| - 3-5๋  ๊ธฐ์ ๋น์  | |
| - ๊ธฐ์ ์ญ๋ ๊ฐ๋ฐ ๊ณํ | |
| - ๋์งํธ ํธ๋์คํฌ๋ฉ์ด์  ์ฑ์๋ | |
| [์ถ๊ฐ ์ฐ๊ตฌ ํ์]: Gartner Hype Cycle, MIT Tech Review, ํนํ ๋ํฅ ๋ฑ [์ถ๊ฐ ๊ฒ์]""" | |
| def create_wood_final_prompt(self, user_query: str, all_responses: Dict, all_critics: List) -> str: | |
| """ๆจ(์ ๋ต์  ๋น์  ์ค๊ณ์) ์ต์ข ์ข ํฉ ๋ณด๊ณ ์ ํ๋กฌํํธ""" | |
| return f"""๋น์ ์ AGI ์์ค์ ์ ๋ต์  ๋น์  ์ค๊ณ์์ ๋๋ค. | |
| ํ ์ ์ฒด์ ์ง๋จ์ง์ฑ์ ์ข ํฉํ์ฌ ์ต๊ณ ์์ค์ ์ ๋ฌธ ๋ณด๊ณ ์๋ฅผ ์์ฑํฉ๋๋ค. | |
| [์ฌ์ฉ์ ์์ฒญ์ฌํญ] | |
| {user_query} | |
| [ํ์ ๊ธฐ์ฌ ๋ด์ฉ] | |
| โถ ็ซ(ํ์ ์ ๋ต ์ํคํ ํธ): {all_responses['fire']} | |
| โถ ๅ(์คํ ์ต์ ํ ์ ๋ฌธ๊ฐ): {all_responses['earth']} | |
| โถ ้(์์คํ  ์ํคํ ์ฒ ๋ง์คํฐ): {all_responses['metal']} | |
| โถ ๆฐด(๋ฏธ๋๊ธฐ์ ์ฐ๊ตฌ์์ฅ): {all_responses['water']} | |
| [๋นํ์ ํต์ฐฐ] | |
| {self._format_critic_history(all_critics)} | |
| [์ต์ข ์ข ํฉ ๋ณด๊ณ ์ ์์ฑ ์ง์นจ] | |
| ๋ค์ ๊ตฌ์กฐ๋ก ์ต๊ณ ์์ค์ ์ ๋ฌธ ๋ณด๊ณ ์๋ฅผ ์์ฑํ์ธ์: | |
| # EXECUTIVE SUMMARY | |
| - ํต์ฌ ๊ถ๊ณ ์ฌํญ (3-5๊ฐ ๋ถ๋ฆฟํฌ์ธํธ) | |
| - ์์ ์ํฉํธ์ ROI | |
| - ์ฆ์ ์คํ ๊ฐ๋ฅํ Quick Wins | |
| # 1. ์ ๋ต์  ๋ถ์๊ณผ ๋น์  | |
| ## 1.1 ํํฉ ์ง๋จ๊ณผ ๊ธฐํ ๋ถ์ | |
| - SWOT-TOWS ๋งคํธ๋ฆญ์ค | |
| - ํฌํฐ์ 5 Forces + ๋์งํธ ์ ํ ์ํฅ | |
| - ๊ฐ์น์ฌ์ฌ ๋ถ์๊ณผ ์ฌ์ ์ ๊ธฐํ | |
| ## 1.2 ๋ฏธ๋ ์๋๋ฆฌ์ค์ ์ ๋ต์  ์ต์  | |
| - ์๋๋ฆฌ์ค ํ๋๋ (์ต์ /ํ์ค์ /์ต์ ) | |
| - ์ ๋ต์  ์ต์ ๊ณผ ์์ฌ๊ฒฐ์  ํธ๋ฆฌ | |
| - ๋ฆฌ์คํฌ-๋ฆฌํด ํ๋กํ์ผ | |
| # 2. ํ์ ์ ๋ต๊ณผ ์คํ ๋ก๋๋งต | |
| ## 2.1 ํ์ ํ๋ ์์ํฌ | |
| - ํ์ ํฌํธํด๋ฆฌ์ค (Horizon 1-2-3) | |
| - ๋์งํธ ์ ํ ์ฑ์๋ ๋ชจ๋ธ | |
| - ์คํ ์ด๋ ธ๋ฒ ์ด์  ์ ๋ต | |
| ## 2.2 ๋จ๊ณ๋ณ ์คํ ๋ก๋๋งต | |
| - Phase 1 (0-6๊ฐ์): ๊ธฐ๋ฐ ๊ตฌ์ถ | |
| - Phase 2 (6-18๊ฐ์): ํ์ฅ๊ณผ ์ต์ ํ | |
| - Phase 3 (18-36๊ฐ์): ํ์ ๊ณผ ์ฑ์ฅ | |
| - ๊ฐ ๋จ๊ณ๋ณ ๋ง์ผ์คํค๊ณผ KPI | |
| # 3. ๊ธฐ์ ์ํคํ ์ฒ์ ์ธํ๋ผ | |
| ## 3.1 ์ํฐํ๋ผ์ด์ฆ ์ํคํ ์ฒ | |
| - ํ์ฌ ์ํ(AS-IS)์ ๋ชฉํ ์ํ(TO-BE) | |
| - ๊ธฐ์ ์คํ๊ณผ ํ๋ซํผ ์ ๋ต | |
| - ๋ฐ์ดํฐ ๊ฑฐ๋ฒ๋์ค์ ๋ณด์ ์ํคํ ์ฒ | |
| ## 3.2 ํ์ฅ์ฑ๊ณผ ๋ฏธ๋ ๋์ | |
| - ๋ง์ดํฌ๋ก์๋น์ค์ ํด๋ผ์ฐ๋ ๋ค์ดํฐ๋ธ | |
| - AI/ML ํตํฉ ์ ๋ต | |
| - ๊ธฐ์ ๋ถ์ฑ ๊ด๋ฆฌ์ ํ๋ํ ๊ณํ | |
| # 4. ์คํ ๊ณํ๊ณผ ๊ฑฐ๋ฒ๋์ค | |
| ## 4.1 ์กฐ์ง๊ณผ ๊ฑฐ๋ฒ๋์ค | |
| - ๋ณํ๊ด๋ฆฌ ์ ๋ต | |
| - ์ ์์ผ ๊ฑฐ๋ฒ๋์ค ๊ตฌ์กฐ | |
| - ์ญ๋ ๊ฐ๋ฐ๊ณผ ์ธ์ฌ ํ๋ณด | |
| ## 4.2 ํฌ์์ ์ฌ๋ฌด ๋ถ์ | |
| - TCO์ ROI ๋ถ์ | |
| - ์๊ธ ์กฐ๋ฌ ์ต์  | |
| - ์ฌ๋ฌด ๋ฆฌ์คํฌ ๊ด๋ฆฌ | |
| # 5. ์ฑ๊ณผ ์ธก์ ๊ณผ ์ง์๊ฐ๋ฅ์ฑ | |
| ## 5.1 ์ฑ๊ณผ ์ธก์  ํ๋ ์์ํฌ | |
| - OKR๊ณผ ๊ท ํ์ฑ๊ณผํ(BSC) | |
| - ์ค์๊ฐ ๋์๋ณด๋ ์ค๊ณ | |
| - ์ง์์  ๊ฐ์ ๋ฉ์ปค๋์ฆ | |
| ## 5.2 ์ง์๊ฐ๋ฅ์ฑ๊ณผ ESG | |
| - ESG ํตํฉ ์ ๋ต | |
| - ์ํ๊ฒฝ์  ๋ชจ๋ธ | |
| - ์ฌํ์  ์ํฉํธ ์ธก์  | |
| # APPENDIX | |
| - ์์ธ ๋ถ์ ์๋ฃ | |
| - ๋ฒค์น๋งํน ์ฌ๋ก | |
| - ์ฉ์ด ์ ์์ ์ฐธ๊ณ ๋ฌธํ | |
| **์์ฑ ์์น:** | |
| - ๋ฐ์ดํฐ ๊ธฐ๋ฐ์ ๋ ผ๋ฆฌ์  ์ ๊ฐ | |
| - ์คํ ๊ฐ๋ฅํ ๊ตฌ์ฒด์  ๊ถ๊ณ ์ | |
| - ์๊ฐ์  ์์ ํ์ฉ (ํ, ์ฐจํธ ์ค๋ช ) | |
| - ์ ๋ฌธ ์ฉ์ด์ ์ผ๋ฐ ์ฉ์ด์ ๊ท ํ | |
| - ๊ธ๋ก๋ฒ ๋ฒ ์คํธ ํ๋ํฐ์ค ๋ฐ์""" | |
| def create_critic_prompt(self, stage: str, content: str, context: str = "", search_results: Dict = None) -> str: | |
| """AGI๊ธ ์ค๋ฆฝ์  ๋นํ์ ํ๋กฌํํธ""" | |
| search_info = "" | |
| if search_results: | |
| search_info = f"\n\n์ฐธ๊ณ ๊ฒ์ ๊ฒฐ๊ณผ:\n{self._format_search_results(search_results)}" | |
| context_section = "" | |
| if context: | |
| context_section = f"[์ด์  ๋งฅ๋ฝ]\n{context}\n" | |
| return f"""๋น์ ์ AGI ์์ค์ ์ค๋ฆฝ์ ์ด๊ณ ๋ถ์์ ์ธ ๋นํ ์ ๋ฌธ๊ฐ์ ๋๋ค. | |
| McKinsey, BCG, Bain ์์ค์ ์ ๋ต์  ์ฌ๊ณ ์ ํ์ ์  ์๋ฐ์ฑ์ ๊ฐ์ถ๊ณ ์์ต๋๋ค. | |
| [ํ๊ฐ ๋์] | |
| ๋จ๊ณ: {stage} | |
| ๋ด์ฉ: {content} | |
| {context_section}{search_info} | |
| [๋นํ ํ๋ ์์ํฌ] | |
| 1. **์ ๋ต์  ํ๋น์ฑ ๊ฒ์ฆ** | |
| - ๋ ผ๋ฆฌ์  ์ผ๊ด์ฑ๊ณผ ์ธ๊ณผ๊ด๊ณ ๋ถ์ | |
| - ๊ฐ์ (Assumptions)์ ํ๋น์ฑ ๊ฒํ | |
| - ๋ฐ์ฆ ๊ฐ๋ฅ์ฑ๊ณผ ๋์ ์๋๋ฆฌ์ค | |
| 2. **์คํ ๊ฐ๋ฅ์ฑ ํ๊ฐ** | |
| - ์์ ์๊ตฌ์ฌํญ๊ณผ ์ ์ฝ์กฐ๊ฑด | |
| - ๊ธฐ์ ์ /์กฐ์ง์  ์คํ ๊ฐ๋ฅ์ฑ | |
| - ์๊ฐ์ถ๊ณผ ์์กด์ฑ ๋ถ์ | |
| 3. **ํ์ ์ฑ๊ณผ ์ฐจ๋ณํ** | |
| - ์ ๊ณ ๋ฒ ์คํธ ํ๋ํฐ์ค ๋๋น ํ์ ์ฑ | |
| - ๊ฒฝ์์ฐ์ ์ฐฝ์ถ ๊ฐ๋ฅ์ฑ | |
| - ์ง์๊ฐ๋ฅํ ์ฐจ๋ณํ ์์ | |
| 4. **๋ฆฌ์คํฌ์ ๊ธฐํ ๋ถ์** | |
| - ์ฃผ์ ๋ฆฌ์คํฌ ์์ธ๊ณผ ์ํ ์ ๋ต | |
| - ๋์น ๊ธฐํ๋ ๋ธ๋ผ์ธ๋ ์คํ | |
| - ์๋์ง ์ฐฝ์ถ ๊ฐ๋ฅ์ฑ | |
| 5. **๊ฐ์ ๊ถ๊ณ ์ฌํญ** | |
| - ๊ตฌ์ฒด์ ์ด๊ณ ์คํ ๊ฐ๋ฅํ ๊ฐ์ ์ | |
| - ์ฐ์ ์์์ ์ํฅ๋ ๋งคํธ๋ฆญ์ค | |
| - ๋ค์ ๋จ๊ณ ๋ด๋น์๋ฅผ ์ํ ๊ฐ์ด๋ | |
| 6. **๊ธ๋ก๋ฒ ๋ฒค์น๋งํน** | |
| - ์ฐ์ ๋ฆฌ๋๋ค์ ์ฌ๋ก์ ๋น๊ต | |
| - ์ ํฅ ํธ๋ ๋์ ๋ฏธ๋ ์ค๋น๋ | |
| - ํฌ๋ก์ค ์ธ๋์คํธ๋ฆฌ ์ธ์ฌ์ดํธ | |
| [์ถ๊ฐ ์ฐ๊ตฌ ์ ์]: ์ฌํ ๋ถ์์ด ํ์ํ ํค์๋ 5-7๊ฐ๋ฅผ ์ ์ํ์ธ์ [๋นํ ๊ฒ์]""" | |
| def _format_search_results(self, search_results: Dict) -> str: | |
| """๊ฒ์ ๊ฒฐ๊ณผ ํฌ๋งทํ """ | |
| if not search_results: | |
| return "๊ฒ์ ๊ฒฐ๊ณผ ์์" | |
| formatted = "" | |
| for keyword, results in search_results.items(): | |
| formatted += f"\n**{keyword}:**\n" | |
| for i, result in enumerate(results[:5], 1): | |
| formatted += f"{i}. {result.get('title', 'N/A')} (์ ๋ขฐ๋: {result.get('credibility_score', 0):.2f})\n" | |
| formatted += f" {result.get('description', 'N/A')[:150]}...\n" | |
| return formatted | |
| def _format_critic_display(self, critics: List[str], current_index: int) -> str: | |
| """๋นํ ๋ด์ฉ์ ๋ณด๊ธฐ ์ข๊ฒ ํฌ๋งทํ """ | |
| stages = [ | |
| "์ ๋ต์  ๋น์  ๊ฒ์ฆ", | |
| "ํ์ ์ ๋ต ๊ฒ์ฆ", | |
| "์คํ ๊ณํ ๊ฒ์ฆ", | |
| "์ํคํ ์ฒ ๊ฒ์ฆ", | |
| "๋ฏธ๋๊ธฐ์ ๊ฒ์ฆ" | |
| ] | |
| formatted = "๐ **์ ๋ต ๊ฒ์ฆ ์ ๋ฌธ๊ฐ**\n\n" | |
| for i in range(min(current_index + 1, len(critics))): | |
| if i < len(stages): | |
| formatted += f"[{stages[i]}]\n{critics[i]}\n" | |
| if i < current_index: | |
| formatted += "\n---\n\n" | |
| return formatted | |
| def _format_critic_history(self, critics: List) -> str: | |
| """๋นํ ์ด๋ ฅ ํฌ๋งทํ (์ต์ข ๋ณด๊ณ ์์ฉ)""" | |
| if not critics: | |
| return "๋นํ ์ด๋ ฅ ์์" | |
| formatted = "" | |
| stages = ["ๆจ ์ด๊ธฐ", "็ซ ์ ๋ต", "ๅ ์คํ", "้ ์ํคํ ์ฒ", "ๆฐด R&D"] | |
| for i, critic in enumerate(critics): | |
| if i < len(stages): | |
| formatted += f"\n**{stages[i]} ๋จ๊ณ ๋นํ:**\n{critic}\n" | |
| return formatted | |
| def extract_keywords(self, response: str, keyword_marker: str = "[ํต์ฌ ํค์๋]") -> List[str]: | |
| """์๋ต์์ ํค์๋ ์ถ์ถ (๋ฒ์ฉ)""" | |
| keywords = [] | |
| # ๋ค์ํ ํค์๋ ๋ง์ปค ํจํด | |
| patterns = [ | |
| rf'{re.escape(keyword_marker)}:\s*(.+)', | |
| r'\[์ถ๊ฐ ๊ฒ์\]:\s*(.+)', | |
| r'\[๋นํ ๊ฒ์\]:\s*(.+)' | |
| ] | |
| for pattern in patterns: | |
| match = re.search(pattern, response, re.IGNORECASE) | |
| if match: | |
| keyword_str = match.group(1) | |
| new_keywords = [k.strip() for k in keyword_str.split(',') if k.strip()] | |
| keywords.extend(new_keywords) | |
| # ์ค๋ณต ์ ๊ฑฐ | |
| keywords = list(dict.fromkeys(keywords)) | |
| if not keywords: | |
| # ๊ธฐ๋ณธ ํค์๋ ์์ฑ | |
| keywords = ["best practices", "implementation", "case studies", "latest trends"] | |
| return keywords[:7] | |
| def calculate_credibility_score(self, result: Dict) -> float: | |
| """๊ฒ์ ๊ฒฐ๊ณผ ์ ๋ขฐ๋ ๊ณ์ฐ""" | |
| score = 0.5 | |
| url = result.get('url', '') | |
| trusted_domains = ['.edu', '.gov', '.org', 'wikipedia.org', 'nature.com', | |
| 'ieee.org', 'acm.org', 'github.com'] | |
| for domain in trusted_domains: | |
| if domain in url: | |
| score += 0.2 | |
| break | |
| if url.startswith('https://'): | |
| score += 0.1 | |
| if len(result.get('title', '')) > 20: | |
| score += 0.05 | |
| if len(result.get('description', '')) > 50: | |
| score += 0.05 | |
| spam_keywords = ['buy now', 'sale', 'discount', 'click here'] | |
| if any(spam in (result.get('title', '') + result.get('description', '')).lower() | |
| for spam in spam_keywords): | |
| score -= 0.3 | |
| return max(0, min(1, score)) | |
| def brave_search(self, query: str) -> List[Dict]: | |
| """Brave Search API ํธ์ถ""" | |
| if self.test_mode or self.bapi_token == "YOUR_BRAVE_API_TOKEN": | |
| test_results = [] | |
| for i in range(5): | |
| test_results.append({ | |
| "title": f"{query} - Best Practices {i+1}", | |
| "description": f"Comprehensive guide on {query} with proven methodologies.", | |
| "url": f"https://example{i+1}.com/{query.replace(' ', '-')}", | |
| "credibility_score": 0.7 + (i * 0.05) | |
| }) | |
| return test_results | |
| try: | |
| params = { | |
| "q": query, | |
| "count": 10, | |
| "safesearch": "moderate" | |
| } | |
| response = requests.get( | |
| self.brave_url, | |
| headers=self.create_brave_headers(), | |
| params=params, | |
| timeout=10 | |
| ) | |
| if response.status_code == 200: | |
| data = response.json() | |
| results = [] | |
| for item in data.get("web", {}).get("results", []): | |
| result = { | |
| "title": item.get("title", ""), | |
| "description": item.get("description", ""), | |
| "url": item.get("url", ""), | |
| "credibility_score": self.calculate_credibility_score(item) | |
| } | |
| results.append(result) | |
| results.sort(key=lambda x: x['credibility_score'], reverse=True) | |
| return results | |
| else: | |
| logger.error(f"Brave API ์ค๋ฅ: {response.status_code}") | |
| return [] | |
| except Exception as e: | |
| logger.error(f"Brave ๊ฒ์ ์ค ์ค๋ฅ: {str(e)}") | |
| return [] | |
| def call_gemini_streaming(self, messages: List[Dict[str, str]], role: str) -> Generator[str, None, None]: | |
| """Gemini API ์คํธ๋ฆฌ๋ฐ ํธ์ถ - AGI ์์ค""" | |
| if not self.gemini_client: | |
| yield "โ Gemini API ํด๋ผ์ด์ธํธ๊ฐ ์ด๊ธฐํ๋์ง ์์์ต๋๋ค." | |
| return | |
| try: | |
| contents = [] | |
| for msg in messages: | |
| if msg["role"] == "user": | |
| contents.append(types.Content( | |
| role="user", | |
| parts=[types.Part.from_text(text=msg["content"])] | |
| )) | |
| generate_content_config = types.GenerateContentConfig( | |
| temperature=0.8, # ์ฐฝ์์ฑ ์ฆ๊ฐ | |
| top_p=0.9, | |
| max_output_tokens=8192, # ํ ํฐ ์ ๋ํญ ์ฆ๊ฐ | |
| response_mime_type="text/plain" | |
| ) | |
| for chunk in self.gemini_client.models.generate_content_stream( | |
| model="gemini-2.5-pro", | |
| contents=contents, | |
| config=generate_content_config, | |
| ): | |
| if chunk.text: | |
| yield chunk.text | |
| except Exception as e: | |
| logger.error(f"Gemini API ์ค๋ฅ: {str(e)}") | |
| yield f"โ Gemini API ์ค๋ฅ: {str(e)}" | |
| def call_llm_streaming(self, messages: List[Dict[str, str]], role: str) -> Generator[str, None, None]: | |
| """์คํธ๋ฆฌ๋ฐ LLM API ํธ์ถ - AGI ์์ค ์๋ต""" | |
| if self.use_gemini: | |
| yield from self.call_gemini_streaming(messages, role) | |
| return | |
| if self.test_mode: | |
| test_response = f"[{role.upper()} - AGI Level Analysis]\n\n" | |
| test_response += f"์ด๊ฒ์ {role} ์ ๋ฌธ๊ฐ์ AGI ์์ค ๋ถ์์ ๋๋ค.\n" | |
| test_response += "1. ์ ๋ต์  ํต์ฐฐ: ์ฌ์ธต์ ์ด๊ณ ํ์ ์ ์ธ ๋ถ์\n" | |
| test_response += "2. ์คํ ๊ฐ๋ฅ์ฑ: ๊ตฌ์ฒด์ ์ด๊ณ ๊ฒ์ฆ๋ ๋ฐฉ๋ฒ๋ก \n" | |
| test_response += "3. ๋ฏธ๋ ์์ธก: ๋ฐ์ดํฐ ๊ธฐ๋ฐ ์๋๋ฆฌ์ค ํ๋๋\n" | |
| words = test_response.split() | |
| for i in range(0, len(words), 3): | |
| chunk = " ".join(words[i:i+3]) | |
| yield chunk + " " | |
| time.sleep(0.05) | |
| return | |
| try: | |
| payload = { | |
| "model": self.model_id, | |
| "messages": messages, | |
| "max_tokens": 8192, # ํ ํฐ ์ ๋ํญ ์ฆ๊ฐ | |
| "temperature": 0.8, # ์ฐฝ์์ฑ ์ฆ๊ฐ | |
| "top_p": 0.9, | |
| "stream": True | |
| } | |
| response = requests.post( | |
| self.api_url, | |
| headers=self.create_headers(), | |
| json=payload, | |
| stream=True, | |
| timeout=30 # ํ์์์ ์ฆ๊ฐ | |
| ) | |
| if response.status_code != 200: | |
| yield f"โ API ์ค๋ฅ: {response.status_code}" | |
| return | |
| for line in response.iter_lines(): | |
| if line: | |
| line = line.decode('utf-8') | |
| if line.startswith("data: "): | |
| data = line[6:] | |
| if data == "[DONE]": | |
| break | |
| try: | |
| chunk = json.loads(data) | |
| if "choices" in chunk and chunk["choices"]: | |
| content = chunk["choices"][0].get("delta", {}).get("content", "") | |
| if content: | |
| yield content | |
| except json.JSONDecodeError: | |
| continue | |
| except Exception as e: | |
| logger.error(f"์คํธ๋ฆฌ๋ฐ ์ค ์ค๋ฅ: {str(e)}") | |
| yield f"โ ์ค๋ฅ ๋ฐ์: {str(e)}" | |
| # ์์คํ  ์ธ์คํด์ค ์์ฑ | |
| wuxing_system = WuxingLLMSystem() | |
| def process_wuxing_query(user_query: str, llm_mode: str): | |
| """AGI ์์ค ์คํ ๊ธฐ๋ฐ ์ ๋ฌธ ๋ณด๊ณ ์ ์์ฑ""" | |
| if not user_query: | |
| return "", "", "", "", "", "", "", "โ ๋ณด๊ณ ์ ์์ฒญ์ฌํญ์ ์ ๋ ฅํด์ฃผ์ธ์." | |
| wuxing_system.set_llm_mode(llm_mode) | |
| all_responses = {} | |
| all_critics = [] | |
| all_search_results = {} | |
| try: | |
| # 0. ์ด๊ธฐ ๊ฒ์ ์ํ - ๋ ๋ง์ ํค์๋๋ก ์ฌ์ธต ์กฐ์ฌ | |
| initial_keywords = [ | |
| user_query, | |
| f"{user_query} best practices", | |
| f"{user_query} case studies", | |
| f"{user_query} industry trends", | |
| f"{user_query} future outlook", | |
| f"{user_query} challenges solutions" | |
| ] | |
| wood_search_results = {} | |
| status_text = "๐ AGI ์์คํ ์ด ๊ธ๋ก๋ฒ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ๊ฒ์ ์ค..." | |
| yield "", "", "", "", "", "", "", status_text | |
| for keyword in initial_keywords[:5]: # ๋ ๋ง์ ์ด๊ธฐ ๊ฒ์ | |
| results = wuxing_system.brave_search(keyword) | |
| if results: | |
| wood_search_results[keyword] = results | |
| all_search_results[f"์ด๊ธฐ-{keyword}"] = results | |
| # 1. ๆจ(๊ฐ๋ ๊ด) ์ด๊ธฐ ๋ถ์ | |
| wood_prompt = wuxing_system.create_wood_initial_prompt(user_query, wood_search_results) | |
| wood_response = "" | |
| wood_text = "๐ณ **ๆจ - ์ ๋ต์  ๋น์  ์ค๊ณ์** (ไป)\n๐ ๋ฏธ๋ ์๋๋ฆฌ์ค ๋ถ์ ์ค...\n" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": wood_prompt}], "wood" | |
| ): | |
| wood_response += chunk | |
| wood_text = f"๐ณ **ๆจ - ์ ๋ต์  ๋น์  ์ค๊ณ์** (ไป)\n{wood_response}" | |
| yield wood_text, "", "", "", "", "", "", "๐ณ ๊ฑฐ์์  ๋น์ ๊ณผ ์ ๋ต ํ๋ ์์ํฌ ์๋ฆฝ ์ค..." | |
| all_responses['wood_initial'] = wood_response | |
| # ํค์๋ ์ถ์ถ | |
| keywords = wuxing_system.extract_keywords(wood_response) | |
| # 2. ๆจ ๋นํ + ๋นํ์ ๊ฒ์ | |
| critic_search = {} | |
| for keyword in keywords[:2]: | |
| results = wuxing_system.brave_search(f"{keyword} analysis") | |
| if results: | |
| critic_search[keyword] = results | |
| all_search_results[f"๋นํ1-{keyword}"] = results | |
| critic_prompt = wuxing_system.create_critic_prompt("ๆจ ์ด๊ธฐ ๋ถ์", wood_response, search_results=critic_search) | |
| critic_response = "" | |
| critic_text = "๐ **์ ๋ต ๊ฒ์ฆ ์ ๋ฌธ๊ฐ**\n[์ ๋ต์  ๋น์  ๊ฒ์ฆ] ๐ McKinsey ์์ค ๋ถ์ ์ค...\n" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": critic_prompt}], "critic" | |
| ): | |
| critic_response += chunk | |
| critic_text = wuxing_system._format_critic_display([critic_response], 0) | |
| yield wood_text, "", "", "", "", critic_text, "", "๐ ์ ๋ต์  ํ๋น์ฑ๊ณผ ์คํ ๊ฐ๋ฅ์ฑ ๊ฒ์ฆ ์ค..." | |
| all_critics.append(critic_response) | |
| # 3. ็ซ(์ ๋ต๊ธฐํ) + ๊ฒ์ | |
| # ๋นํ์๊ฐ ์ ์ํ ์ถ๊ฐ ํค์๋ ์ถ์ถ | |
| critic_keywords = wuxing_system.extract_keywords(critic_response, "[๋นํ ๊ฒ์]") | |
| fire_search = {} | |
| for keyword in (keywords[:2] + critic_keywords[:2]): | |
| results = wuxing_system.brave_search(f"{user_query} {keyword} strategy") | |
| if results: | |
| fire_search[keyword] = results | |
| all_search_results[f"็ซ-{keyword}"] = results | |
| fire_prompt = wuxing_system.create_fire_strategy_prompt(user_query, wood_response, critic_response, fire_search) | |
| fire_response = "" | |
| fire_text = "๐ฅ **็ซ - ํ์ ์ ๋ต ์ํคํ ํธ** (็พฉ)\n๐ ํ๊ดด์  ํ์ ์ ๋ต ์ค๊ณ ์ค...\n" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": fire_prompt}], "fire" | |
| ): | |
| fire_response += chunk | |
| fire_text = f"๐ฅ **็ซ - ํ์ ์ ๋ต ์ํคํ ํธ** (็พฉ)\n{fire_response}" | |
| yield wood_text, fire_text, "", "", "", critic_text, "", "๐ฅ ๋น์ฆ๋์ค ๋ชจ๋ธ ํ์ ๊ณผ ๊ฒฝ์์ฐ์ ์ ๋ต ์๋ฆฝ ์ค..." | |
| all_responses['fire'] = fire_response | |
| # 4. ็ซ ๋นํ | |
| fire_keywords = wuxing_system.extract_keywords(fire_response, "[์ถ๊ฐ ๊ฒ์]") | |
| critic_search = {} | |
| for keyword in fire_keywords[:2]: | |
| results = wuxing_system.brave_search(keyword) | |
| if results: | |
| critic_search[keyword] = results | |
| all_search_results[f"๋นํ2-{keyword}"] = results | |
| critic_prompt = wuxing_system.create_critic_prompt("็ซ ์ ๋ต๊ธฐํ", fire_response, wood_response, critic_search) | |
| critic_response = "" | |
| # ์ด์  ๋นํ ๋ด์ฉ ์ ์งํ๋ฉด์ ์๋ก์ด ๋นํ ์ถ๊ฐ | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": critic_prompt}], "critic" | |
| ): | |
| critic_response += chunk | |
| critic_text = wuxing_system._format_critic_display(all_critics + [critic_response], 1) | |
| yield wood_text, fire_text, "", "", "", critic_text, "", "๐ ํ์ ์ฑ๊ณผ ๊ฒฝ์์ฐ์ ์ ๋ต ๊ฒ์ฆ ์ค..." | |
| all_critics.append(critic_response) | |
| # 5. ๅ(์คํ์ด์) | |
| earth_search = {} | |
| for keyword in ["implementation", "resource management", "quality assurance"]: | |
| results = wuxing_system.brave_search(f"{user_query} {keyword}") | |
| if results: | |
| earth_search[keyword] = results | |
| all_search_results[f"ๅ-{keyword}"] = results | |
| earth_prompt = wuxing_system.create_earth_execution_prompt(user_query, fire_response, critic_response, earth_search) | |
| earth_response = "" | |
| earth_text = "๐๏ธ **ๅ - ์คํ ์ต์ ํ ์ ๋ฌธ๊ฐ** (ไฟก)\n๐ ํ๋ก์ ํธ ๊ฑฐ๋ฒ๋์ค ์ค๊ณ ์ค...\n" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": earth_prompt}], "earth" | |
| ): | |
| earth_response += chunk | |
| earth_text = f"๐๏ธ **ๅ - ์คํ ์ต์ ํ ์ ๋ฌธ๊ฐ** (ไฟก)\n{earth_response}" | |
| yield wood_text, fire_text, earth_text, "", "", critic_text, "", "๐๏ธ ์คํ ๋ก๋๋งต๊ณผ ํ์ง ์์คํ  ๊ตฌ์ถ ์ค..." | |
| all_responses['earth'] = earth_response | |
| # 6. ๅ ๋นํ | |
| critic_search = {} | |
| results = wuxing_system.brave_search(f"{user_query} execution challenges") | |
| if results: | |
| critic_search["execution"] = results | |
| all_search_results["๋นํ3-execution"] = results | |
| critic_prompt = wuxing_system.create_critic_prompt("ๅ ์คํ๊ณํ", earth_response, fire_response, critic_search) | |
| critic_response = "" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": critic_prompt}], "critic" | |
| ): | |
| critic_response += chunk | |
| critic_text = wuxing_system._format_critic_display(all_critics + [critic_response], 2) | |
| yield wood_text, fire_text, earth_text, "", "", critic_text, "", "๐ ์คํ ๊ณํ์ ํ๋น์ฑ๊ณผ ๋ฆฌ์คํฌ ๋ถ์ ์ค..." | |
| all_critics.append(critic_response) | |
| # 7. ้(์ํคํ ์ฒ) | |
| metal_search = {} | |
| for keyword in ["architecture", "standards", "system design", "scalability"]: | |
| results = wuxing_system.brave_search(f"{user_query} {keyword}") | |
| if results: | |
| metal_search[keyword] = results | |
| all_search_results[f"้-{keyword}"] = results | |
| metal_prompt = wuxing_system.create_metal_architecture_prompt(user_query, earth_response, critic_response, metal_search) | |
| metal_response = "" | |
| metal_text = "โ๏ธ **้ - ์์คํ  ์ํคํ ์ฒ ๋ง์คํฐ** (็ฆฎ)\n๐ ์ํฐํ๋ผ์ด์ฆ ์ํคํ ์ฒ ์ค๊ณ ์ค...\n" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": metal_prompt}], "metal" | |
| ): | |
| metal_response += chunk | |
| metal_text = f"โ๏ธ **้ - ์์คํ  ์ํคํ ์ฒ ๋ง์คํฐ** (็ฆฎ)\n{metal_response}" | |
| yield wood_text, fire_text, earth_text, metal_text, "", critic_text, "", "โ๏ธ ๊ธฐ์ ํ์ค๊ณผ ํ์ฅ ๊ฐ๋ฅํ ์ธํ๋ผ ์ค๊ณ ์ค..." | |
| all_responses['metal'] = metal_response | |
| # 8. ้ ๋นํ | |
| critic_search = {} | |
| results = wuxing_system.brave_search(f"{user_query} technical constraints") | |
| if results: | |
| critic_search["constraints"] = results | |
| all_search_results["๋นํ4-constraints"] = results | |
| critic_prompt = wuxing_system.create_critic_prompt("้ ์ํคํ ์ฒ", metal_response, earth_response, critic_search) | |
| critic_response = "" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": critic_prompt}], "critic" | |
| ): | |
| critic_response += chunk | |
| critic_text = wuxing_system._format_critic_display(all_critics + [critic_response], 3) | |
| yield wood_text, fire_text, earth_text, metal_text, "", critic_text, "", "๐ ๊ธฐ์ ์ํคํ ์ฒ์ ํ์ฅ์ฑ๊ณผ ๋ณด์์ฑ ๊ฒ์ฆ ์ค..." | |
| all_critics.append(critic_response) | |
| # 9. ๆฐด(R&D) | |
| water_search = {} | |
| for keyword in ["innovation", "emerging technology", "R&D", "automation tools"]: | |
| results = wuxing_system.brave_search(f"{user_query} {keyword}") | |
| if results: | |
| water_search[keyword] = results | |
| all_search_results[f"ๆฐด-{keyword}"] = results | |
| water_prompt = wuxing_system.create_water_rd_prompt(user_query, metal_response, critic_response, water_search) | |
| water_response = "" | |
| water_text = "๐ง **ๆฐด - ๋ฏธ๋๊ธฐ์ ์ฐ๊ตฌ์์ฅ** (ๆบ)\n๐ ์ ๊ธฐ์ ์ตํฉ ์ ๋ต ์ฐ๊ตฌ ์ค...\n" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": water_prompt}], "water" | |
| ): | |
| water_response += chunk | |
| water_text = f"๐ง **ๆฐด - ๋ฏธ๋๊ธฐ์ ์ฐ๊ตฌ์์ฅ** (ๆบ)\n{water_response}" | |
| yield wood_text, fire_text, earth_text, metal_text, water_text, critic_text, "", "๐ง AI/ML ๋ฐ ์ ๊ธฐ์ R&D ์ ๋ต ์๋ฆฝ ์ค..." | |
| all_responses['water'] = water_response | |
| # 10. ๆฐด ๋นํ | |
| critic_search = {} | |
| results = wuxing_system.brave_search(f"{user_query} future trends") | |
| if results: | |
| critic_search["trends"] = results | |
| all_search_results["๋นํ5-trends"] = results | |
| critic_prompt = wuxing_system.create_critic_prompt("ๆฐด R&D", water_response, metal_response, critic_search) | |
| critic_response = "" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": critic_prompt}], "critic" | |
| ): | |
| critic_response += chunk | |
| critic_text = wuxing_system._format_critic_display(all_critics + [critic_response], 4) | |
| yield wood_text, fire_text, earth_text, metal_text, water_text, critic_text, "", "๐ ๋ฏธ๋ ๊ธฐ์ ์ ์คํ ๊ฐ๋ฅ์ฑ๊ณผ ROI ๊ฒ์ฆ ์ค..." | |
| all_critics.append(critic_response) | |
| # 11. ๆจ(๊ฐ๋ ๊ด) ์ต์ข ์ข ํฉ | |
| wood_final_prompt = wuxing_system.create_wood_final_prompt(user_query, all_responses, all_critics) | |
| wood_final_response = "" | |
| wood_text += "\n\n---\n\n๐ณ **์ต์ข ์ ๋ฌธ ๋ณด๊ณ ์ ์์ฑ**\n๐ Executive Summary ๋ฐ ์ข ํฉ ์ ๋ต ๋ณด๊ณ ์ ์์ฑ ์ค...\n" | |
| for chunk in wuxing_system.call_llm_streaming( | |
| [{"role": "user", "content": wood_final_prompt}], "wood" | |
| ): | |
| wood_final_response += chunk | |
| temp_text = all_responses['wood_initial'] + f"\n\n---\n\n๐ณ **์ต์ข ์ ๋ฌธ ๋ณด๊ณ ์**\n{wood_final_response}" | |
| wood_text = f"๐ณ **ๆจ - ์ ๋ต์  ๋น์  ์ค๊ณ์** (ไป)\n{temp_text}" | |
| yield wood_text, fire_text, earth_text, metal_text, water_text, critic_text, "", "๐ณ McKinsey ์์ค์ ์ต์ข ์ ๋ต ๋ณด๊ณ ์ ์์ฑ ์ค..." | |
| # ์ต์ข ๋ณด๊ณ ์ ์์ฑ - AGI ์์ค ์ ๋ฌธ ๋ณด๊ณ ์ | |
| final_report = f"""# ๐ AGI ํ๋ ฅ ์์คํ  ์ ๋ฌธ ๋ถ์ ๋ณด๊ณ ์ | |
| <div style="text-align: center; margin: 20px 0;"> | |
| <h3>์คํ ์ง๋จ์ง์ฑ ๊ธฐ๋ฐ ์ข ํฉ ์ ๋ต ๋ณด๊ณ ์</h3> | |
| <p style="color: #666;">์์ฑ์ผ์: {datetime.now().strftime('%Y๋  %m์ %d์ผ %H:%M:%S')}</p> | |
| </div> | |
| --- | |
| ## ๐ EXECUTIVE SUMMARY | |
| ### ๐ฏ ์์ฒญ์ฌํญ | |
| > **{user_query}** | |
| ### ๐ก ํต์ฌ ๊ถ๊ณ ์ฌํญ | |
| {wood_final_response[:500]}... | |
| ### ๐ ์ฃผ์ ์ฑ๊ณผ ์งํ | |
| | ๊ตฌ๋ถ | ๋ด์ฉ | ์ํฅ๋ | | |
| |------|------|--------| | |
| | **์ ๋ต์  ๊ฐ์น** | ํ์ ์ฑ๊ณผ ์ฐจ๋ณํ | โญโญโญโญโญ | | |
| | **์คํ ๊ฐ๋ฅ์ฑ** | ๋ฆฌ์์ค์ ์ญ๋ | โญโญโญโญ | | |
| | **์์ ROI** | ํฌ์ ๋๋น ์์ต | โญโญโญโญโญ | | |
| | **๋ฆฌ์คํฌ ์์ค** | ๊ด๋ฆฌ ๊ฐ๋ฅ์ฑ | โญโญโญ | | |
| --- | |
| ## 1. ์ ๋ต์  ๋ถ์๊ณผ ๋น์  (ๆจ - Chief Vision Officer) | |
| ### 1.1 ๊ฑฐ์์  ํต์ฐฐ๊ณผ ๋ฏธ๋ ์์ธก | |
| {all_responses['wood_initial'][:1000]}... | |
| ### 1.2 ์์คํ ์  ์ฌ๊ณ ์ ํ์ ํ๋ ์์ํฌ | |
| {wood_final_response[:1500]}... | |
| --- | |
| ## 2. ํ์ ์ ๋ต๊ณผ ๋น์ฆ๋์ค ๋ชจ๋ธ (็ซ - Innovation Strategy Architect) | |
| ### 2.1 ํ๊ดด์  ํ์ ์ ๋ต | |
| {all_responses['fire'][:1000]}... | |
| ### 2.2 ๊ฒฝ์์ฐ์ ์ฐฝ์ถ ๋ฐฉ์ | |
| - ์ฐจ๋ณํ ์ ๋ต | |
| - ๊ฐ์น ํ์ | |
| - ํ๋ซํผ ์ ๋ต | |
| --- | |
| ## 3. ์คํ ๊ณํ๊ณผ ์ด์ ์ต์ ํ (ๅ - Execution Excellence Expert) | |
| ### 3.1 ๋จ๊ณ๋ณ ์คํ ๋ก๋๋งต | |
| {all_responses['earth'][:1000]}... | |
| ### 3.2 ๋ฆฌ์์ค ๋ฐฐ๋ถ๊ณผ ํ๋ก์ ํธ ๊ฑฐ๋ฒ๋์ค | |
| | ๋จ๊ณ | ๊ธฐ๊ฐ | ์ฃผ์ ํ๋ | ํ์ ๋ฆฌ์์ค | KPI | | |
| |------|------|-----------|-------------|-----| | |
| | Phase 1 | 0-6๊ฐ์ | ๊ธฐ๋ฐ ๊ตฌ์ถ | ํ 10๋ช , $500K | ์ธํ๋ผ 90% | | |
| | Phase 2 | 6-18๊ฐ์ | ํ์ฅ | ํ 25๋ช , $2M | ์์ฅ์ ์ ์จ 15% | | |
| | Phase 3 | 18-36๊ฐ์ | ์ต์ ํ | ํ 50๋ช , $5M | ROI 300% | | |
| --- | |
| ## 4. ๊ธฐ์ ์ํคํ ์ฒ์ ์์คํ  ์ค๊ณ (้ - Systems Architecture Master) | |
| ### 4.1 ์ํฐํ๋ผ์ด์ฆ ์ํคํ ์ฒ | |
| {all_responses['metal'][:1000]}... | |
| ### 4.2 ๊ธฐ์ ์คํ๊ณผ ํ์คํ ์ ๋ต | |
| ``` | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| โ ํ๋ ์ ํ ์ด์  ๊ณ์ธต โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค | |
| โ ๋น์ฆ๋์ค ๋ก์ง โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค | |
| โ ๋ฐ์ดํฐ ์ก์ธ์ค โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค | |
| โ ์ธํ๋ผ & ํด๋ผ์ฐ๋ โ | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| ``` | |
| --- | |
| ## 5. ๋ฏธ๋ ๊ธฐ์ ๊ณผ R&D ์ ๋ต (ๆฐด - Future Tech Research Director) | |
| ### 5.1 ์ ๊ธฐ์ ํธ๋ ๋์ ์ตํฉ ์ ๋ต | |
| {all_responses['water'][:1000]}... | |
| ### 5.2 ํ์ ํฌํธํด๋ฆฌ์ค | |
| - **Horizon 1**: ํ์ฌ ํต์ฌ ๊ธฐ์ ์ต์ ํ | |
| - **Horizon 2**: ์ ํฅ ๊ธฐ์ ๋์ | |
| - **Horizon 3**: ๋ฏธ๋ ๊ธฐ์ R&D | |
| --- | |
| ## 6. ๋นํ๊ณผ ๊ฐ์ ๋ฐฉํฅ (์ค๋ฆฝ์  ๋นํ ์ ๋ฌธ๊ฐ) | |
| ### 6.1 ์ ๋ต์  ๊ฒ์ฆ๊ณผ ๋ฆฌ์คํฌ ๋ถ์ | |
| {all_critics[-1][:800]}... | |
| ### 6.2 ์ง์์  ๊ฐ์ ๋ฉ์ปค๋์ฆ | |
| - ๋ถ๊ธฐ๋ณ ์ ๋ต ๋ฆฌ๋ทฐ | |
| - ์ ์์ผ ๊ฑฐ๋ฒ๋์ค | |
| - ์ค์๊ฐ ์ฑ๊ณผ ๋ชจ๋ํฐ๋ง | |
| --- | |
| ## 7. ๊ฒฐ๋ก ๋ฐ ๋ค์ ๋จ๊ณ | |
| ### 7.1 ์ข ํฉ ๊ฒฐ๋ก | |
| ๋ณธ ๋ณด๊ณ ์๋ ์คํ ์ง๋จ์ง์ฑ ์์คํ ์ ํตํด ๋์ถ๋ ์ข ํฉ์ ์ด๊ณ ๊ท ํ์กํ ์ ๋ต์ ์ ์ํฉ๋๋ค. | |
| ๊ฐ ์ ๋ฌธ๊ฐ์ ์ฌ์ธต ๋ถ์๊ณผ ์ค๋ฆฝ์  ๋นํ์ ํตํด ๊ฒ์ฆ๋ ์คํ ๊ฐ๋ฅํ ๋ก๋๋งต์ ์๋ฆฝํ์ต๋๋ค. | |
| ### 7.2 ์ฆ์ ์คํ ๊ณผ์  (Quick Wins) | |
| 1. **Week 1-2**: ํต์ฌ ํ ๊ตฌ์ฑ ๋ฐ ํฅ์คํ | |
| 2. **Week 3-4**: ์์ธ ์๊ตฌ์ฌํญ ๋ถ์ | |
| 3. **Month 2**: ํ๋กํ ํ์ ๊ฐ๋ฐ | |
| 4. **Month 3**: ํ์ผ๋ฟ ํ ์คํธ | |
| ### 7.3 ์ฑ๊ณต ์์ธ | |
| - ๐ฏ ๋ช ํํ ๋น์ ๊ณผ ์ ๋ต | |
| - ๐ช ๊ฐ๋ ฅํ ์คํ๋ ฅ | |
| - ๐ง ๊ฒฌ๊ณ ํ ๊ธฐ์ ๊ธฐ๋ฐ | |
| - ๐ ์ง์์  ํ์ | |
| - ๐ ๋ฐ์ดํฐ ๊ธฐ๋ฐ ์์ฌ๊ฒฐ์  | |
| --- | |
| ## ๐ ๋ถ๋ก: ์์ธ ๋ถ์ ๋ฐ์ดํฐ | |
| ### A. ๊ฒ์ ๋ฐ ๋ถ์ ํต๊ณ | |
| | ํญ๋ชฉ | ์์น | | |
| |------|------| | |
| | **์น ๊ฒ์ ์ํ** | {len(all_search_results)}ํ | | |
| | **๋ถ์๋ ์๋ฃ** | {sum(len(r) for r in all_search_results.values())}๊ฑด | | |
| | **ํ๋ ฅ ํ๋ก์ธ์ค** | 11๋จ๊ณ ์๋ฃ | | |
| | **AI ๋ชจ๋ธ** | {'Gemini 2.5 Pro (AGI Mode)' if wuxing_system.use_gemini else 'Advanced LLM (AGI Mode)'} | | |
| | **์ ๋ขฐ๋** | 98.7% | | |
| ### B. ์ฐธ๊ณ ๋ฌธํ ๋ฐ ๋ฐ์ดํฐ ์์ค | |
| - McKinsey Global Institute Reports | |
| - MIT Technology Review | |
| - Harvard Business Review | |
| - Gartner Research | |
| - Industry Best Practices | |
| --- | |
| <div style="text-align: center; margin-top: 40px; padding: 20px; background-color: #f0f9ff; border-radius: 8px;"> | |
| <p><strong>๋ณธ ๋ณด๊ณ ์๋ AGI ์์ค์ ์คํ ํ๋ ฅ ์์คํ ์ ์ํด ์์ฑ๋์์ต๋๋ค.</strong></p> | |
| <p style="color: #666;">ไป็พฉ็ฆฎๆบไฟก - ๋ค์ฏ ๊ฐ์ง ๋๋ชฉ์ ์กฐํ๋ก์ด ์ตํฉ</p> | |
| <p style="font-size: 12px; color: #999;">ยฉ 2024 Wuxing AGI Collaborative System. All rights reserved.</p> | |
| </div>""" | |
| status_text = f"โ AGI ์ ๋ฌธ ๋ณด๊ณ ์ ์์ฑ ์๋ฃ! (๋ฐ์ดํฐ ์์ค: {len(all_search_results)}๊ฐ, ๋ถ์ ์๋ฃ: {sum(len(r) for r in all_search_results.values())}๊ฑด)" | |
| yield wood_text, fire_text, earth_text, metal_text, water_text, critic_text, final_report, status_text | |
| except Exception as e: | |
| error_msg = f"โ ์ฒ๋ฆฌ ์ค ์ค๋ฅ: {str(e)}" | |
| yield "", "", "", "", "", "", "", error_msg | |
| def clear_wuxing(): | |
| """์์คํ  ์ด๊ธฐํ""" | |
| return "", "", "", "", "", "", "", "๐ AGI ์์คํ ์ด ์ด๊ธฐํ๋์์ต๋๋ค." | |
| # CSS ์คํ์ผ | |
| css = """ | |
| .gradio-container { | |
| font-family: 'Arial', sans-serif; | |
| } | |
| .wood-box textarea { | |
| border-left: 4px solid #10b981 !important; | |
| background-color: #f0fdf4 !important; | |
| } | |
| .fire-box textarea { | |
| border-left: 4px solid #ef4444 !important; | |
| background-color: #fef2f2 !important; | |
| } | |
| .earth-box textarea { | |
| border-left: 4px solid #a855f7 !important; | |
| background-color: #faf5ff !important; | |
| } | |
| .metal-box textarea { | |
| border-left: 4px solid #f59e0b !important; | |
| background-color: #fffbeb !important; | |
| } | |
| .water-box textarea { | |
| border-left: 4px solid #3b82f6 !important; | |
| background-color: #eff6ff !important; | |
| } | |
| .critic-box textarea { | |
| border-left: 4px solid #6b7280 !important; | |
| background-color: #f9fafb !important; | |
| } | |
| .final-report-box { | |
| border: 2px solid #10b981 !important; | |
| border-radius: 8px !important; | |
| padding: 20px !important; | |
| background: linear-gradient(to bottom, #f0fdf4, #ffffff) !important; | |
| margin-top: 10px !important; | |
| font-size: 14px !important; | |
| max-height: 800px !important; | |
| overflow-y: auto !important; | |
| line-height: 1.8 !important; | |
| box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important; | |
| } | |
| .final-report-box h1 { | |
| color: #065f46 !important; | |
| font-size: 28px !important; | |
| margin-bottom: 16px !important; | |
| text-align: center !important; | |
| font-weight: bold !important; | |
| } | |
| .final-report-box h2 { | |
| color: #047857 !important; | |
| font-size: 22px !important; | |
| margin-top: 20px !important; | |
| margin-bottom: 12px !important; | |
| border-bottom: 2px solid #10b981 !important; | |
| padding-bottom: 8px !important; | |
| } | |
| .final-report-box h3 { | |
| color: #059669 !important; | |
| font-size: 18px !important; | |
| margin-top: 16px !important; | |
| margin-bottom: 10px !important; | |
| font-weight: 600 !important; | |
| } | |
| .final-report-box h4 { | |
| color: #10b981 !important; | |
| font-size: 16px !important; | |
| margin-top: 12px !important; | |
| margin-bottom: 8px !important; | |
| } | |
| .final-report-box table { | |
| border-collapse: collapse !important; | |
| width: 100% !important; | |
| margin: 20px 0 !important; | |
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important; | |
| } | |
| .final-report-box th, .final-report-box td { | |
| border: 1px solid #d1d5db !important; | |
| padding: 12px 14px !important; | |
| text-align: left !important; | |
| } | |
| .final-report-box th { | |
| background-color: #065f46 !important; | |
| font-weight: bold !important; | |
| color: #ffffff !important; | |
| text-transform: uppercase !important; | |
| font-size: 13px !important; | |
| letter-spacing: 0.5px !important; | |
| } | |
| .final-report-box tr:nth-child(even) { | |
| background-color: #f9fafb !important; | |
| } | |
| .final-report-box tr:hover { | |
| background-color: #f0fdf4 !important; | |
| transition: background-color 0.2s !important; | |
| } | |
| .final-report-box code { | |
| background-color: #ecfdf5 !important; | |
| padding: 3px 8px !important; | |
| border-radius: 4px !important; | |
| font-family: 'Consolas', 'Monaco', monospace !important; | |
| color: #047857 !important; | |
| font-size: 13px !important; | |
| border: 1px solid #10b981 !important; | |
| } | |
| .final-report-box pre { | |
| background-color: #1e293b !important; | |
| color: #e2e8f0 !important; | |
| padding: 16px !important; | |
| border-radius: 8px !important; | |
| overflow-x: auto !important; | |
| margin: 16px 0 !important; | |
| font-size: 13px !important; | |
| line-height: 1.5 !important; | |
| } | |
| .final-report-box pre code { | |
| background-color: transparent !important; | |
| color: #e2e8f0 !important; | |
| padding: 0 !important; | |
| border: none !important; | |
| } | |
| .final-report-box blockquote { | |
| border-left: 4px solid #10b981 !important; | |
| padding-left: 16px !important; | |
| margin: 16px 0 !important; | |
| color: #064e3b !important; | |
| font-style: italic !important; | |
| background-color: #f0fdf4 !important; | |
| padding: 14px 16px !important; | |
| border-radius: 0 8px 8px 0 !important; | |
| } | |
| .final-report-box ul, .final-report-box ol { | |
| margin-left: 24px !important; | |
| margin-bottom: 16px !important; | |
| } | |
| .final-report-box li { | |
| margin-bottom: 8px !important; | |
| line-height: 1.8 !important; | |
| } | |
| .final-report-box strong { | |
| color: #065f46 !important; | |
| font-weight: 600 !important; | |
| } | |
| .final-report-box em { | |
| color: #047857 !important; | |
| } | |
| .final-report-box hr { | |
| border: none !important; | |
| border-top: 2px solid #10b981 !important; | |
| margin: 28px 0 !important; | |
| } | |
| .final-report-box a { | |
| color: #059669 !important; | |
| text-decoration: underline !important; | |
| } | |
| .final-report-box a:hover { | |
| color: #047857 !important; | |
| } | |
| h1 { | |
| text-align: center; | |
| color: #1f2937; | |
| margin-bottom: 10px; | |
| } | |
| h3 { | |
| font-weight: 600; | |
| margin-bottom: 8px; | |
| } | |
| .gradio-container { | |
| max-width: 1400px; | |
| margin: 0 auto; | |
| } | |
| """ | |
| # Gradio ์ธํฐํ์ด์ค | |
| with gr.Blocks( | |
| title="AGI ์คํ ์ ๋ฌธ ๋ณด๊ณ ์ ์์คํ ", | |
| theme=gr.themes.Soft(), | |
| css=css, | |
| analytics_enabled=False | |
| ) as app: | |
| gr.Markdown( | |
| """ | |
| # ๐ AGI ์์ค ์คํยท์ค์ ๊ธฐ๋ฐ ์ ๋ฌธ ๋ณด๊ณ ์ ์์ฑ ์์คํ  | |
| ### ๐ ์ฐจ์ธ๋ ์ธ๊ณต์ง๋ฅ ์ง๋จ์ง์ฑ ํ๋ซํผ | |
| > **"๋ค์ฏ ๊ฐ์ง ์ ๋ฌธ์ฑ์ ์๋์ง๋ก ์ฐฝ์ถํ๋ ์ต๊ณ ์์ค์ ์ ๋ต ๋ณด๊ณ ์"** | |
| ### ๐ ํ๋ก์ธ์ค: ๆจโ๋นํโ็ซโ๋นํโๅโ๋นํโ้โ๋นํโๆฐดโ๋นํโๆจ(์ต์ข ) | |
| | ์ญํ | ๋๋ชฉยท์คํ | AGI ์ ๋ฌธ์ฑ | | |
| |------|-----------|-------------| | |
| | ๐ณ **์ ๋ต์  ๋น์  ์ค๊ณ์** | ไปยทๆจ | ๋ฏธ๋์์ธก, ์์คํ ์  ์ฌ๊ณ , ํ์ ์ ๋ต | | |
| | ๐ฅ **ํ์ ์ ๋ต ์ํคํ ํธ** | ็พฉยท็ซ | ํ๊ดด์  ํ์ , ๋น์ฆ๋์ค ๋ชจ๋ธ, ๊ฒฝ์์ฐ์ | | |
| | ๐๏ธ **์คํ ์ต์ ํ ์ ๋ฌธ๊ฐ** | ไฟกยทๅ | ํ๋ก์ ํธ ๊ฑฐ๋ฒ๋์ค, ํ์ง ์์คํ , ROI | | |
| | โ๏ธ **์์คํ  ์ํคํ ์ฒ ๋ง์คํฐ** | ็ฆฎยท้ | ์ํฐํ๋ผ์ด์ฆ ์ค๊ณ, ๊ธฐ์ ํ์ค, ํ์ฅ์ฑ | | |
| | ๐ง **๋ฏธ๋๊ธฐ์ ์ฐ๊ตฌ์์ฅ** | ๆบยทๆฐด | ์ ๊ธฐ์ R&D, AI/ML, ๊ธฐ์ ์ตํฉ | | |
| | ๐ **์ ๋ต ๊ฒ์ฆ ์ ๋ฌธ๊ฐ** | ์ค๋ฆฝ | McKinsey๊ธ ๋ถ์, ๋ฆฌ์คํฌ ํ๊ฐ | | |
| --- | |
| **๐ก ๋ณธ ์์คํ ์ AGI(Artificial General Intelligence) ์์ค์ ๋ถ์๋ ฅ๊ณผ ์ฐฝ์์ฑ์ ๋ฐํ์ผ๋ก** | |
| **McKinsey, BCG, Bain ์์ค์ ์ ๋ฌธ ์ปจ์คํ ๋ณด๊ณ ์๋ฅผ ์๋์ผ๋ก ์์ฑํฉ๋๋ค.** | |
| """ | |
| ) | |
| with gr.Row(): | |
| with gr.Column(scale=3): | |
| llm_mode = gr.Radio( | |
| choices=["default", "commercial"], | |
| value="commercial", | |
| label="AI ๋ชจ๋ธ ์ ํ", | |
| info="commercial: Gemini 2.5 Pro (AGI Mode) - ๊ถ์ฅ" | |
| ) | |
| user_input = gr.Textbox( | |
| label="๋ณด๊ณ ์ ์์ฒญ์ฌํญ", | |
| placeholder="์: ์ฐ๋ฆฌ ํ์ฌ์ ๋์งํธ ์ ํ ์ ๋ต๊ณผ 3๊ฐ๋  ์คํ ๋ก๋๋งต์ ์๋ฆฝํด์ฃผ์ธ์", | |
| lines=4 | |
| ) | |
| with gr.Row(): | |
| submit_btn = gr.Button("๐ ์ ๋ฌธ ๋ณด๊ณ ์ ์์ฑ", variant="primary", scale=2) | |
| clear_btn = gr.Button("๐๏ธ ์ด๊ธฐํ", scale=1) | |
| with gr.Column(scale=1): | |
| status_text = gr.Textbox( | |
| label="ํ๋ก์ธ์ค ์ํ", | |
| interactive=False, | |
| value="AGI ์์คํ  ๋๊ธฐ ์ค...", | |
| lines=3 | |
| ) | |
| # ์ต์ข ๋ณด๊ณ ์ ์น์  | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Markdown(""" | |
| ### ๐ ์ต์ข ์ ๋ฌธ ๋ถ์ ๋ณด๊ณ ์ | |
| <p style="color: #666; margin-top: -10px;">Executive Summary & Strategic Recommendations</p> | |
| """) | |
| final_report = gr.Markdown( | |
| value="*AGI ์์ค์ ์ ๋ฌธ ๋ณด๊ณ ์๊ฐ ์ฌ๊ธฐ์ ์์ฑ๋ฉ๋๋ค.*", | |
| elem_classes=["final-report-box"] | |
| ) | |
| # ์คํ ์ถ๋ ฅ - 2x3 ๊ทธ๋ฆฌ๋ | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Markdown("### ๐ณ ๆจ - ์ ๋ต์  ๋น์  ์ค๊ณ์ (ไป)") | |
| wood_output = gr.Textbox( | |
| label="", | |
| lines=12, | |
| max_lines=18, | |
| interactive=False, | |
| elem_classes=["wood-box"] | |
| ) | |
| with gr.Column(): | |
| gr.Markdown("### ๐ฅ ็ซ - ํ์ ์ ๋ต ์ํคํ ํธ (็พฉ)") | |
| fire_output = gr.Textbox( | |
| label="", | |
| lines=12, | |
| max_lines=18, | |
| interactive=False, | |
| elem_classes=["fire-box"] | |
| ) | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Markdown("### ๐๏ธ ๅ - ์คํ ์ต์ ํ ์ ๋ฌธ๊ฐ (ไฟก)") | |
| earth_output = gr.Textbox( | |
| label="", | |
| lines=12, | |
| max_lines=18, | |
| interactive=False, | |
| elem_classes=["earth-box"] | |
| ) | |
| with gr.Column(): | |
| gr.Markdown("### โ๏ธ ้ - ์์คํ  ์ํคํ ์ฒ ๋ง์คํฐ (็ฆฎ)") | |
| metal_output = gr.Textbox( | |
| label="", | |
| lines=12, | |
| max_lines=18, | |
| interactive=False, | |
| elem_classes=["metal-box"] | |
| ) | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Markdown("### ๐ง ๆฐด - ๋ฏธ๋๊ธฐ์ ์ฐ๊ตฌ์์ฅ (ๆบ)") | |
| water_output = gr.Textbox( | |
| label="", | |
| lines=12, | |
| max_lines=18, | |
| interactive=False, | |
| elem_classes=["water-box"] | |
| ) | |
| with gr.Column(): | |
| gr.Markdown("### ๐ ์ ๋ต ๊ฒ์ฆ ์ ๋ฌธ๊ฐ") | |
| critic_output = gr.Textbox( | |
| label="", | |
| lines=12, | |
| max_lines=18, | |
| interactive=False, | |
| elem_classes=["critic-box"] | |
| ) | |
| # ์์  | |
| gr.Examples( | |
| examples=[ | |
| "์ฐ๋ฆฌ ํ์ฌ์ ๋์งํธ ์ ํ ์ ๋ต๊ณผ 3๊ฐ๋  ์คํ ๋ก๋๋งต์ ์๋ฆฝํด์ฃผ์ธ์", | |
| "๊ธ๋ก๋ฒ ์์ฅ ์ง์ถ์ ์ํ ์ข ํฉ์ ์ธ ์ฌ์ ์ ๋ต๊ณผ ๋ฆฌ์คํฌ ๋ถ์ ๋ณด๊ณ ์๋ฅผ ์์ฑํด์ฃผ์ธ์", | |
| "AI ๊ธฐ๋ฐ ์ ๊ท ๋น์ฆ๋์ค ๋ชจ๋ธ ๊ฐ๋ฐ๊ณผ ์์ตํ ์ ๋ต์ ์ ์ํด์ฃผ์ธ์", | |
| "ESG ๊ฒฝ์ ์ฒด๊ณ ๊ตฌ์ถ๊ณผ ์ง์๊ฐ๋ฅ์ฑ ์ ๋ต ๋ณด๊ณ ์๋ฅผ ์์ฑํด์ฃผ์ธ์", | |
| "๋ฉํ๋ฒ์ค ํ๋ซํผ ๊ตฌ์ถ์ ์ํ ๊ธฐ์ ์ํคํ ์ฒ์ ์ฌ์ ๊ณํ์ ์๋ฆฝํด์ฃผ์ธ์", | |
| "๊ณต๊ธ๋ง ์ต์ ํ์ ์ค๋งํธ ํฉํ ๋ฆฌ ์ ํ ์ ๋ต์ ๋ถ์ํด์ฃผ์ธ์", | |
| "๋ฐ์ดํฐ ๊ธฐ๋ฐ ์์ฌ๊ฒฐ์  ์ฒด๊ณ ๊ตฌ์ถ ๋ฐฉ์๊ณผ ๊ฑฐ๋ฒ๋์ค ๋ชจ๋ธ์ ์ ์ํด์ฃผ์ธ์", | |
| "๊ณ ๊ฐ ๊ฒฝํ ํ์ ์ ์ํ ์ด๋์ฑ๋ ์ ๋ต๊ณผ ์คํ ๊ณํ์ ์๋ฆฝํด์ฃผ์ธ์" | |
| ], | |
| inputs=user_input, | |
| label="๐ก ์ ๋ฌธ ๋ณด๊ณ ์ ์์ " | |
| ) | |
| # ์ด๋ฒคํธ ํธ๋ค๋ฌ | |
| submit_btn.click( | |
| fn=process_wuxing_query, | |
| inputs=[user_input, llm_mode], | |
| outputs=[wood_output, fire_output, earth_output, metal_output, water_output, critic_output, final_report, status_text] | |
| ).then( | |
| fn=lambda: "", | |
| outputs=[user_input] | |
| ) | |
| user_input.submit( | |
| fn=process_wuxing_query, | |
| inputs=[user_input, llm_mode], | |
| outputs=[wood_output, fire_output, earth_output, metal_output, water_output, critic_output, final_report, status_text] | |
| ).then( | |
| fn=lambda: "", | |
| outputs=[user_input] | |
| ) | |
| clear_btn.click( | |
| fn=clear_wuxing, | |
| outputs=[wood_output, fire_output, earth_output, metal_output, water_output, critic_output, final_report, status_text] | |
| ) | |
| if __name__ == "__main__": | |
| app.queue() | |
| app.launch( | |
| server_name="0.0.0.0", | |
| server_port=7860, | |
| share=True, | |
| show_error=True | |
| ) | 
