Spaces:
Running
Running
Delete app-backup2.py
Browse files- app-backup2.py +0 -1661
app-backup2.py
DELETED
@@ -1,1661 +0,0 @@
|
|
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 LLMCollaborativeSystem:
|
42 |
-
def __init__(self):
|
43 |
-
self.token = FRIENDLI_TOKEN
|
44 |
-
self.bapi_token = BAPI_TOKEN
|
45 |
-
self.gemini_api_key = GEMINI_API_KEY
|
46 |
-
self.api_url = API_URL
|
47 |
-
self.brave_url = BRAVE_SEARCH_URL
|
48 |
-
self.model_id = MODEL_ID
|
49 |
-
self.test_mode = TEST_MODE or (self.token == "YOUR_FRIENDLI_TOKEN")
|
50 |
-
self.use_gemini = False
|
51 |
-
self.gemini_client = None
|
52 |
-
|
53 |
-
if self.test_mode:
|
54 |
-
logger.warning("ํ
์คํธ ๋ชจ๋๋ก ์คํ๋ฉ๋๋ค.")
|
55 |
-
if self.bapi_token == "YOUR_BRAVE_API_TOKEN":
|
56 |
-
logger.warning("Brave API ํ ํฐ์ด ์ค์ ๋์ง ์์์ต๋๋ค.")
|
57 |
-
if self.gemini_api_key == "YOUR_GEMINI_API_KEY":
|
58 |
-
logger.warning("Gemini API ํ ํฐ์ด ์ค์ ๋์ง ์์์ต๋๋ค.")
|
59 |
-
|
60 |
-
def set_llm_mode(self, mode: str):
|
61 |
-
"""LLM ๋ชจ๋ ์ค์ (default ๋๋ commercial)"""
|
62 |
-
if mode == "commercial" and GEMINI_AVAILABLE and self.gemini_api_key != "YOUR_GEMINI_API_KEY":
|
63 |
-
self.use_gemini = True
|
64 |
-
if not self.gemini_client:
|
65 |
-
self.gemini_client = genai.Client(api_key=self.gemini_api_key)
|
66 |
-
logger.info("Gemini 2.5 Pro ๋ชจ๋๋ก ์ ํ๋์์ต๋๋ค.")
|
67 |
-
else:
|
68 |
-
self.use_gemini = False
|
69 |
-
logger.info("๊ธฐ๋ณธ LLM ๋ชจ๋๋ก ์ ํ๋์์ต๋๋ค.")
|
70 |
-
|
71 |
-
def create_headers(self):
|
72 |
-
"""API ํค๋ ์์ฑ"""
|
73 |
-
return {
|
74 |
-
"Authorization": f"Bearer {self.token}",
|
75 |
-
"Content-Type": "application/json"
|
76 |
-
}
|
77 |
-
|
78 |
-
def create_brave_headers(self):
|
79 |
-
"""Brave API ํค๋ ์์ฑ"""
|
80 |
-
return {
|
81 |
-
"Accept": "application/json",
|
82 |
-
"Accept-Encoding": "gzip",
|
83 |
-
"X-Subscription-Token": self.bapi_token
|
84 |
-
}
|
85 |
-
|
86 |
-
def create_supervisor_initial_prompt(self, user_query: str) -> str:
|
87 |
-
"""๊ฐ๋
์ AI ์ด๊ธฐ ํ๋กฌํํธ ์์ฑ"""
|
88 |
-
return f"""๋น์ ์ ๊ฑฐ์์ ๊ด์ ์์ ๋ถ์ํ๊ณ ์ง๋ํ๋ ๊ฐ๋
์ AI์
๋๋ค.
|
89 |
-
|
90 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
91 |
-
|
92 |
-
์ด ์ง๋ฌธ์ ๋ํด:
|
93 |
-
1. ์ ์ฒด์ ์ธ ์ ๊ทผ ๋ฐฉํฅ๊ณผ ํ๋ ์์ํฌ๋ฅผ ์ ์ํ์ธ์
|
94 |
-
2. ํต์ฌ ์์์ ๊ณ ๋ ค์ฌํญ์ ๊ตฌ์กฐํํ์ฌ ์ค๋ช
ํ์ธ์
|
95 |
-
3. ์ด ์ฃผ์ ์ ๋ํด ์กฐ์ฌ๊ฐ ํ์ํ 5-7๊ฐ์ ๊ตฌ์ฒด์ ์ธ ํค์๋๋ ๊ฒ์์ด๋ฅผ ์ ์ํ์ธ์
|
96 |
-
|
97 |
-
ํค์๋๋ ๋ค์ ํ์์ผ๋ก ์ ์ํ์ธ์:
|
98 |
-
[๊ฒ์ ํค์๋]: ํค์๋1, ํค์๋2, ํค์๋3, ํค์๋4, ํค์๋5"""
|
99 |
-
|
100 |
-
def create_researcher_prompt(self, user_query: str, supervisor_guidance: str, search_results: Dict[str, List[Dict]]) -> str:
|
101 |
-
"""์กฐ์ฌ์ AI ํ๋กฌํํธ ์์ฑ"""
|
102 |
-
search_summary = ""
|
103 |
-
all_results = []
|
104 |
-
|
105 |
-
for keyword, results in search_results.items():
|
106 |
-
search_summary += f"\n\n**{keyword}์ ๋ํ ๊ฒ์ ๊ฒฐ๊ณผ:**\n"
|
107 |
-
for i, result in enumerate(results[:10], 1): # ์์ 10๊ฐ๋ง ํ์
|
108 |
-
search_summary += f"{i}. {result.get('title', 'N/A')} (์ ๋ขฐ๋: {result.get('credibility_score', 0):.2f})\n"
|
109 |
-
search_summary += f" - {result.get('description', 'N/A')}\n"
|
110 |
-
search_summary += f" - ์ถ์ฒ: {result.get('url', 'N/A')}\n"
|
111 |
-
if result.get('published'):
|
112 |
-
search_summary += f" - ๊ฒ์์ผ: {result.get('published')}\n"
|
113 |
-
|
114 |
-
all_results.extend(results)
|
115 |
-
|
116 |
-
# ๋ชจ์ ๊ฐ์ง
|
117 |
-
contradictions = self.detect_contradictions(all_results)
|
118 |
-
contradiction_text = ""
|
119 |
-
if contradictions:
|
120 |
-
contradiction_text = "\n\n**๋ฐ๊ฒฌ๋ ์ ๋ณด ๋ชจ์:**\n"
|
121 |
-
for cont in contradictions[:3]: # ์ต๋ 3๊ฐ๋ง ํ์
|
122 |
-
contradiction_text += f"- {cont['type']}: {cont['source1']} vs {cont['source2']}\n"
|
123 |
-
|
124 |
-
return f"""๋น์ ์ ์ ๋ณด๋ฅผ ์กฐ์ฌํ๊ณ ์ ๋ฆฌํ๋ ์กฐ์ฌ์ AI์
๋๋ค.
|
125 |
-
|
126 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
127 |
-
|
128 |
-
๊ฐ๋
์ AI์ ์ง์นจ:
|
129 |
-
{supervisor_guidance}
|
130 |
-
|
131 |
-
๋ธ๋ ์ด๋ธ ๊ฒ์ ๊ฒฐ๊ณผ (์ ๋ขฐ๋ ์ ์ ํฌํจ):
|
132 |
-
{search_summary}
|
133 |
-
{contradiction_text}
|
134 |
-
|
135 |
-
์ ๊ฒ์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํ์ผ๋ก:
|
136 |
-
1. ๊ฐ ํค์๋๋ณ๋ก ์ค์ํ ์ ๋ณด๋ฅผ ์ ๋ฆฌํ์ธ์
|
137 |
-
2. ์ ๋ขฐํ ์ ์๋ ์ถ์ฒ(์ ๋ขฐ๋ 0.7 ์ด์)๋ฅผ ์ฐ์ ์ ์ผ๋ก ์ฐธ๊ณ ํ์ธ์
|
138 |
-
3. ์ถ์ฒ๋ฅผ ๋ช
ํํ ํ๊ธฐํ์ฌ ์คํ์ AI๊ฐ ๊ฒ์ฆํ ์ ์๋๋ก ํ์ธ์
|
139 |
-
4. ์ ๋ณด์ ๋ชจ์์ด ์๋ค๋ฉด ์์ชฝ ๊ด์ ์ ๋ชจ๋ ์ ์ํ์ธ์
|
140 |
-
5. ์ต์ ํธ๋ ๋๋ ์ค์ํ ํต๊ณ๊ฐ ์๋ค๋ฉด ๊ฐ์กฐํ์ธ์
|
141 |
-
6. ์ ๋ขฐ๋๊ฐ ๋ฎ์ ์ ๋ณด๋ ์ฃผ์ ํ์์ ํจ๊ป ํฌํจํ์ธ์"""
|
142 |
-
|
143 |
-
def create_supervisor_execution_prompt(self, user_query: str, research_summary: str) -> str:
|
144 |
-
"""๊ฐ๋
์ AI์ ์คํ ์ง์ ํ๋กฌํํธ"""
|
145 |
-
return f"""๋น์ ์ ๊ฑฐ์์ ๊ด์ ์์ ๋ถ์ํ๊ณ ์ง๋ํ๋ ๊ฐ๋
์ AI์
๋๋ค.
|
146 |
-
|
147 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
148 |
-
|
149 |
-
์กฐ์ฌ์ AI๊ฐ ์ ๋ฆฌํ ์กฐ์ฌ ๋ด์ฉ:
|
150 |
-
{research_summary}
|
151 |
-
|
152 |
-
์ ์กฐ์ฌ ๋ด์ฉ์ ๊ธฐ๋ฐ์ผ๋ก ์คํ์ AI์๊ฒ ์์ฃผ ๊ตฌ์ฒด์ ์ธ ์ง์๋ฅผ ๋ด๋ ค์ฃผ์ธ์:
|
153 |
-
1. ์กฐ์ฌ๋ ์ ๋ณด๋ฅผ ์ด๋ป๊ฒ ํ์ฉํ ์ง ๋ช
ํํ ์ง์ํ์ธ์
|
154 |
-
2. ์คํ ๊ฐ๋ฅํ ๋จ๊ณ๋ณ ์์
์ ๊ตฌ์ฒด์ ์ผ๋ก ์ ์ํ์ธ์
|
155 |
-
3. ๊ฐ ๋จ๊ณ์์ ์ฐธ๊ณ ํด์ผ ํ ์กฐ์ฌ ๋ด์ฉ์ ๋ช
์ํ์ธ์
|
156 |
-
4. ์์๋๋ ๊ฒฐ๊ณผ๋ฌผ์ ํํ๋ฅผ ๊ตฌ์ฒด์ ์ผ๋ก ์ค๋ช
ํ์ธ์"""
|
157 |
-
|
158 |
-
def create_executor_prompt(self, user_query: str, supervisor_guidance: str, research_summary: str) -> str:
|
159 |
-
"""์คํ์ AI ํ๋กฌํํธ ์์ฑ"""
|
160 |
-
return f"""๋น์ ์ ์ธ๋ถ์ ์ธ ๋ด์ฉ์ ๊ตฌํํ๋ ์คํ์ AI์
๋๋ค.
|
161 |
-
|
162 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
163 |
-
|
164 |
-
์กฐ์ฌ์ AI๊ฐ ์ ๋ฆฌํ ์กฐ์ฌ ๋ด์ฉ:
|
165 |
-
{research_summary}
|
166 |
-
|
167 |
-
๊ฐ๋
์ AI์ ๊ตฌ์ฒด์ ์ธ ์ง์:
|
168 |
-
{supervisor_guidance}
|
169 |
-
|
170 |
-
์ ์กฐ์ฌ ๋ด์ฉ๊ณผ ์ง์์ฌํญ์ ๋ฐํ์ผ๋ก:
|
171 |
-
1. ์กฐ์ฌ๋ ์ ๋ณด๋ฅผ ์ ๊ทน ํ์ฉํ์ฌ ๊ตฌ์ฒด์ ์ธ ์คํ ๊ณํ์ ์์ฑํ์ธ์
|
172 |
-
2. ๊ฐ ๋จ๊ณ๋ณ๋ก ์ฐธ๊ณ ํ ์กฐ์ฌ ๋ด์ฉ์ ๋ช
์ํ์ธ์
|
173 |
-
3. ์ค์ ๋ก ์ ์ฉ ๊ฐ๋ฅํ ๊ตฌ์ฒด์ ์ธ ๋ฐฉ๋ฒ๋ก ์ ์ ์ํ์ธ์
|
174 |
-
4. ์์๋๋ ์ฑ๊ณผ์ ์ธก์ ๋ฐฉ๋ฒ์ ํฌํจํ์ธ์"""
|
175 |
-
|
176 |
-
def create_executor_final_prompt(self, user_query: str, initial_response: str, supervisor_feedback: str, research_summary: str) -> str:
|
177 |
-
"""์คํ์ AI ์ต์ข
๋ณด๊ณ ์ ํ๋กฌํํธ"""
|
178 |
-
return f"""๋น์ ์ ์ธ๋ถ์ ์ธ ๋ด์ฉ์ ๊ตฌํํ๋ ์คํ์ AI์
๋๋ค.
|
179 |
-
|
180 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
181 |
-
|
182 |
-
์กฐ์ฌ์ AI์ ์กฐ์ฌ ๋ด์ฉ:
|
183 |
-
{research_summary}
|
184 |
-
|
185 |
-
๋น์ ์ ์ด๊ธฐ ๋ต๋ณ:
|
186 |
-
{initial_response}
|
187 |
-
|
188 |
-
๊ฐ๋
์ AI์ ํผ๋๋ฐฑ ๋ฐ ๊ฐ์ ์ฌํญ:
|
189 |
-
{supervisor_feedback}
|
190 |
-
|
191 |
-
์ ํผ๋๋ฐฑ์ ์์ ํ ๋ฐ์ํ์ฌ ์ต์ข
๋ณด๊ณ ์๋ฅผ ์์ฑํ์ธ์:
|
192 |
-
1. ๊ฐ๋
์์ ๋ชจ๋ ๊ฐ์ ์ฌํญ์ ๋ฐ์ํ์ธ์
|
193 |
-
2. ์กฐ์ฌ ๋ด์ฉ์ ๋์ฑ ๊ตฌ์ฒด์ ์ผ๋ก ํ์ฉํ์ธ์
|
194 |
-
3. ์คํ ๊ฐ๋ฅ์ฑ์ ๋์ด๋ ์ธ๋ถ ๊ณํ์ ํฌํจํ์ธ์
|
195 |
-
4. ๋ช
ํํ ๊ฒฐ๋ก ๊ณผ ๋ค์ ๋จ๊ณ๋ฅผ ์ ์ํ์ธ์
|
196 |
-
5. ์ ๋ฌธ์ ์ด๊ณ ์์ฑ๋ ๋์ ์ต์ข
๋ณด๊ณ ์ ํ์์ผ๋ก ์์ฑํ์ธ์"""
|
197 |
-
|
198 |
-
def create_evaluator_prompt(self, user_query: str, supervisor_responses: List[str], researcher_response: str, executor_responses: List[str], evaluator_responses: List[str] = None) -> str:
|
199 |
-
"""ํ๊ฐ์ AI ํ๋กฌํํธ ์์ฑ"""
|
200 |
-
evaluator_history = ""
|
201 |
-
if evaluator_responses and len(evaluator_responses) > 0:
|
202 |
-
evaluator_history = f"""
|
203 |
-
ํ๊ฐ์ AI์ ์ด์ ํ๊ฐ๋ค:
|
204 |
-
- ์กฐ์ฌ ๊ฒฐ๊ณผ ํ๊ฐ: {evaluator_responses[0] if len(evaluator_responses) > 0 else 'N/A'}
|
205 |
-
- ์ด๊ธฐ ๊ตฌํ ํ๊ฐ: {evaluator_responses[1] if len(evaluator_responses) > 1 else 'N/A'}
|
206 |
-
"""
|
207 |
-
|
208 |
-
return f"""๋น์ ์ ์ ์ฒด ํ๋ ฅ ๊ณผ์ ๊ณผ ๊ฒฐ๊ณผ๋ฅผ ํ๊ฐํ๋ ํ๊ฐ์ AI์
๋๋ค.
|
209 |
-
|
210 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
211 |
-
|
212 |
-
๊ฐ๋
์ AI์ ๋ถ์ ๋ฐ ์ง์:
|
213 |
-
- ์ด๊ธฐ ๋ถ์: {supervisor_responses[0]}
|
214 |
-
- ์คํ ์ง์: {supervisor_responses[1] if len(supervisor_responses) > 1 else 'N/A'}
|
215 |
-
- ๊ฐ์ ์ง์: {supervisor_responses[2] if len(supervisor_responses) > 2 else 'N/A'}
|
216 |
-
|
217 |
-
์กฐ์ฌ์ AI์ ์กฐ์ฌ ๊ฒฐ๊ณผ:
|
218 |
-
{researcher_response}
|
219 |
-
|
220 |
-
์คํ์ AI์ ๊ตฌํ:
|
221 |
-
- ์ด๊ธฐ ๊ตฌํ: {executor_responses[0]}
|
222 |
-
- ์ต์ข
๋ณด๊ณ ์: {executor_responses[1] if len(executor_responses) > 1 else 'N/A'}
|
223 |
-
{evaluator_history}
|
224 |
-
์ ์ ์ฒด ๊ณผ์ ์ ํ๊ฐํ์ฌ:
|
225 |
-
1. **ํ์ง ํ๊ฐ**: ๊ฐ AI์ ๋ต๋ณ ํ์ง๊ณผ ์ญํ ์ํ๋๋ฅผ ํ๊ฐํ์ธ์ (10์ ๋ง์ )
|
226 |
-
2. **ํ๋ ฅ ํจ๊ณผ์ฑ**: AI ๊ฐ ํ๋ ฅ์ด ์ผ๋ง๋ ํจ๊ณผ์ ์ด์๋์ง ํ๊ฐํ์ธ์
|
227 |
-
3. **์ ๋ณด ํ์ฉ๋**: ์น ๊ฒ์ ์ ๋ณด๊ฐ ์ผ๋ง๋ ์ ํ์ฉ๋์๋์ง ํ๊ฐํ์ธ์
|
228 |
-
4. **๊ฐ์ ์ **: ํฅํ ๊ฐ์ ์ด ํ์ํ ๋ถ๋ถ์ ๊ตฌ์ฒด์ ์ผ๋ก ์ ์ํ์ธ์
|
229 |
-
5. **์ต์ข
ํ์ **: ์ ์ฒด ํ๋ก์ธ์ค์ ๋ํ ์ข
ํฉ ํ๊ฐ๋ฅผ ์ ์ํ์ธ์
|
230 |
-
|
231 |
-
ํ๊ฐ๋ ๊ตฌ์ฒด์ ์ด๊ณ ๊ฑด์ค์ ์ผ๋ก ์์ฑํ์ธ์."""
|
232 |
-
|
233 |
-
def extract_keywords(self, supervisor_response: str) -> List[str]:
|
234 |
-
"""๊ฐ๋
์ ์๋ต์์ ํค์๋ ์ถ์ถ"""
|
235 |
-
keywords = []
|
236 |
-
|
237 |
-
# [๊ฒ์ ํค์๋]: ํ์์ผ๋ก ํค์๋ ์ฐพ๊ธฐ
|
238 |
-
keyword_match = re.search(r'\[๊ฒ์ ํค์๋\]:\s*(.+)', supervisor_response, re.IGNORECASE)
|
239 |
-
if keyword_match:
|
240 |
-
keyword_str = keyword_match.group(1)
|
241 |
-
keywords = [k.strip() for k in keyword_str.split(',') if k.strip()]
|
242 |
-
|
243 |
-
# ํค์๋๊ฐ ์์ผ๋ฉด ๊ธฐ๋ณธ ํค์๋ ์์ฑ
|
244 |
-
if not keywords:
|
245 |
-
keywords = ["best practices", "implementation guide", "case studies", "latest trends", "success factors"]
|
246 |
-
|
247 |
-
return keywords[:7] # ์ต๋ 7๊ฐ๋ก ์ ํ
|
248 |
-
|
249 |
-
def generate_synonyms(self, keyword: str) -> List[str]:
|
250 |
-
"""ํค์๋์ ๋์์ด/์ ์ฌ์ด ์์ฑ"""
|
251 |
-
synonyms = {
|
252 |
-
"optimization": ["improvement", "enhancement", "efficiency", "tuning"],
|
253 |
-
"performance": ["speed", "efficiency", "throughput", "latency"],
|
254 |
-
"strategy": ["approach", "method", "technique", "plan"],
|
255 |
-
"implementation": ["deployment", "execution", "development", "integration"],
|
256 |
-
"analysis": ["evaluation", "assessment", "study", "research"],
|
257 |
-
"management": ["administration", "governance", "control", "supervision"],
|
258 |
-
"best practices": ["proven methods", "industry standards", "guidelines", "recommendations"],
|
259 |
-
"trends": ["developments", "innovations", "emerging", "future"],
|
260 |
-
"machine learning": ["ML", "AI", "deep learning", "neural networks"],
|
261 |
-
"ํ๋ก์ ํธ": ["project", "์ฌ์
", "์
๋ฌด", "์์
"]
|
262 |
-
}
|
263 |
-
|
264 |
-
# ํค์๋ ์ ๊ทํ
|
265 |
-
keyword_lower = keyword.lower()
|
266 |
-
|
267 |
-
# ์ง์ ๋งค์นญ๋๋ ๋์์ด๊ฐ ์์ผ๋ฉด ๋ฐํ
|
268 |
-
if keyword_lower in synonyms:
|
269 |
-
return synonyms[keyword_lower][:2] # ์ต๋ 2๊ฐ
|
270 |
-
|
271 |
-
# ๋ถ๋ถ ๋งค์นญ ํ์ธ
|
272 |
-
for key, values in synonyms.items():
|
273 |
-
if key in keyword_lower or keyword_lower in key:
|
274 |
-
return values[:2]
|
275 |
-
|
276 |
-
# ๋์์ด๊ฐ ์์ผ๋ฉด ๋น ๋ฆฌ์คํธ
|
277 |
-
return []
|
278 |
-
|
279 |
-
def calculate_credibility_score(self, result: Dict) -> float:
|
280 |
-
"""๊ฒ์ ๊ฒฐ๊ณผ์ ์ ๋ขฐ๋ ์ ์ ๊ณ์ฐ (0-1)"""
|
281 |
-
score = 0.5 # ๊ธฐ๋ณธ ์ ์
|
282 |
-
|
283 |
-
url = result.get('url', '')
|
284 |
-
title = result.get('title', '')
|
285 |
-
description = result.get('description', '')
|
286 |
-
|
287 |
-
# URL ๊ธฐ๋ฐ ์ ์
|
288 |
-
trusted_domains = [
|
289 |
-
'.edu', '.gov', '.org', 'wikipedia.org', 'nature.com',
|
290 |
-
'sciencedirect.com', 'ieee.org', 'acm.org', 'springer.com',
|
291 |
-
'harvard.edu', 'mit.edu', 'stanford.edu', 'github.com'
|
292 |
-
]
|
293 |
-
|
294 |
-
for domain in trusted_domains:
|
295 |
-
if domain in url:
|
296 |
-
score += 0.2
|
297 |
-
break
|
298 |
-
|
299 |
-
# HTTPS ์ฌ์ฉ ์ฌ๋ถ
|
300 |
-
if url.startswith('https://'):
|
301 |
-
score += 0.1
|
302 |
-
|
303 |
-
# ์ ๋ชฉ๊ณผ ์ค๋ช
์ ๊ธธ์ด (๋๋ฌด ์งง์ผ๋ฉด ์ ๋ขฐ๋ ๊ฐ์)
|
304 |
-
if len(title) > 20:
|
305 |
-
score += 0.05
|
306 |
-
if len(description) > 50:
|
307 |
-
score += 0.05
|
308 |
-
|
309 |
-
# ๊ด๊ณ /์คํธ ํค์๋ ์ฒดํฌ
|
310 |
-
spam_keywords = ['buy now', 'sale', 'discount', 'click here', '100% free']
|
311 |
-
if any(spam in (title + description).lower() for spam in spam_keywords):
|
312 |
-
score -= 0.3
|
313 |
-
|
314 |
-
# ๋ ์ง ์ ๋ณด๊ฐ ์์ผ๋ฉด ๊ฐ์ฐ์
|
315 |
-
if any(year in description for year in ['2024', '2023', '2022']):
|
316 |
-
score += 0.1
|
317 |
-
|
318 |
-
return max(0, min(1, score)) # 0-1 ๋ฒ์๋ก ์ ํ
|
319 |
-
|
320 |
-
def fetch_url_content(self, url: str, max_length: int = 2000) -> str:
|
321 |
-
"""URL์์ ์ฝํ
์ธ ์ถ์ถ"""
|
322 |
-
try:
|
323 |
-
# User-Agent ์ค์
|
324 |
-
headers = {
|
325 |
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
326 |
-
}
|
327 |
-
|
328 |
-
req = urllib.request.Request(url, headers=headers)
|
329 |
-
|
330 |
-
with urllib.request.urlopen(req, timeout=5) as response:
|
331 |
-
html = response.read().decode('utf-8', errors='ignore')
|
332 |
-
|
333 |
-
soup = BeautifulSoup(html, 'html.parser')
|
334 |
-
|
335 |
-
# ์คํฌ๋ฆฝํธ์ ์คํ์ผ ์ ๊ฑฐ
|
336 |
-
for script in soup(["script", "style"]):
|
337 |
-
script.decompose()
|
338 |
-
|
339 |
-
# ๋ณธ๋ฌธ ํ
์คํธ ์ถ์ถ
|
340 |
-
text = soup.get_text()
|
341 |
-
|
342 |
-
# ๊ณต๋ฐฑ ์ ๋ฆฌ
|
343 |
-
lines = (line.strip() for line in text.splitlines())
|
344 |
-
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
|
345 |
-
text = ' '.join(chunk for chunk in chunks if chunk)
|
346 |
-
|
347 |
-
# ๊ธธ์ด ์ ํ
|
348 |
-
if len(text) > max_length:
|
349 |
-
text = text[:max_length] + "..."
|
350 |
-
|
351 |
-
return text
|
352 |
-
|
353 |
-
except Exception as e:
|
354 |
-
logger.error(f"URL ์ฝํ
์ธ ๊ฐ์ ธ์ค๊ธฐ ์คํจ {url}: {str(e)}")
|
355 |
-
return ""
|
356 |
-
|
357 |
-
def detect_contradictions(self, results: List[Dict]) -> List[Dict]:
|
358 |
-
"""๊ฒ์ ๊ฒฐ๊ณผ ๊ฐ ๋ชจ์ ๊ฐ์ง"""
|
359 |
-
contradictions = []
|
360 |
-
|
361 |
-
# ๊ฐ๋จํ ๋ชจ์ ๊ฐ์ง ํจํด
|
362 |
-
opposite_pairs = [
|
363 |
-
("increase", "decrease"),
|
364 |
-
("improve", "worsen"),
|
365 |
-
("effective", "ineffective"),
|
366 |
-
("success", "failure"),
|
367 |
-
("benefit", "harm"),
|
368 |
-
("positive", "negative"),
|
369 |
-
("growth", "decline")
|
370 |
-
]
|
371 |
-
|
372 |
-
# ๊ฒฐ๊ณผ๋ค์ ๋น๊ต
|
373 |
-
for i in range(len(results)):
|
374 |
-
for j in range(i + 1, len(results)):
|
375 |
-
desc1 = results[i].get('description', '').lower()
|
376 |
-
desc2 = results[j].get('description', '').lower()
|
377 |
-
|
378 |
-
# ๋ฐ๋ ๊ฐ๋
์ด ํฌํจ๋์ด ์๋์ง ํ์ธ
|
379 |
-
for word1, word2 in opposite_pairs:
|
380 |
-
if (word1 in desc1 and word2 in desc2) or (word2 in desc1 and word1 in desc2):
|
381 |
-
# ๊ฐ์ ์ฃผ์ ์ ๋ํด ๋ฐ๋ ์๊ฒฌ์ธ์ง ํ์ธ
|
382 |
-
common_words = set(desc1.split()) & set(desc2.split())
|
383 |
-
if len(common_words) > 5: # ๊ณตํต ๋จ์ด๊ฐ 5๊ฐ ์ด์์ด๋ฉด ๊ฐ์ ์ฃผ์ ๋ก ๊ฐ์ฃผ
|
384 |
-
contradictions.append({
|
385 |
-
'source1': results[i]['url'],
|
386 |
-
'source2': results[j]['url'],
|
387 |
-
'type': f"{word1} vs {word2}",
|
388 |
-
'desc1': results[i]['description'][:100],
|
389 |
-
'desc2': results[j]['description'][:100]
|
390 |
-
})
|
391 |
-
|
392 |
-
return contradictions
|
393 |
-
|
394 |
-
def brave_search(self, query: str) -> List[Dict]:
|
395 |
-
"""Brave Search API ํธ์ถ"""
|
396 |
-
if self.test_mode or self.bapi_token == "YOUR_BRAVE_API_TOKEN":
|
397 |
-
# ํ
์คํธ ๋ชจ๋์์๋ ์๋ฎฌ๋ ์ด์
๋ ๊ฒฐ๊ณผ ๋ฐํ
|
398 |
-
test_results = []
|
399 |
-
for i in range(5):
|
400 |
-
test_results.append({
|
401 |
-
"title": f"Best Practices for {query} - Source {i+1}",
|
402 |
-
"description": f"Comprehensive guide on implementing {query} with proven methodologies and real-world examples from industry leaders.",
|
403 |
-
"url": f"https://example{i+1}.com/{query.replace(' ', '-')}",
|
404 |
-
"credibility_score": 0.7 + (i * 0.05)
|
405 |
-
})
|
406 |
-
return test_results
|
407 |
-
|
408 |
-
try:
|
409 |
-
params = {
|
410 |
-
"q": query,
|
411 |
-
"count": 20, # 20๊ฐ๋ก ์ฆ๊ฐ
|
412 |
-
"safesearch": "moderate",
|
413 |
-
"freshness": "pw" # Past week for recent results
|
414 |
-
}
|
415 |
-
|
416 |
-
response = requests.get(
|
417 |
-
self.brave_url,
|
418 |
-
headers=self.create_brave_headers(),
|
419 |
-
params=params,
|
420 |
-
timeout=10
|
421 |
-
)
|
422 |
-
|
423 |
-
if response.status_code == 200:
|
424 |
-
data = response.json()
|
425 |
-
results = []
|
426 |
-
for item in data.get("web", {}).get("results", [])[:20]:
|
427 |
-
result = {
|
428 |
-
"title": item.get("title", ""),
|
429 |
-
"description": item.get("description", ""),
|
430 |
-
"url": item.get("url", ""),
|
431 |
-
"published": item.get("published", "")
|
432 |
-
}
|
433 |
-
# ์ ๋ขฐ๋ ์ ์ ๊ณ์ฐ
|
434 |
-
result["credibility_score"] = self.calculate_credibility_score(result)
|
435 |
-
results.append(result)
|
436 |
-
|
437 |
-
# ์ ๋ขฐ๋ ์ ์ ๊ธฐ์ค์ผ๋ก ์ ๋ ฌ
|
438 |
-
results.sort(key=lambda x: x['credibility_score'], reverse=True)
|
439 |
-
return results
|
440 |
-
else:
|
441 |
-
logger.error(f"Brave API ์ค๋ฅ: {response.status_code}")
|
442 |
-
return []
|
443 |
-
|
444 |
-
except Exception as e:
|
445 |
-
logger.error(f"Brave ๊ฒ์ ์ค ์ค๋ฅ: {str(e)}")
|
446 |
-
return []
|
447 |
-
|
448 |
-
def simulate_streaming(self, text: str, role: str) -> Generator[str, None, None]:
|
449 |
-
"""ํ
์คํธ ๋ชจ๋์์ ์คํธ๋ฆฌ๋ฐ ์๋ฎฌ๋ ์ด์
"""
|
450 |
-
words = text.split()
|
451 |
-
for i in range(0, len(words), 3):
|
452 |
-
chunk = " ".join(words[i:i+3])
|
453 |
-
yield chunk + " "
|
454 |
-
time.sleep(0.05)
|
455 |
-
|
456 |
-
def call_gemini_streaming(self, messages: List[Dict[str, str]], role: str) -> Generator[str, None, None]:
|
457 |
-
"""Gemini API ์คํธ๋ฆฌ๋ฐ ํธ์ถ"""
|
458 |
-
if not self.gemini_client:
|
459 |
-
yield "โ Gemini API ํด๋ผ์ด์ธํธ๊ฐ ์ด๊ธฐํ๋์ง ์์์ต๋๋ค."
|
460 |
-
return
|
461 |
-
|
462 |
-
try:
|
463 |
-
# ์์คํ
ํ๋กฌํํธ ์ค์
|
464 |
-
system_prompts = {
|
465 |
-
"supervisor": "๋น์ ์ ๊ฑฐ์์ ๊ด์ ์์ ๋ถ์ํ๊ณ ์ง๋ํ๋ ๊ฐ๋
์ AI์
๋๋ค.",
|
466 |
-
"researcher": "๋น์ ์ ์ ๋ณด๋ฅผ ์กฐ์ฌํ๊ณ ์ฒด๊ณ์ ์ผ๋ก ์ ๋ฆฌํ๋ ์กฐ์ฌ์ AI์
๋๋ค.",
|
467 |
-
"executor": "๋น์ ์ ์ธ๋ถ์ ์ธ ๋ด์ฉ์ ๊ตฌํํ๋ ์คํ์ AI์
๋๋ค.",
|
468 |
-
"evaluator": "๋น์ ์ ์ ์ฒด ํ๋ ฅ ๊ณผ์ ๊ณผ ๊ฒฐ๊ณผ๋ฅผ ํ๊ฐํ๋ ํ๊ฐ์ AI์
๋๋ค."
|
469 |
-
}
|
470 |
-
|
471 |
-
# Gemini ํ์์ contents ๊ตฌ์ฑ
|
472 |
-
contents = []
|
473 |
-
|
474 |
-
# ์์คํ
ํ๋กฌํํธ๋ฅผ ์ฒซ ๋ฒ์งธ ์ฌ์ฉ์ ๋ฉ์์ง๋ก ์ถ๊ฐ
|
475 |
-
contents.append(types.Content(
|
476 |
-
role="user",
|
477 |
-
parts=[types.Part.from_text(text=system_prompts.get(role, ""))]
|
478 |
-
))
|
479 |
-
contents.append(types.Content(
|
480 |
-
role="model",
|
481 |
-
parts=[types.Part.from_text(text="๋ค, ์ดํดํ์ต๋๋ค. ์ ์ญํ ์ ์ํํ๊ฒ ์ต๋๋ค.")]
|
482 |
-
))
|
483 |
-
|
484 |
-
# ์ฌ์ฉ์ ๋ฉ์์ง ์ถ๊ฐ
|
485 |
-
for msg in messages:
|
486 |
-
if msg["role"] == "user":
|
487 |
-
contents.append(types.Content(
|
488 |
-
role="user",
|
489 |
-
parts=[types.Part.from_text(text=msg["content"])]
|
490 |
-
))
|
491 |
-
|
492 |
-
# GenerateContentConfig ์ค์
|
493 |
-
generate_content_config = types.GenerateContentConfig(
|
494 |
-
temperature=0.7,
|
495 |
-
top_p=0.8,
|
496 |
-
max_output_tokens=4096,
|
497 |
-
response_mime_type="text/plain"
|
498 |
-
)
|
499 |
-
|
500 |
-
# ์คํธ๋ฆฌ๋ฐ ์์ฑ
|
501 |
-
for chunk in self.gemini_client.models.generate_content_stream(
|
502 |
-
model="gemini-2.5-pro",
|
503 |
-
contents=contents,
|
504 |
-
config=generate_content_config,
|
505 |
-
):
|
506 |
-
if chunk.text:
|
507 |
-
yield chunk.text
|
508 |
-
|
509 |
-
except Exception as e:
|
510 |
-
logger.error(f"Gemini API ์ค๋ฅ: {str(e)}")
|
511 |
-
yield f"โ Gemini API ์ค๋ฅ: {str(e)}"
|
512 |
-
|
513 |
-
def call_llm_streaming(self, messages: List[Dict[str, str]], role: str) -> Generator[str, None, None]:
|
514 |
-
"""์คํธ๋ฆฌ๋ฐ LLM API ํธ์ถ"""
|
515 |
-
|
516 |
-
# Gemini ๋ชจ๋์ธ ๊ฒฝ์ฐ
|
517 |
-
if self.use_gemini:
|
518 |
-
yield from self.call_gemini_streaming(messages, role)
|
519 |
-
return
|
520 |
-
|
521 |
-
# ํ
์คํธ ๋ชจ๋
|
522 |
-
if self.test_mode:
|
523 |
-
logger.info(f"ํ
์คํธ ๋ชจ๋ ์คํธ๋ฆฌ๋ฐ - Role: {role}")
|
524 |
-
test_responses = {
|
525 |
-
"supervisor_initial": """์ด ์ง๋ฌธ์ ๋ํ ๊ฑฐ์์ ๋ถ์์ ์ ์ํ๊ฒ ์ต๋๋ค.
|
526 |
-
|
527 |
-
1. **ํต์ฌ ๊ฐ๋
ํ์
**
|
528 |
-
- ์ง๋ฌธ์ ๋ณธ์ง์ ์์๋ฅผ ์ฌ์ธต ๋ถ์ํฉ๋๋ค
|
529 |
-
- ๊ด๋ จ๋ ์ฃผ์ ์ด๋ก ๊ณผ ์์น์ ๊ฒํ ํฉ๋๋ค
|
530 |
-
- ๋ค์ํ ๊ด์ ์์์ ์ ๊ทผ ๋ฐฉ๋ฒ์ ๊ณ ๋ คํฉ๋๋ค
|
531 |
-
|
532 |
-
2. **์ ๋ต์ ์ ๊ทผ ๋ฐฉํฅ**
|
533 |
-
- ์ฒด๊ณ์ ์ด๊ณ ๋จ๊ณ๋ณ ํด๊ฒฐ ๋ฐฉ์์ ์๋ฆฝํฉ๋๋ค
|
534 |
-
- ์ฅ๋จ๊ธฐ ๋ชฉํ๋ฅผ ๋ช
ํํ ์ค์ ํฉ๋๋ค
|
535 |
-
- ๋ฆฌ์คํฌ ์์ธ๊ณผ ๋์ ๋ฐฉ์์ ๋ง๋ จํฉ๋๋ค
|
536 |
-
|
537 |
-
3. **๊ธฐ๋ ํจ๊ณผ์ ๊ณผ์ **
|
538 |
-
- ์์๋๋ ๊ธ์ ์ ์ฑ๊ณผ๋ฅผ ๋ถ์ํฉ๋๋ค
|
539 |
-
- ์ ์ฌ์ ๋์ ๊ณผ์ ๋ฅผ ์๋ณํฉ๋๋ค
|
540 |
-
- ์ง์๊ฐ๋ฅํ ๋ฐ์ ๋ฐฉํฅ์ ์ ์ํฉ๋๋ค
|
541 |
-
|
542 |
-
[๊ฒ์ ํค์๋]: machine learning optimization, performance improvement strategies, model efficiency techniques, hyperparameter tuning best practices, latest ML trends 2024""",
|
543 |
-
|
544 |
-
"researcher": """์กฐ์ฌ ๊ฒฐ๊ณผ๋ฅผ ์ข
ํฉํ์ฌ ๋ค์๊ณผ ๊ฐ์ด ์ ๋ฆฌํ์ต๋๋ค.
|
545 |
-
|
546 |
-
**1. Machine Learning Optimization (์ ๋ขฐ๋ ๋์)**
|
547 |
-
- ์ต์ ์ฐ๊ตฌ์ ๋ฐ๋ฅด๋ฉด ๋ชจ๋ธ ์ต์ ํ์ ํต์ฌ์ ์ํคํ
์ฒ ์ค๊ณ์ ํ๋ จ ์ ๋ต์ ๊ท ํ์
๋๋ค (์ ๋ขฐ๋: 0.85)
|
548 |
-
- AutoML ๋๊ตฌ๋ค์ด ํ์ดํผํ๋ผ๋ฏธํฐ ํ๋์ ์๋ํํ์ฌ ํจ์จ์ฑ์ ํฌ๊ฒ ํฅ์์ํต๋๋ค (์ ๋ขฐ๋: 0.82)
|
549 |
-
- ์ถ์ฒ: ML Conference 2024 (https://mlconf2024.org), Google Research (https://research.google)
|
550 |
-
|
551 |
-
**2. Performance Improvement Strategies (์ ๋ขฐ๋ ๋์)**
|
552 |
-
- ๋ฐ์ดํฐ ํ์ง ๊ฐ์ ์ด ๋ชจ๋ธ ์ฑ๋ฅ ํฅ์์ 80%๋ฅผ ์ฐจ์งํ๋ค๋ ์ฐ๊ตฌ ๊ฒฐ๊ณผ (์ ๋ขฐ๋: 0.90)
|
553 |
-
- ์์๋ธ ๊ธฐ๋ฒ๊ณผ ์ ์ดํ์ต์ด ์ฃผ์ ์ฑ๋ฅ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ์
์ฆ๋จ (์ ๋ขฐ๋: 0.78)
|
554 |
-
- ์ถ์ฒ: Stanford AI Lab (https://ai.stanford.edu), MIT CSAIL (https://csail.mit.edu)
|
555 |
-
|
556 |
-
**3. Model Efficiency Techniques (์ ๋ขฐ๋ ์ค๊ฐ)**
|
557 |
-
- ๋ชจ๋ธ ๊ฒฝ๋ํ(Pruning, Quantization)๋ก ์ถ๋ก ์๋ 10๋ฐฐ ํฅ์ ๊ฐ๋ฅ (์ ๋ขฐ๋: 0.75)
|
558 |
-
- Knowledge Distillation์ผ๋ก ๋ชจ๋ธ ํฌ๊ธฐ 90% ๊ฐ์, ์ฑ๋ฅ ์ ์ง (์ ๋ขฐ๋: 0.72)
|
559 |
-
- ์ถ์ฒ: ArXiv ๋
ผ๋ฌธ (https://arxiv.org/abs/2023.xxxxx)
|
560 |
-
|
561 |
-
**4. ์ค์ ์ ์ฉ ์ฌ๋ก (์ ๋ขฐ๋ ๋์)**
|
562 |
-
- Netflix: ์ถ์ฒ ์์คํ
๊ฐ์ ์ผ๋ก ์ฌ์ฉ์ ๋ง์กฑ๋ 35% ํฅ์ (์ ๋ขฐ๋: 0.88)
|
563 |
-
- Tesla: ์ค์๊ฐ ๊ฐ์ฒด ์ธ์ ์๋ 50% ๊ฐ์ (์ ๋ขฐ๋: 0.80)
|
564 |
-
- OpenAI: GPT ๋ชจ๋ธ ํจ์จ์ฑ ๊ฐ์ ์ผ๋ก ๋น์ฉ 70% ์ ๊ฐ (์ ๋ขฐ๋: 0.85)
|
565 |
-
|
566 |
-
**ํต์ฌ ์ธ์ฌ์ดํธ:**
|
567 |
-
- ์ต์ ํธ๋ ๋๋ ํจ์จ์ฑ๊ณผ ์ฑ๋ฅ์ ๊ท ํ์ ์ด์
|
568 |
-
- 2024๋
๋ค์ด Sparse Models์ MoE(Mixture of Experts) ๊ธฐ๋ฒ์ด ๋ถ์
|
569 |
-
- ์ค๋ฌด ์ ์ฉ ์ ๋จ๊ณ๋ณ ๊ฒ์ฆ์ด ์ฑ๊ณต์ ํต์ฌ""",
|
570 |
-
|
571 |
-
"supervisor_execution": """์กฐ์ฌ ๋ด์ฉ์ ๋ฐํ์ผ๋ก ์คํ์ AI์๊ฒ ๋ค์๊ณผ ๊ฐ์ด ๊ตฌ์ฒด์ ์ผ๏ฟฝ๏ฟฝ๏ฟฝ ์ง์ํฉ๋๋ค.
|
572 |
-
|
573 |
-
**1๋จ๊ณ: ํ์ฌ ๋ชจ๋ธ ์ง๋จ (1์ฃผ์ฐจ)**
|
574 |
-
- ์กฐ์ฌ๋ ๋ฒค์น๋งํฌ ๊ธฐ์ค์ผ๋ก ํ์ฌ ๋ชจ๋ธ ์ฑ๋ฅ ํ๊ฐ
|
575 |
-
- Netflix ์ฌ๋ก๋ฅผ ์ฐธ๊ณ ํ์ฌ ์ฃผ์ ๋ณ๋ชฉ ์ง์ ์๋ณ
|
576 |
-
- AutoML ๋๊ตฌ๋ฅผ ํ์ฉํ ์ด๊ธฐ ์ต์ ํ ๊ฐ๋ฅ์ฑ ํ์
|
577 |
-
|
578 |
-
**2๋จ๊ณ: ๋ฐ์ดํฐ ํ์ง ๊ฐ์ (2-3์ฃผ์ฐจ)**
|
579 |
-
- ์กฐ์ฌ ๊ฒฐ๊ณผ์ "80% ๊ท์น"์ ๋ฐ๋ผ ๋ฐ์ดํฐ ์ ์ ์ฐ์ ์คํ
|
580 |
-
- ๋ฐ์ดํฐ ์ฆ๊ฐ ๊ธฐ๋ฒ ์ ์ฉ (์กฐ์ฌ๋ ์ต์ ๊ธฐ๋ฒ ํ์ฉ)
|
581 |
-
- A/B ํ
์คํธ๋ก ๊ฐ์ ํจ๊ณผ ์ธก์
|
582 |
-
|
583 |
-
**3๋จ๊ณ: ๋ชจ๋ธ ์ต์ ํ ๊ตฌํ (4-6์ฃผ์ฐจ)**
|
584 |
-
- Knowledge Distillation ์ ์ฉํ์ฌ ๋ชจ๋ธ ๊ฒฝ๋ํ
|
585 |
-
- ์กฐ์ฌ๋ Pruning ๊ธฐ๋ฒ์ผ๋ก ์ถ๋ก ์๋ ๊ฐ์
|
586 |
-
- Tesla ์ฌ๋ก์ ์ค์๊ฐ ์ฒ๋ฆฌ ์ต์ ํ ๊ธฐ๋ฒ ๋ฒค์น๋งํน
|
587 |
-
|
588 |
-
**4๋จ๊ณ: ์ฑ๊ณผ ๊ฒ์ฆ ๋ฐ ๋ฐฐํฌ (7-8์ฃผ์ฐจ)**
|
589 |
-
- OpenAI ์ฌ๋ก์ ๋น์ฉ ์ ๊ฐ ์งํ ์ ์ฉ
|
590 |
-
- ์กฐ์ฌ๋ ์ฑ๋ฅ ์งํ๋ก ๊ฐ์ ์จ ์ธก์
|
591 |
-
- ๋จ๊ณ์ ๋ฐฐํฌ ์ ๋ต ์๋ฆฝ""",
|
592 |
-
|
593 |
-
"executor": """๊ฐ๋
์์ ์ง์์ ์กฐ์ฌ ๋ด์ฉ์ ๊ธฐ๋ฐ์ผ๋ก ๊ตฌ์ฒด์ ์ธ ์คํ ๊ณํ์ ์๋ฆฝํฉ๋๋ค.
|
594 |
-
|
595 |
-
**1๋จ๊ณ: ํ์ฌ ๋ชจ๋ธ ์ง๋จ (1์ฃผ์ฐจ)**
|
596 |
-
- ์์์ผ-ํ์์ผ: MLflow๋ฅผ ์ฌ์ฉํ ํ์ฌ ๋ชจ๋ธ ๋ฉํธ๋ฆญ ์์ง
|
597 |
-
* ์กฐ์ฌ ๊ฒฐ๊ณผ ์ฐธ๊ณ : Netflix๊ฐ ์ฌ์ฉํ ํต์ฌ ์งํ (์ ํ๋, ์ง์ฐ์๊ฐ, ์ฒ๋ฆฌ๋)
|
598 |
-
- ์์์ผ-๋ชฉ์์ผ: AutoML ๋๊ตฌ (Optuna, Ray Tune) ์ค์ ๋ฐ ์ด๊ธฐ ์คํ
|
599 |
-
* ์กฐ์ฌ๋ best practice์ ๋ฐ๋ผ search space ์ ์
|
600 |
-
- ๊ธ์์ผ: ์ง๋จ ๋ณด๊ณ ์ ์์ฑ ๋ฐ ๊ฐ์ ์ฐ์ ์์ ๊ฒฐ์
|
601 |
-
|
602 |
-
**2๋จ๊ณ: ๋ฐ์ดํฐ ํ์ง ๊ฐ์ (2-3์ฃผ์ฐจ)**
|
603 |
-
- ๋ฐ์ดํฐ ์ ์ ํ์ดํ๋ผ์ธ ๊ตฌ์ถ
|
604 |
-
* ์กฐ์ฌ ๊ฒฐ๊ณผ์ "80% ๊ท์น" ์ ์ฉ: ๋๋ฝ๊ฐ, ์ด์์น, ๋ ์ด๋ธ ์ค๋ฅ ์ฒ๋ฆฌ
|
605 |
-
* ์ฝ๋ ์์: `data_quality_pipeline.py` ๊ตฌํ
|
606 |
-
- ๋ฐ์ดํฐ ์ฆ๊ฐ ๊ตฌํ
|
607 |
-
* ์ต์ ๊ธฐ๋ฒ ์ ์ฉ: MixUp, CutMix, AutoAugment
|
608 |
-
* ๊ฒ์ฆ ๋ฐ์ดํฐ์
์ผ๋ก ํจ๊ณผ ์ธก์ (๋ชฉํ: 15% ์ฑ๋ฅ ํฅ์)
|
609 |
-
|
610 |
-
**3๋จ๊ณ: ๋ชจ๋ธ ์ต์ ํ ๊ตฌํ (4-6์ฃผ์ฐจ)**
|
611 |
-
- Knowledge Distillation ๊ตฌํ
|
612 |
-
* Teacher ๋ชจ๋ธ: ํ์ฌ ๋๊ท๋ชจ ๋ชจ๋ธ
|
613 |
-
* Student ๋ชจ๋ธ: 90% ์์ ํฌ๊ธฐ ๋ชฉํ (์กฐ์ฌ ๊ฒฐ๊ณผ ๊ธฐ๋ฐ)
|
614 |
-
* ๊ตฌํ ํ๋ ์์ํฌ: PyTorch/TensorFlow""",
|
615 |
-
|
616 |
-
"supervisor_review": """์คํ์ AI์ ๊ณํ์ ๊ฒํ ํ ๊ฒฐ๊ณผ, ์กฐ์ฌ ๋ด์ฉ์ด ์ ๋ฐ์๋์์ต๋๋ค. ๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ์ฌํญ์ ์ ์ํฉ๋๋ค.
|
617 |
-
|
618 |
-
**๊ฐ์ **
|
619 |
-
- ์กฐ์ฌ๋ ์ฌ๋ก๋ค(Netflix, Tesla, OpenAI)์ด ๊ฐ ๋จ๊ณ์ ์ ์ ํ ํ์ฉ๋จ
|
620 |
-
- ๊ตฌ์ฒด์ ์ธ ๋๊ตฌ์ ๊ธฐ๋ฒ์ด ๋ช
์๋์ด ์คํ ๊ฐ๋ฅ์ฑ์ด ๋์
|
621 |
-
- ์ธก์ ๊ฐ๋ฅํ ๋ชฉํ๊ฐ ์กฐ์ฌ ๊ฒฐ๊ณผ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ค์ ๋จ
|
622 |
-
|
623 |
-
**๊ฐ์ ํ์์ฌํญ**
|
624 |
-
1. **๋ฆฌ์คํฌ ๊ด๋ฆฌ ๊ฐํ**
|
625 |
-
- ๊ฐ ๋จ๊ณ๋ณ ์คํจ ์๋๋ฆฌ์ค์ ๋์ ๋ฐฉ์ ์ถ๊ฐ ํ์
|
626 |
-
- ๊ธฐ์ ์ ๋ฌธ์ ๋ฐ์ ์ ๋ฐฑ์
๊ณํ ์๋ฆฝ
|
627 |
-
|
628 |
-
2. **๋น์ฉ ๋ถ์ ๊ตฌ์ฒดํ**
|
629 |
-
- OpenAI ์ฌ๋ก์ 70% ์ ๊ฐ์ ์ํ ๊ตฌ์ฒด์ ์ธ ๋น์ฉ ๊ณ์ฐ
|
630 |
-
- ROI ๋ถ์ ๋ฐ ํฌ์ ๋๋น ํจ๊ณผ ์ธก์ ๋ฐฉ๋ฒ
|
631 |
-
|
632 |
-
**์ถ๊ฐ ๊ถ์ฅ์ฌํญ**
|
633 |
-
- ์ต์ ์ฐ๊ตฌ ๋ํฅ ๋ชจ๋ํฐ๋ง ์ฒด๊ณ ๊ตฌ์ถ
|
634 |
-
- ๊ฒฝ์์ฌ ๋ฒค์น๋งํน์ ์ํ ์ ๊ธฐ์ ์ธ ์กฐ์ฌ ํ๋ก์ธ์ค""",
|
635 |
-
|
636 |
-
"executor_final": """๊ฐ๋
์ AI์ ํผ๋๋ฐฑ์ ์์ ํ ๋ฐ์ํ์ฌ ์ต์ข
์คํ ๋ณด๊ณ ์๋ฅผ ์์ฑํฉ๋๋ค.
|
637 |
-
|
638 |
-
# ๐ฏ ๊ธฐ๊ณํ์ต ๋ชจ๋ธ ์ฑ๋ฅ ํฅ์ ์ต์ข
์คํ ๋ณด๊ณ ์
|
639 |
-
|
640 |
-
## ๐ Executive Summary
|
641 |
-
|
642 |
-
๋ณธ ๋ณด๊ณ ์๋ ์น ๊ฒ์์ ํตํด ์์ง๋ ์ต์ ์ฌ๋ก์ ๊ฐ๋
์ AI์ ์ ๋ต์ ์ง์นจ์ ๋ฐํ์ผ๋ก, 8์ฃผ๊ฐ์ ์ฒด๊ณ์ ์ธ ๋ชจ๋ธ ์ต์ ํ ํ๋ก์ ํธ๋ฅผ ์ ์ํฉ๋๋ค.
|
643 |
-
|
644 |
-
### ๐ฏ ๋ชฉํ ๋ฌ์ฑ ์งํ
|
645 |
-
|
646 |
-
| ์งํ | ํ์ฌ | ๋ชฉํ | ๊ฐ์ ์จ |
|
647 |
-
|------|------|------|--------|
|
648 |
-
| ๋ชจ๋ธ ํฌ๊ธฐ | 2.5GB | 250MB | 90% ๊ฐ์ |
|
649 |
-
| ์ถ๋ก ์๋ | 45ms | 4.5ms | 10๋ฐฐ ํฅ์ |
|
650 |
-
| ์ด์ ๋น์ฉ | $2,000/์ | $600/์ | 70% ์ ๊ฐ |
|
651 |
-
| ์ ํ๋ | 92% | 90.5% | 1.5% ์์ค |
|
652 |
-
|
653 |
-
## ๐ 1๋จ๊ณ: ํ์ฌ ๋ชจ๋ธ ์ง๋จ ๋ฐ ๋ฒ ์ด์ค๋ผ์ธ ์ค์ (1์ฃผ์ฐจ)
|
654 |
-
|
655 |
-
### ์คํ ๊ณํ
|
656 |
-
|
657 |
-
**์-ํ์์ผ: ์ฑ๋ฅ ๋ฉํธ๋ฆญ ์์ง**
|
658 |
-
- MLflow๋ฅผ ํตํ ํ์ฌ ๋ชจ๋ธ ์ ์ฒด ๋ถ์
|
659 |
-
- Netflix ์ฌ๋ก ๊ธฐ๋ฐ ํต์ฌ ์งํ:
|
660 |
-
- ์ ํ๋: 92%
|
661 |
-
- ์ง์ฐ์๊ฐ: 45ms
|
662 |
-
- ์ฒ๋ฆฌ๋: 1,000 req/s
|
663 |
-
- GPU ๋ฉ๋ชจ๋ฆฌ: 8GB
|
664 |
-
|
665 |
-
**์-๋ชฉ์์ผ: AutoML ์ด๊ธฐ ํ์**
|
666 |
-
```python
|
667 |
-
# Optuna ํ์ดํผํ๋ผ๋ฏธํฐ ์ต์ ํ ์ค์
|
668 |
-
study = optuna.create_study(direction="maximize")
|
669 |
-
study.optimize(objective, n_trials=200)
|
670 |
-
|
671 |
-
# Ray Tune ๋ถ์ฐ ํ์ต ์ค์
|
672 |
-
analysis = tune.run(
|
673 |
-
train_model,
|
674 |
-
config=search_space,
|
675 |
-
num_samples=50,
|
676 |
-
resources_per_trial={"gpu": 1}
|
677 |
-
)
|
678 |
-
```
|
679 |
-
|
680 |
-
### ์์ ์ฐ์ถ๋ฌผ
|
681 |
-
- โ
์์ธ ์ฑ๋ฅ ๋ฒ ์ด์ค๋ผ์ธ ๋ฌธ์
|
682 |
-
- โ
๊ฐ์ ๊ธฐํ ์ฐ์ ์์ ๋งคํธ๋ฆญ์ค
|
683 |
-
- โ
๋ฆฌ์คํฌ ๋ ์ง์คํฐ
|
684 |
-
|
685 |
-
## ๐ 2๋จ๊ณ: ๋ฐ์ดํฐ ํ์ง ๊ฐ์ (2-3์ฃผ์ฐจ)
|
686 |
-
|
687 |
-
### ์คํ ๊ณํ
|
688 |
-
|
689 |
-
**๋ฐ์ดํฐ ์ ์ ํ์ดํ๋ผ์ธ ๊ตฌ์ถ**
|
690 |
-
|
691 |
-
> ์กฐ์ฌ ๊ฒฐ๊ณผ์ "80% ๊ท์น" ์ ์ฉ: ๋ฐ์ดํฐ ํ์ง์ด ์ฑ๋ฅ์ 80%๋ฅผ ๊ฒฐ์
|
692 |
-
|
693 |
-
```python
|
694 |
-
class DataQualityPipeline:
|
695 |
-
def __init__(self):
|
696 |
-
self.validators = [
|
697 |
-
MissingValueHandler(threshold=0.05),
|
698 |
-
OutlierDetector(method='isolation_forest'),
|
699 |
-
LabelConsistencyChecker(),
|
700 |
-
DataDriftMonitor()
|
701 |
-
]
|
702 |
-
|
703 |
-
def process(self, data):
|
704 |
-
for validator in self.validators:
|
705 |
-
data = validator.transform(data)
|
706 |
-
self.log_metrics(validator.get_stats())
|
707 |
-
return data
|
708 |
-
```
|
709 |
-
|
710 |
-
**๊ณ ๊ธ ๋ฐ์ดํฐ ์ฆ๊ฐ ๊ธฐ๋ฒ**
|
711 |
-
- **MixUp**: 15% ์ ํ๋ ํฅ์ ์์
|
712 |
-
- **CutMix**: ๊ฒฝ๊ณ ๊ฒ์ถ ์ฑ๋ฅ 20% ๊ฐ์
|
713 |
-
- **AutoAugment**: ์๋ ์ต์ ์ฆ๊ฐ ์ ์ฑ
ํ์
|
714 |
-
|
715 |
-
### ๋ฆฌ์คํฌ ๋์ ์ ๋ต
|
716 |
-
|
717 |
-
| ๋ฆฌ์คํฌ | ํ๋ฅ | ์ํฅ๋ | ๋์ ๋ฐฉ์ |
|
718 |
-
|--------|------|--------|-----------|
|
719 |
-
| ๋ฐ์ดํฐ ํ์ง ์ ํ | ์ค๊ฐ | ๋์ | ๋กค๋ฐฑ ๋ฉ์ปค๋์ฆ ๊ตฌํ |
|
720 |
-
| ์ฆ๊ฐ ๊ณผ์ ํฉ | ๋ฎ์ | ์ค๊ฐ | ๊ฒ์ฆ์
๋ถ๋ฆฌ ๋ฐ ๊ต์ฐจ ๊ฒ์ฆ |
|
721 |
-
| ์ฒ๋ฆฌ ์๊ฐ ์ฆ๊ฐ | ๋์ | ๋ฎ์ | ๋ณ๋ ฌ ์ฒ๋ฆฌ ํ์ดํ๋ผ์ธ |
|
722 |
-
|
723 |
-
## ๐ 3๋จ๊ณ: ๋ชจ๋ธ ์ต์ ํ ๊ตฌํ (4-6์ฃผ์ฐจ)
|
724 |
-
|
725 |
-
### Knowledge Distillation ์์ธ ๊ณํ
|
726 |
-
|
727 |
-
**Teacher-Student ์ํคํ
์ฒ**
|
728 |
-
- Teacher ๋ชจ๋ธ: ํ์ฌ 2.5GB ๋ชจ๋ธ
|
729 |
-
- Student ๋ชจ๋ธ ์คํ:
|
730 |
-
- ํ๋ผ๋ฏธํฐ: 250M โ 25M (90% ๊ฐ์)
|
731 |
-
- ๋ ์ด์ด: 24 โ 6
|
732 |
-
- Hidden dimension: 1024 โ 256
|
733 |
-
|
734 |
-
**ํ๋ จ ์ ๋ต**
|
735 |
-
```python
|
736 |
-
distillation_config = {
|
737 |
-
"temperature": 5.0,
|
738 |
-
"alpha": 0.7, # KD loss weight
|
739 |
-
"beta": 0.3, # Original loss weight
|
740 |
-
"epochs": 50,
|
741 |
-
"learning_rate": 1e-4,
|
742 |
-
"batch_size": 128
|
743 |
-
}
|
744 |
-
```
|
745 |
-
|
746 |
-
### Pruning & Quantization
|
747 |
-
|
748 |
-
**๊ตฌ์กฐ์ Pruning ๊ณํ**
|
749 |
-
1. Magnitude ๊ธฐ๋ฐ ์ค์๋ ํ๊ฐ
|
750 |
-
2. 50% ์ฑ๋ ์ ๊ฑฐ
|
751 |
-
3. Fine-tuning: 10 ์ํญ
|
752 |
-
4. ์ฑ๋ฅ ๊ฒ์ฆ ๋ฐ ๋ฐ๋ณต
|
753 |
-
|
754 |
-
**INT8 Quantization**
|
755 |
-
- Post-training quantization ์ ์ฉ
|
756 |
-
- Calibration dataset: 1,000 ์ํ
|
757 |
-
- ์์ ์๋ ํฅ์: 4๋ฐฐ
|
758 |
-
|
759 |
-
## ๐ 4๋จ๊ณ: ์ฑ๊ณผ ๊ฒ์ฆ ๋ฐ ํ๋ก๋์
๋ฐฐํฌ (7-8์ฃผ์ฐจ)
|
760 |
-
|
761 |
-
### ์ข
ํฉ ์ฑ๋ฅ ๊ฒ์ฆ
|
762 |
-
|
763 |
-
**์ฑ๋ฅ ์งํ ๋ฌ์ฑ๋ ๊ฒ์ฆ**
|
764 |
-
|
765 |
-
| ํ
์คํธ ํญ๋ชฉ | ๋ฐฉ๋ฒ | ์ฑ๊ณต ๊ธฐ์ค | ๊ฒฐ๊ณผ |
|
766 |
-
|-------------|------|-----------|------|
|
767 |
-
| ์ถ๋ก ์๋ | A/B ํ
์คํธ | <5ms | โ
4.5ms |
|
768 |
-
| ์ ํ๋ | ํ๋์์ ๊ฒ์ฆ | >90% | โ
90.5% |
|
769 |
-
| ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋ | ํ๋กํ์ผ๋ง | <300MB | โ
250MB |
|
770 |
-
| ์ฒ๋ฆฌ๋ | ๋ถํ ํ
์คํธ | >5000 req/s | โ
6000 req/s |
|
771 |
-
|
772 |
-
### ๋จ๊ณ์ ๋ฐฐํฌ ์ ๋ต
|
773 |
-
|
774 |
-
```mermaid
|
775 |
-
graph LR
|
776 |
-
A[1% ํธ๋ํฝ] --> B[10% ํธ๋ํฝ]
|
777 |
-
B --> C[50% ํธ๋ํฝ]
|
778 |
-
C --> D[100% ์ ํ]
|
779 |
-
|
780 |
-
A -->|Day 1-3| B
|
781 |
-
B -->|Day 4-7| C
|
782 |
-
C -->|Day 8-14| D
|
783 |
-
```
|
784 |
-
|
785 |
-
### ๋ชจ๋ํฐ๋ง ๋์๋ณด๋
|
786 |
-
|
787 |
-
**ํต์ฌ ๋ฉํธ๋ฆญ**
|
788 |
-
- ๐ด P99 ์ง์ฐ์๊ฐ: < 10ms
|
789 |
-
- ๐ก ์ค๋ฅ์จ: < 0.1%
|
790 |
-
- ๐ข CPU/GPU ์ฌ์ฉ๋ฅ : < 80%
|
791 |
-
|
792 |
-
## ๐ฐ ROI ๋ถ์
|
793 |
-
|
794 |
-
### ๋น์ฉ-ํจ์ต ๋ถ์
|
795 |
-
|
796 |
-
| ํญ๋ชฉ | ๋น์ฉ/ํจ์ต | ์ธ๋ถ ๋ด์ญ |
|
797 |
-
|------|-----------|-----------|
|
798 |
-
| **์ด๊ธฐ ํฌ์** | $50,000 | ์ธ๊ฑด๋น + ์ธํ๋ผ |
|
799 |
-
| **์๊ฐ ์ ๊ฐ์ก** | $14,000 | ์๋ฒ + GPU ๋น์ฉ |
|
800 |
-
| **ํฌ์ ํ์ ๊ธฐ๊ฐ** | 3.6๊ฐ์ | - |
|
801 |
-
| **1๋
์์ด์ต** | $118,000 | ์ ๊ฐ์ก - ํฌ์๋น |
|
802 |
-
|
803 |
-
### ์ฅ๊ธฐ ํจ๊ณผ
|
804 |
-
- ๐ ํ์ฅ์ฑ 10๋ฐฐ ํฅ์
|
805 |
-
- ๐ก ์ ๊ท ์๋น์ค ์ถ์ ๊ฐ๋ฅ
|
806 |
-
- ๐ ํ์ ๋ฐฐ์ถ 70% ๊ฐ์
|
807 |
-
|
808 |
-
## ๐ ์ง์์ ๊ฐ์ ๊ณํ
|
809 |
-
|
810 |
-
### ์๊ฐ ๋ชจ๋ํฐ๋ง
|
811 |
-
- ์ฑ๋ฅ ์งํ ๋ฆฌ๋ทฐ
|
812 |
-
- ์ฌ์ฉ์ ํผ๋๋ฐฑ ๋ถ์
|
813 |
-
- ๊ธฐ์ ๋ถ์ฑ ๊ด๋ฆฌ
|
814 |
-
|
815 |
-
### ๋ถ๊ธฐ๋ณ ์
๋ฐ์ดํธ
|
816 |
-
- ๋ชจ๋ธ ์ฌํ๋ จ
|
817 |
-
- ์๋ก์ด ์ต์ ํ ๊ธฐ๋ฒ ๋์
|
818 |
-
- ๋ฒค์น๋งํฌ ์
๋ฐ์ดํธ
|
819 |
-
|
820 |
-
### ์ฐจ๊ธฐ ํ๋ก์ ํธ ๋ก๋๋งต
|
821 |
-
|
822 |
-
| ๋ถ๊ธฐ | ํ๋ก์ ํธ | ์์ ํจ๊ณผ |
|
823 |
-
|------|----------|-----------|
|
824 |
-
| Q2 2025 | ์ฃ์ง ๋๋ฐ์ด์ค ๋ฐฐํฌ | ์ง์ฐ์๊ฐ 90% ๊ฐ์ |
|
825 |
-
| Q3 2025 | ์ฐํฉ ํ์ต ๋์
| ํ๋ผ์ด๋ฒ์ ๊ฐํ |
|
826 |
-
| Q4 2025 | AutoML ํ๋ซํผ ๊ตฌ์ถ | ๊ฐ๋ฐ ์๋ 5๋ฐฐ ํฅ์ |
|
827 |
-
|
828 |
-
## ๐ ๊ฒฐ๋ก ๋ฐ ๊ถ๊ณ ์ฌํญ
|
829 |
-
|
830 |
-
### ํต์ฌ ์ฑ๊ณผ
|
831 |
-
- โ
๋ชจ๋ ๋ชฉํ ์งํ ๋ฌ์ฑ
|
832 |
-
- โ
์์ฐ ๋ด ํ๋ก์ ํธ ์๋ฃ
|
833 |
-
- โ
๋ฆฌ์คํฌ ์ฑ๊ณต์ ๊ด๋ฆฌ
|
834 |
-
|
835 |
-
### ํฅํ ๊ถ๊ณ ์ฌํญ
|
836 |
-
1. **์ฆ์ ์คํ**: 1-2๋จ๊ณ ์ฆ์ ์ฐฉ์
|
837 |
-
2. **ํ ๊ตฌ์ฑ**: ML์์ง๋์ด 2๋ช
, DevOps 1๋ช
ํ์
|
838 |
-
3. **์ธํ๋ผ ์ค๋น**: GPU ์๋ฒ ์ฌ์ ํ๋ณด
|
839 |
-
4. **๋ณ๊ฒฝ ๊ด๋ฆฌ**: ์ดํด๊ด๊ณ์ ์ฌ์ ๊ต์ก
|
840 |
-
|
841 |
-
> ๋ณธ ํ๋ก์ ํธ๋ ์ต์ ์ฐ๊ตฌ ๊ฒฐ๊ณผ์ ์
๊ณ ๋ฒ ์คํธ ํ๋ํฐ์ค๋ฅผ ์ ์ฉํ์ฌ, 8์ฃผ ๋ง์ ๋ชจ๋ธ ์ฑ๋ฅ์ ํ๊ธฐ์ ์ผ๋ก ๊ฐ์ ํ๊ณ ์ด์ ๋น์ฉ์ 70% ์ ๊ฐํ๋ ์ฑ๊ณผ๋ฅผ ๋ฌ์ฑํ ๊ฒ์ผ๋ก ํ์ ํฉ๋๋ค.
|
842 |
-
|
843 |
-
---
|
844 |
-
*์์ฑ์ผ: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*
|
845 |
-
*์์ฑ์: ํ๋ ฅ์ AI ์์คํ
(๊ฐ๋
์, ์กฐ์ฌ์, ์คํ์, ํ๊ฐ์ AI)*""",
|
846 |
-
|
847 |
-
"evaluator": """## ๐ ์ ์ฒด ํ๋ ฅ ๊ณผ์ ํ๊ฐ ๋ณด๊ณ ์
|
848 |
-
|
849 |
-
### 1๏ธโฃ ํ์ง ํ๊ฐ (10์ ๋ง์ )
|
850 |
-
|
851 |
-
| AI ์ญํ | ์ ์ | ํ๊ฐ ๋ด์ฉ |
|
852 |
-
|---------|------|-----------|
|
853 |
-
| **๊ฐ๋
์ AI** | 9.5/10 | ๊ฑฐ์์ ๊ด์ ์์ ์ฒด๊ณ์ ์ธ ๋ถ์๊ณผ ๋ฐฉํฅ ์ ์ |
|
854 |
-
| **์กฐ์ฌ์ AI** | 9.0/10 | ์น ๊ฒ์์ ํตํ ์ต์ ์ ๋ณด ์์ง ์ฐ์ |
|
855 |
-
| **์คํ์ AI** | 8.5/10 | ์กฐ์ฌ ๋ด์ฉ์ ์ ํ์ฉํ ๊ตฌ์ฒด์ ๊ณํ ์๋ฆฝ |
|
856 |
-
|
857 |
-
**์์ธ ํ๊ฐ:**
|
858 |
-
- โ
๊ฐ๋
์ AI: ๋จ๊ณ๋ณ ๊ตฌ์ฒด์ ์ธ ์ง์์ฌํญ ์ ๊ณต์ด ํ์ํจ
|
859 |
-
- โ
์กฐ์ฌ์ AI: ์ ๋ขฐ๋ ํ๊ฐ์ ๋ชจ์ ๊ฐ์ง ๊ธฐ๋ฅ์ด ํจ๊ณผ์
|
860 |
-
- โ
์คํ์ AI: ์คํ ๊ฐ๋ฅํ ๋จ๊ณ๋ณ ์ ๊ทผ๋ฒ ์ ์ ์ฐ์
|
861 |
-
|
862 |
-
### 2๏ธโฃ ํ๋ ฅ ํจ๊ณผ์ฑ ํ๊ฐ
|
863 |
-
|
864 |
-
**๊ฐ์ :**
|
865 |
-
- ๐ AI ๊ฐ ์ญํ ๋ถ๋ด์ด ๋ช
ํํ๊ณ ์ํธ๋ณด์์
|
866 |
-
- ๐ ์ ๋ณด ํ๋ฆ์ด ์ฒด๊ณ์ ์ด๊ณ ์ผ๊ด์ฑ ์์
|
867 |
-
- โจ ํผ๋๋ฐฑ ๋ฐ์์ด ํจ๊ณผ์ ์ผ๋ก ์ด๋ฃจ์ด์ง
|
868 |
-
|
869 |
-
**๊ฐ์ ์ :**
|
870 |
-
- โก ์ค์๊ฐ ์ํธ์์ฉ ๋ฉ์ปค๋์ฆ ์ถ๊ฐ ๊ณ ๋ ค
|
871 |
-
- ๐ ์ค๊ฐ ์ ๊ฒ ๋จ๊ณ ๋์
ํ์
|
872 |
-
|
873 |
-
### 3๏ธโฃ ์ ๋ณด ํ์ฉ๋ ํ๊ฐ
|
874 |
-
|
875 |
-
| ํ๊ฐ ํญ๋ชฉ | ๋ฌ์ฑ๋ | ์ธ๋ถ ๋ด์ฉ |
|
876 |
-
|-----------|--------|-----------|
|
877 |
-
| ๊ฒ์ ๋ฒ์ | 95% | 20๊ฐ ์ด์์ ์น ์์ค์์ ์ ๋ณด ์์ง |
|
878 |
-
| ์ ๋ขฐ๋ ํ๊ฐ | 90% | 0.7 ์ด์์ ์ ๋ขฐ๋ ์์ค ์ฐ์ ํ์ฉ |
|
879 |
-
| ์ ๋ณด ํตํฉ | 85% | ๋ค์ํ ๊ด์ ์ ์ ๋ณด๋ฅผ ๊ท ํ์๊ฒ ํตํฉ |
|
880 |
-
|
881 |
-
**์ฐ์ํ ์ :**
|
882 |
-
- โ
์ ๋ขฐ๋ ๊ธฐ๋ฐ ์ ๋ณด ์ ๋ณ ํจ๊ณผ์
|
883 |
-
- โ
์ค์ ๊ธฐ์
์ฌ๋ก ์ ์ ํ ํ์ฉ
|
884 |
-
- โ
์ต์ ํธ๋ ๋ ๋ฐ์ ์ฐ์
|
885 |
-
|
886 |
-
**๋ณด์ ํ์:**
|
887 |
-
- ๐ ํ์ ๋
ผ๋ฌธ ๋ฑ ๋ ๊น์ด ์๋ ์๋ฃ ํ์ฉ
|
888 |
-
- ๐ ์ง์ญ๋ณ/์ฐ์
๋ณ ํน์ฑ ๊ณ ๋ ค ํ์
|
889 |
-
|
890 |
-
### 4๏ธโฃ ํฅํ ๊ฐ์ ๋ฐฉํฅ
|
891 |
-
|
892 |
-
#### 1. **์ค์๊ฐ ํ์
๊ฐํ**
|
893 |
-
- AI ๊ฐ ์ค๊ฐ ์ฒดํฌํฌ์ธํธ ์ถ๊ฐ
|
894 |
-
- ๋์ ์ญํ ์กฐ์ ๋ฉ์ปค๋์ฆ ๋์
|
895 |
-
|
896 |
-
#### 2. **์ ๋ณด ๊ฒ์ฆ ๊ฐํ**
|
897 |
-
- ๊ต์ฐจ ๊ฒ์ฆ ํ๋ก์ธ์ค ์ถ๊ฐ
|
898 |
-
- ์ ๋ฌธ๊ฐ ๊ฒํ ๋จ๊ณ ๊ณ ๋ ค
|
899 |
-
|
900 |
-
#### 3. **๋ง์ถคํ ๊ฐํ**
|
901 |
-
- ์ฌ์ฉ์ ์ปจํ
์คํธ ๋ ๊น์ด ๋ฐ์
|
902 |
-
- ์ฐ์
๋ณ/๊ท๋ชจ๋ณ ๋ง์ถค ์ ๋ต ์ ๊ณต
|
903 |
-
|
904 |
-
### 5๏ธโฃ ์ต์ข
ํ์ : โญโญโญโญโญ **9.0/10**
|
905 |
-
|
906 |
-
> **์ข
ํฉ ํ๊ฐ:**
|
907 |
-
>
|
908 |
-
> ๋ณธ ํ๋ ฅ ์์คํ
์ ๊ฐ AI์ ์ ๋ฌธ์ฑ์ ํจ๊ณผ์ ์ผ๋ก ํ์ฉํ์ฌ ์ฌ์ฉ์ ์ง๋ฌธ์ ๋ํ ์ข
ํฉ์ ์ด๊ณ ์คํ ๊ฐ๋ฅํ ๋ต๋ณ์ ์ ๊ณตํ์ต๋๋ค. ํนํ ์น ๊ฒ์์ ํตํ ์ต์ ์ ๋ณด ํ์ฉ๊ณผ ๋จ๊ณ์ ํผ๋๋ฐฑ ๋ฐ์์ด ์ฐ์ํ์ต๋๋ค.
|
909 |
-
>
|
910 |
-
> ํฅํ ์ค์๊ฐ ํ์
๊ณผ ๋ง์ถคํ๋ฅผ ๋์ฑ ๊ฐํํ๋ค๋ฉด ๋์ฑ ๋ฐ์ด๋ ์ฑ๊ณผ๋ฅผ ๋ฌ์ฑํ ์ ์์ ๊ฒ์
๋๋ค.
|
911 |
-
|
912 |
-
---
|
913 |
-
|
914 |
-
**ํ๊ฐ ์๋ฃ ์๊ฐ**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"""
|
915 |
-
}
|
916 |
-
|
917 |
-
# ํ๋กฌํํธ ๋ด์ฉ์ ๋ฐ๋ผ ์ ์ ํ ์๋ต ์ ํ
|
918 |
-
if role == "supervisor" and "์กฐ์ฌ์ AI๊ฐ ์ ๋ฆฌํ" in messages[0]["content"]:
|
919 |
-
response = test_responses["supervisor_execution"]
|
920 |
-
elif role == "supervisor" and messages[0]["content"].find("์คํ์ AI์ ๋ต๋ณ") > -1:
|
921 |
-
response = test_responses["supervisor_review"]
|
922 |
-
elif role == "supervisor":
|
923 |
-
response = test_responses["supervisor_initial"]
|
924 |
-
elif role == "researcher":
|
925 |
-
response = test_responses["researcher"]
|
926 |
-
elif role == "executor" and "์ต์ข
๋ณด๊ณ ์" in messages[0]["content"]:
|
927 |
-
response = test_responses["executor_final"]
|
928 |
-
elif role == "evaluator":
|
929 |
-
response = test_responses["evaluator"]
|
930 |
-
else:
|
931 |
-
response = test_responses["executor"]
|
932 |
-
|
933 |
-
yield from self.simulate_streaming(response, role)
|
934 |
-
return
|
935 |
-
|
936 |
-
# ์ค์ API ํธ์ถ
|
937 |
-
try:
|
938 |
-
system_prompts = {
|
939 |
-
"supervisor": "๋น์ ์ ๊ฑฐ์์ ๊ด์ ์์ ๋ถ์ํ๊ณ ์ง๋ํ๋ ๊ฐ๋
์ AI์
๋๋ค.",
|
940 |
-
"researcher": "๋น์ ์ ์ ๋ณด๋ฅผ ์กฐ์ฌํ๊ณ ์ฒด๊ณ์ ์ผ๋ก ์ ๋ฆฌํ๋ ์กฐ์ฌ์ AI์
๋๋ค.",
|
941 |
-
"executor": "๋น์ ์ ์ธ๋ถ์ ์ธ ๋ด์ฉ์ ๊ตฌํํ๋ ์คํ์ AI์
๋๋ค.",
|
942 |
-
"evaluator": "๋น์ ์ ์ ์ฒด ํ๋ ฅ ๊ณผ์ ๊ณผ ๊ฒฐ๊ณผ๋ฅผ ํ๊ฐํ๋ ํ๊ฐ์ AI์
๋๋ค."
|
943 |
-
}
|
944 |
-
|
945 |
-
full_messages = [
|
946 |
-
{"role": "system", "content": system_prompts.get(role, "")},
|
947 |
-
*messages
|
948 |
-
]
|
949 |
-
|
950 |
-
payload = {
|
951 |
-
"model": self.model_id,
|
952 |
-
"messages": full_messages,
|
953 |
-
"max_tokens": 4096,
|
954 |
-
"temperature": 0.7,
|
955 |
-
"top_p": 0.8,
|
956 |
-
"stream": True,
|
957 |
-
"stream_options": {"include_usage": True}
|
958 |
-
}
|
959 |
-
|
960 |
-
logger.info(f"API ์คํธ๋ฆฌ๋ฐ ํธ์ถ ์์ - Role: {role}")
|
961 |
-
|
962 |
-
response = requests.post(
|
963 |
-
self.api_url,
|
964 |
-
headers=self.create_headers(),
|
965 |
-
json=payload,
|
966 |
-
stream=True,
|
967 |
-
timeout=10
|
968 |
-
)
|
969 |
-
|
970 |
-
if response.status_code != 200:
|
971 |
-
logger.error(f"API ์ค๋ฅ: {response.status_code}")
|
972 |
-
yield f"โ API ์ค๋ฅ ({response.status_code}): {response.text[:200]}"
|
973 |
-
return
|
974 |
-
|
975 |
-
for line in response.iter_lines():
|
976 |
-
if line:
|
977 |
-
line = line.decode('utf-8')
|
978 |
-
if line.startswith("data: "):
|
979 |
-
data = line[6:]
|
980 |
-
if data == "[DONE]":
|
981 |
-
break
|
982 |
-
try:
|
983 |
-
chunk = json.loads(data)
|
984 |
-
if "choices" in chunk and chunk["choices"]:
|
985 |
-
content = chunk["choices"][0].get("delta", {}).get("content", "")
|
986 |
-
if content:
|
987 |
-
yield content
|
988 |
-
except json.JSONDecodeError:
|
989 |
-
continue
|
990 |
-
|
991 |
-
except requests.exceptions.Timeout:
|
992 |
-
yield "โฑ๏ธ API ํธ์ถ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค. ๋ค์ ์๋ํด์ฃผ์ธ์."
|
993 |
-
except requests.exceptions.ConnectionError:
|
994 |
-
yield "๐ API ์๋ฒ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. ์ธํฐ๋ท ์ฐ๊ฒฐ์ ํ์ธํด์ฃผ์ธ์."
|
995 |
-
except Exception as e:
|
996 |
-
logger.error(f"์คํธ๋ฆฌ๋ฐ ์ค ์ค๋ฅ: {str(e)}")
|
997 |
-
yield f"โ ์ค๋ฅ ๋ฐ์: {str(e)}"
|
998 |
-
|
999 |
-
# ์์คํ
์ธ์คํด์ค ์์ฑ
|
1000 |
-
llm_system = LLMCollaborativeSystem()
|
1001 |
-
|
1002 |
-
# ๋ด๋ถ ํ์คํ ๋ฆฌ ๊ด๋ฆฌ (UI์๋ ํ์ํ์ง ์์)
|
1003 |
-
internal_history = []
|
1004 |
-
|
1005 |
-
def process_query_streaming(user_query: str, llm_mode: str):
|
1006 |
-
"""์คํธ๋ฆฌ๋ฐ์ ์ง์ํ๋ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ"""
|
1007 |
-
global internal_history
|
1008 |
-
|
1009 |
-
if not user_query:
|
1010 |
-
return "", "", "", "", "", "โ ์ง๋ฌธ์ ์
๋ ฅํด์ฃผ์ธ์."
|
1011 |
-
|
1012 |
-
# LLM ๋ชจ๋ ์ค์
|
1013 |
-
llm_system.set_llm_mode(llm_mode)
|
1014 |
-
|
1015 |
-
conversation_log = []
|
1016 |
-
all_responses = {"supervisor": [], "researcher": [], "executor": [], "evaluator": []}
|
1017 |
-
|
1018 |
-
try:
|
1019 |
-
# 1๋จ๊ณ: ๊ฐ๋
์ AI ์ด๊ธฐ ๋ถ์ ๋ฐ ํค์๋ ์ถ์ถ
|
1020 |
-
supervisor_prompt = llm_system.create_supervisor_initial_prompt(user_query)
|
1021 |
-
supervisor_initial_response = ""
|
1022 |
-
|
1023 |
-
supervisor_text = "[์ด๊ธฐ ๋ถ์] ๐ ์์ฑ ์ค...\n"
|
1024 |
-
for chunk in llm_system.call_llm_streaming(
|
1025 |
-
[{"role": "user", "content": supervisor_prompt}],
|
1026 |
-
"supervisor"
|
1027 |
-
):
|
1028 |
-
supervisor_initial_response += chunk
|
1029 |
-
supervisor_text = f"[์ด๊ธฐ ๋ถ์] - {datetime.now().strftime('%H:%M:%S')}\n{supervisor_initial_response}"
|
1030 |
-
yield supervisor_text, "", "", "", "", "๐ ๊ฐ๋
์ AI๊ฐ ๋ถ์ ์ค..."
|
1031 |
-
|
1032 |
-
all_responses["supervisor"].append(supervisor_initial_response)
|
1033 |
-
|
1034 |
-
# ํค์๋ ์ถ์ถ
|
1035 |
-
keywords = llm_system.extract_keywords(supervisor_initial_response)
|
1036 |
-
logger.info(f"์ถ์ถ๋ ํค์๋: {keywords}")
|
1037 |
-
|
1038 |
-
# 2๋จ๊ณ: ๋ธ๋ ์ด๋ธ ๊ฒ์ ์ํ
|
1039 |
-
researcher_text = "[์น ๊ฒ์] ๐ ๊ฒ์ ์ค...\n"
|
1040 |
-
yield supervisor_text, researcher_text, "", "", "", "๐ ์น ๊ฒ์ ์ํ ์ค..."
|
1041 |
-
|
1042 |
-
search_results = {}
|
1043 |
-
total_search_count = 0
|
1044 |
-
|
1045 |
-
# ์๋ ํค์๋๋ก ๊ฒ์
|
1046 |
-
for keyword in keywords:
|
1047 |
-
results = llm_system.brave_search(keyword)
|
1048 |
-
if results:
|
1049 |
-
search_results[keyword] = results
|
1050 |
-
total_search_count += len(results)
|
1051 |
-
researcher_text += f"โ '{keyword}' ๊ฒ์ ์๋ฃ ({len(results)}๊ฐ ๊ฒฐ๊ณผ)\n"
|
1052 |
-
yield supervisor_text, researcher_text, "", "", "", f"๐ '{keyword}' ๊ฒ์ ์ค..."
|
1053 |
-
|
1054 |
-
# ๋์์ด๋ก ์ถ๊ฐ ๊ฒ์
|
1055 |
-
synonyms = llm_system.generate_synonyms(keyword)
|
1056 |
-
for synonym in synonyms:
|
1057 |
-
syn_results = llm_system.brave_search(f"{keyword} {synonym}")
|
1058 |
-
if syn_results:
|
1059 |
-
search_results[f"{keyword} ({synonym})"] = syn_results
|
1060 |
-
total_search_count += len(syn_results)
|
1061 |
-
researcher_text += f"โ ๋์์ด '{synonym}' ๊ฒ์ ์๋ฃ ({len(syn_results)}๊ฐ ๊ฒฐ๊ณผ)\n"
|
1062 |
-
yield supervisor_text, researcher_text, "", "", "", f"๐ ๋์์ด '{synonym}' ๊ฒ์ ์ค..."
|
1063 |
-
|
1064 |
-
researcher_text += f"\n๐ ์ด {total_search_count}๊ฐ์ ๊ฒ์ ๊ฒฐ๊ณผ ์์ง ์๋ฃ\n"
|
1065 |
-
|
1066 |
-
# URL ์ฝํ
์ธ ๊ฐ์ ธ์ค๊ธฐ (์์ 3๊ฐ)
|
1067 |
-
researcher_text += "\n[์ฝํ
์ธ ๋ถ์] ๐ ์ฃผ์ ์นํ์ด์ง ๋ด์ฉ ๋ถ์ ์ค...\n"
|
1068 |
-
yield supervisor_text, researcher_text, "", "", "", "๐ ์นํ์ด์ง ๋ด์ฉ ๋ถ์ ์ค..."
|
1069 |
-
|
1070 |
-
content_analyzed = 0
|
1071 |
-
for keyword, results in search_results.items():
|
1072 |
-
for result in results[:2]: # ๊ฐ ํค์๋๋น ์์ 2๊ฐ๋ง
|
1073 |
-
if content_analyzed >= 5: # ์ด 5๊ฐ๊น์ง๋ง
|
1074 |
-
break
|
1075 |
-
|
1076 |
-
url = result.get('url', '')
|
1077 |
-
if url and result.get('credibility_score', 0) >= 0.7:
|
1078 |
-
content = llm_system.fetch_url_content(url)
|
1079 |
-
if content:
|
1080 |
-
result['content_preview'] = content[:500] # ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์ ์ฅ
|
1081 |
-
content_analyzed += 1
|
1082 |
-
researcher_text += f"โ ์ฝํ
์ธ ๋ถ์ ์๋ฃ: {url[:50]}...\n"
|
1083 |
-
yield supervisor_text, researcher_text, "", "", "", f"๐ ๋ถ์ ์ค: {url[:30]}..."
|
1084 |
-
|
1085 |
-
# 3๋จ๊ณ: ์กฐ์ฌ์ AI๊ฐ ๊ฒ์ ๊ฒฐ๊ณผ ์ ๋ฆฌ
|
1086 |
-
researcher_prompt = llm_system.create_researcher_prompt(user_query, supervisor_initial_response, search_results)
|
1087 |
-
researcher_response = ""
|
1088 |
-
|
1089 |
-
researcher_text = "[์กฐ์ฌ ๊ฒฐ๊ณผ ์ ๋ฆฌ] ๐ ์์ฑ ์ค...\n"
|
1090 |
-
for chunk in llm_system.call_llm_streaming(
|
1091 |
-
[{"role": "user", "content": researcher_prompt}],
|
1092 |
-
"researcher"
|
1093 |
-
):
|
1094 |
-
researcher_response += chunk
|
1095 |
-
researcher_text = f"[์กฐ์ฌ ๊ฒฐ๊ณผ ์ ๋ฆฌ] - {datetime.now().strftime('%H:%M:%S')}\n{researcher_response}"
|
1096 |
-
yield supervisor_text, researcher_text, "", "", "", "๐ ์กฐ์ฌ์ AI๊ฐ ์ ๋ฆฌ ์ค..."
|
1097 |
-
|
1098 |
-
all_responses["researcher"].append(researcher_response)
|
1099 |
-
|
1100 |
-
# 4๋จ๊ณ: ํ๊ฐ์ AI๊ฐ ์กฐ์ฌ ๊ฒฐ๊ณผ ํ๊ฐ
|
1101 |
-
evaluator_research_prompt = f"""๋น์ ์ ์ ์ฒด ํ๋ ฅ ๊ณผ์ ๊ณผ ๊ฒฐ๊ณผ๋ฅผ ํ๊ฐํ๋ ํ๊ฐ์ AI์
๋๋ค.
|
1102 |
-
|
1103 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
1104 |
-
|
1105 |
-
๊ฐ๋
์ AI์ ์ด๊ธฐ ๋ถ์:
|
1106 |
-
{supervisor_initial_response}
|
1107 |
-
|
1108 |
-
์กฐ์ฌ์ AI์ ์กฐ์ฌ ๊ฒฐ๊ณผ:
|
1109 |
-
{researcher_response}
|
1110 |
-
|
1111 |
-
์ ์กฐ์ฌ ๊ฒฐ๊ณผ๋ฅผ ํ๊ฐํ์ฌ:
|
1112 |
-
1. ์กฐ์ฌ์ ์ถฉ์ค๋์ ์ ๋ขฐ์ฑ์ ํ๊ฐํ์ธ์
|
1113 |
-
2. ๋๋ฝ๋ ์ค์ ์ ๋ณด๊ฐ ์๋์ง ํ์ธํ์ธ์
|
1114 |
-
3. ์กฐ์ฌ ๊ฒฐ๊ณผ์ ํ์ฉ ๊ฐ๋ฅ์ฑ์ ํ๊ฐํ์ธ์
|
1115 |
-
4. ๊ฐ์ ์ด ํ์ํ ๋ถ๋ถ์ ๊ตฌ์ฒด์ ์ผ๋ก ์ ์ํ์ธ์"""
|
1116 |
-
|
1117 |
-
evaluator_research_response = ""
|
1118 |
-
evaluator_text = "[์กฐ์ฌ ๊ฒฐ๊ณผ ํ๊ฐ] ๐ ํ๊ฐ ์ค...\n"
|
1119 |
-
|
1120 |
-
for chunk in llm_system.call_llm_streaming(
|
1121 |
-
[{"role": "user", "content": evaluator_research_prompt}],
|
1122 |
-
"evaluator"
|
1123 |
-
):
|
1124 |
-
evaluator_research_response += chunk
|
1125 |
-
evaluator_text = f"[์กฐ์ฌ ๊ฒฐ๊ณผ ํ๊ฐ] - {datetime.now().strftime('%H:%M:%S')}\n{evaluator_research_response}"
|
1126 |
-
yield supervisor_text, researcher_text, "", evaluator_text, "", "๐ ํ๊ฐ์ AI๊ฐ ์กฐ์ฌ ๊ฒฐ๊ณผ ํ๊ฐ ์ค..."
|
1127 |
-
|
1128 |
-
all_responses["evaluator"].append(evaluator_research_response)
|
1129 |
-
|
1130 |
-
# 5๋จ๊ณ: ๊ฐ๋
์ AI๊ฐ ํ๊ฐ๋ฅผ ๋ฐ์ํ ์คํ ์ง์
|
1131 |
-
supervisor_execution_prompt = f"""๋น์ ์ ๊ฑฐ์์ ๊ด์ ์์ ๋ถ์ํ๊ณ ์ง๋ํ๋ ๊ฐ๋
์ AI์
๋๋ค.
|
1132 |
-
|
1133 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
1134 |
-
|
1135 |
-
์กฐ์ฌ์ AI๊ฐ ์ ๋ฆฌํ ์กฐ์ฌ ๋ด์ฉ:
|
1136 |
-
{researcher_response}
|
1137 |
-
|
1138 |
-
ํ๊ฐ์ AI์ ์กฐ์ฌ ๊ฒฐ๊ณผ ํ๊ฐ:
|
1139 |
-
{evaluator_research_response}
|
1140 |
-
|
1141 |
-
์ ์กฐ์ฌ ๋ด์ฉ๊ณผ ํ๊ฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์คํ์ AI์๊ฒ ์์ฃผ ๊ตฌ์ฒด์ ์ธ ์ง์๋ฅผ ๋ด๋ ค์ฃผ์ธ์:
|
1142 |
-
1. ํ๊ฐ์์ ํผ๋๋ฐฑ์ ๋ฐ์ํ์ฌ ์ง์๋ฅผ ๊ฐ์ ํ์ธ์
|
1143 |
-
2. ์กฐ์ฌ๋ ์ ๋ณด๋ฅผ ์ด๋ป๊ฒ ํ์ฉํ ์ง ๋ช
ํํ ์ง์ํ์ธ์
|
1144 |
-
3. ์คํ ๊ฐ๋ฅํ ๋จ๊ณ๋ณ ์์
์ ๊ตฌ์ฒด์ ์ผ๋ก ์ ์ํ์ธ์
|
1145 |
-
4. ์์๋๋ ๊ฒฐ๊ณผ๋ฌผ์ ํํ๋ฅผ ๊ตฌ์ฒด์ ์ผ๋ก ์ค๋ช
ํ์ธ์"""
|
1146 |
-
|
1147 |
-
supervisor_execution_response = ""
|
1148 |
-
|
1149 |
-
supervisor_text += "\n\n---\n\n[์คํ ์ง์] ๐ ์์ฑ ์ค...\n"
|
1150 |
-
for chunk in llm_system.call_llm_streaming(
|
1151 |
-
[{"role": "user", "content": supervisor_execution_prompt}],
|
1152 |
-
"supervisor"
|
1153 |
-
):
|
1154 |
-
supervisor_execution_response += chunk
|
1155 |
-
temp_text = f"{all_responses['supervisor'][0]}\n\n---\n\n[์คํ ์ง์] - {datetime.now().strftime('%H:%M:%S')}\n{supervisor_execution_response}"
|
1156 |
-
supervisor_text = f"[์ด๊ธฐ ๋ถ์] - {datetime.now().strftime('%H:%M:%S')}\n{temp_text}"
|
1157 |
-
yield supervisor_text, researcher_text, "", evaluator_text, "", "๐ฏ ๊ฐ๋
์ AI๊ฐ ์ง์ ์ค..."
|
1158 |
-
|
1159 |
-
all_responses["supervisor"].append(supervisor_execution_response)
|
1160 |
-
|
1161 |
-
# 6๋จ๊ณ: ์คํ์ AI๊ฐ ์กฐ์ฌ ๋ด์ฉ๊ณผ ์ง์๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ด๊ธฐ ๊ตฌํ
|
1162 |
-
executor_prompt = llm_system.create_executor_prompt(user_query, supervisor_execution_response, researcher_response)
|
1163 |
-
executor_response = ""
|
1164 |
-
|
1165 |
-
executor_text = "[์ด๊ธฐ ๊ตฌํ] ๐ ์์ฑ ์ค...\n"
|
1166 |
-
for chunk in llm_system.call_llm_streaming(
|
1167 |
-
[{"role": "user", "content": executor_prompt}],
|
1168 |
-
"executor"
|
1169 |
-
):
|
1170 |
-
executor_response += chunk
|
1171 |
-
executor_text = f"[์ด๊ธฐ ๊ตฌํ] - {datetime.now().strftime('%H:%M:%S')}\n{executor_response}"
|
1172 |
-
yield supervisor_text, researcher_text, executor_text, evaluator_text, "", "๐ง ์คํ์ AI๊ฐ ๊ตฌํ ์ค..."
|
1173 |
-
|
1174 |
-
all_responses["executor"].append(executor_response)
|
1175 |
-
|
1176 |
-
# 7๋จ๊ณ: ํ๊ฐ์ AI๊ฐ ์ด๊ธฐ ๊ตฌํ ํ๊ฐ
|
1177 |
-
evaluator_execution_prompt = f"""๋น์ ์ ์ ์ฒด ํ๋ ฅ ๊ณผ์ ๊ณผ ๊ฒฐ๊ณผ๋ฅผ ํ๊ฐํ๋ ํ๊ฐ์ AI์
๋๋ค.
|
1178 |
-
|
1179 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
1180 |
-
|
1181 |
-
์คํ์ AI์ ์ด๊ธฐ ๊ตฌํ:
|
1182 |
-
{executor_response}
|
1183 |
-
|
1184 |
-
๊ฐ๋
์ AI์ ์ง์์ฌํญ:
|
1185 |
-
{supervisor_execution_response}
|
1186 |
-
|
1187 |
-
์ ์ด๊ธฐ ๊ตฌํ์ ํ๊ฐํ์ฌ:
|
1188 |
-
1. ์ง์์ฌํญ์ด ์ผ๋ง๋ ์ ๋ฐ์๋์๋์ง ํ๊ฐํ์ธ์
|
1189 |
-
2. ๊ตฌํ์ ์คํ ๊ฐ๋ฅ์ฑ๊ณผ ๊ตฌ์ฒด์ฑ์ ํ๊ฐํ์ธ์
|
1190 |
-
3. ๋๋ฝ๋ ์ค์ ์์๊ฐ ์๋์ง ํ์ธํ์ธ์
|
1191 |
-
4. ๊ฐ์ ์ด ํ์ํ ๋ถ๋ถ์ ๊ตฌ์ฒด์ ์ผ๋ก ์ ์ํ์ธ์"""
|
1192 |
-
|
1193 |
-
evaluator_execution_response = ""
|
1194 |
-
evaluator_text += "\n\n---\n\n[์ด๊ธฐ ๊ตฌํ ํ๊ฐ] ๐ ํ๊ฐ ์ค...\n"
|
1195 |
-
|
1196 |
-
for chunk in llm_system.call_llm_streaming(
|
1197 |
-
[{"role": "user", "content": evaluator_execution_prompt}],
|
1198 |
-
"evaluator"
|
1199 |
-
):
|
1200 |
-
evaluator_execution_response += chunk
|
1201 |
-
temp_text = f"{all_responses['evaluator'][0]}\n\n---\n\n[์ด๊ธฐ ๊ตฌํ ํ๊ฐ] - {datetime.now().strftime('%H:%M:%S')}\n{evaluator_execution_response}"
|
1202 |
-
evaluator_text = f"[์กฐ์ฌ ๊ฒฐ๊ณผ ํ๊ฐ] - {datetime.now().strftime('%H:%M:%S')}\n{temp_text}"
|
1203 |
-
yield supervisor_text, researcher_text, executor_text, evaluator_text, "", "๐ ํ๊ฐ์ AI๊ฐ ๊ตฌํ ํ๊ฐ ์ค..."
|
1204 |
-
|
1205 |
-
all_responses["evaluator"].append(evaluator_execution_response)
|
1206 |
-
|
1207 |
-
# 8๋จ๊ณ: ๊ฐ๋
์ AI๊ฐ ํ๊ฐ๋ฅผ ๋ฐ์ํ ๊ฐ์ ์ง์
|
1208 |
-
supervisor_improvement_prompt = f"""๋น์ ์ ๊ฑฐ์์ ๊ด์ ์์ ๋ถ์ํ๊ณ ์ง๋ํ๋ ๊ฐ๋
์ AI์
๋๋ค.
|
1209 |
-
|
1210 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
1211 |
-
|
1212 |
-
์คํ์ AI์ ์ด๊ธฐ ๊ตฌํ:
|
1213 |
-
{executor_response}
|
1214 |
-
|
1215 |
-
ํ๊ฐ์ AI์ ๊ตฌํ ํ๊ฐ:
|
1216 |
-
{evaluator_execution_response}
|
1217 |
-
|
1218 |
-
์ ํ๊ฐ๋ฅผ ๋ฐ์ํ์ฌ ์ต์ข
๋ณด๊ณ ์ ์์ฑ์ ์ํ ๊ฐ์ ์ง์๋ฅผ ๋ด๋ ค์ฃผ์ธ์:
|
1219 |
-
1. ํ๊ฐ์๊ฐ ์ง์ ํ ๋ชจ๋ ๊ฐ์ ์ฌํญ์ ๊ตฌ์ฒด์ ์ผ๋ก ๋ฐ์ํ์ธ์
|
1220 |
-
2. ์ถ๊ฐ๋ก ํ์ํ ๊ตฌ์ฒด์ ์ธ ๋ด์ฉ์ ์ง์ํ์ธ์
|
1221 |
-
3. ์ต์ข
๋ณด๊ณ ์์ ๊ตฌ์กฐ์ ํฌํจํด์ผ ํ ์์๋ฅผ ๋ช
ํํ ์ ์ํ์ธ์"""
|
1222 |
-
|
1223 |
-
supervisor_improvement_response = ""
|
1224 |
-
supervisor_text += "\n\n---\n\n[๊ฐ์ ์ง์] ๐ ์์ฑ ์ค...\n"
|
1225 |
-
|
1226 |
-
for chunk in llm_system.call_llm_streaming(
|
1227 |
-
[{"role": "user", "content": supervisor_improvement_prompt}],
|
1228 |
-
"supervisor"
|
1229 |
-
):
|
1230 |
-
supervisor_improvement_response += chunk
|
1231 |
-
temp_text = f"{all_responses['supervisor'][0]}\n\n---\n\n[์คํ ์ง์] - {datetime.now().strftime('%H:%M:%S')}\n{all_responses['supervisor'][1]}\n\n---\n\n[๊ฐ์ ์ง์] - {datetime.now().strftime('%H:%M:%S')}\n{supervisor_improvement_response}"
|
1232 |
-
supervisor_text = f"[์ด๊ธฐ ๋ถ์] - {datetime.now().strftime('%H:%M:%S')}\n{temp_text}"
|
1233 |
-
yield supervisor_text, researcher_text, executor_text, evaluator_text, "", "๐ ๊ฐ๋
์ AI๊ฐ ๊ฐ์ ์ง์ ์ค..."
|
1234 |
-
|
1235 |
-
all_responses["supervisor"].append(supervisor_improvement_response)
|
1236 |
-
|
1237 |
-
# 9๋จ๊ณ: ํ๊ฐ์ AI๊ฐ ์ ์ฒด ๊ณผ์ ์ต์ข
ํ๊ฐ
|
1238 |
-
evaluator_final_prompt = llm_system.create_evaluator_prompt(
|
1239 |
-
user_query,
|
1240 |
-
all_responses["supervisor"],
|
1241 |
-
all_responses["researcher"][0],
|
1242 |
-
all_responses["executor"],
|
1243 |
-
all_responses["evaluator"] # ์ด์ ํ๊ฐ๋ค๋ ์ ๋ฌ
|
1244 |
-
)
|
1245 |
-
evaluator_final_response = ""
|
1246 |
-
|
1247 |
-
evaluator_text += "\n\n---\n\n[์ ์ฒด ๊ณผ์ ์ต์ข
ํ๊ฐ] ๐ ํ๊ฐ ์ค...\n"
|
1248 |
-
for chunk in llm_system.call_llm_streaming(
|
1249 |
-
[{"role": "user", "content": evaluator_final_prompt}],
|
1250 |
-
"evaluator"
|
1251 |
-
):
|
1252 |
-
evaluator_final_response += chunk
|
1253 |
-
temp_text = f"{all_responses['evaluator'][0]}\n\n---\n\n[์ด๊ธฐ ๊ตฌํ ํ๊ฐ] - {datetime.now().strftime('%H:%M:%S')}\n{all_responses['evaluator'][1]}\n\n---\n\n[์ ์ฒด ๊ณผ์ ์ต์ข
ํ๊ฐ] - {datetime.now().strftime('%H:%M:%S')}\n{evaluator_final_response}"
|
1254 |
-
evaluator_text = f"[์กฐ์ฌ ๊ฒฐ๊ณผ ํ๊ฐ] - {datetime.now().strftime('%H:%M:%S')}\n{temp_text}"
|
1255 |
-
yield supervisor_text, researcher_text, executor_text, evaluator_text, "", "๐ ํ๊ฐ์ AI๊ฐ ์ต์ข
ํ๊ฐ ์ค..."
|
1256 |
-
|
1257 |
-
all_responses["evaluator"].append(evaluator_final_response)
|
1258 |
-
|
1259 |
-
# 10๋จ๊ณ: ์คํ์ AI ์ต์ข
๋ณด๊ณ ์ (๋ชจ๋ ํผ๋๋ฐฑ ๋ฐ์)
|
1260 |
-
final_executor_prompt = f"""๋น์ ์ ์ธ๋ถ์ ์ธ ๋ด์ฉ์ ๊ตฌํํ๋ ์คํ์ AI์
๋๋ค.
|
1261 |
-
|
1262 |
-
์ฌ์ฉ์ ์ง๋ฌธ: {user_query}
|
1263 |
-
|
1264 |
-
์กฐ์ฌ์ AI์ ์กฐ์ฌ ๋ด์ฉ:
|
1265 |
-
{researcher_response}
|
1266 |
-
|
1267 |
-
๋น์ ์ ์ด๊ธฐ ๊ตฌํ:
|
1268 |
-
{executor_response}
|
1269 |
-
|
1270 |
-
๊ฐ๋
์ AI์ ๊ฐ์ ์ง์:
|
1271 |
-
{supervisor_improvement_response}
|
1272 |
-
|
1273 |
-
ํ๊ฐ์ AI์ ์ ์ฒด ํ๊ฐ:
|
1274 |
-
{evaluator_final_response}
|
1275 |
-
|
1276 |
-
์ ๋ชจ๋ ํผ๋๋ฐฑ์ ์์ ํ ๋ฐ์ํ์ฌ ์ต์ข
๋ณด๊ณ ์๋ฅผ ์์ฑํ์ธ์:
|
1277 |
-
1. ๋ชจ๋ ๊ฐ์ ์ฌํญ๊ณผ ์ง์์ฌํญ์ ๋น ์ง์์ด ๋ฐ์ํ์ธ์
|
1278 |
-
2. ์กฐ์ฌ ๋ด์ฉ์ ์ต๋ํ ๊ตฌ์ฒด์ ์ผ๋ก ํ์ฉํ์ธ์
|
1279 |
-
3. ์คํ ๊ฐ๋ฅ์ฑ์ ๋์ด๋ ์ธ๋ถ ๊ณํ์ ํฌํจํ์ธ์
|
1280 |
-
4. ๋ช
ํํ ๊ฒฐ๋ก ๊ณผ ๋ค์ ๋จ๊ณ๋ฅผ ์ ์ํ์ธ์
|
1281 |
-
5. ์ ๋ฌธ์ ์ด๊ณ ์์ฑ๋ ๋์ ์ต์ข
๋ณด๊ณ ์ ํ์์ผ๋ก ์์ฑํ์ธ์
|
1282 |
-
|
1283 |
-
**์ค์: ๋งํฌ๋ค์ด ํ์์ ์ ๊ทน ํ์ฉํ์ธ์**
|
1284 |
-
- ์ ๋ชฉ์ #, ##, ### ์ ์ฌ์ฉํ์ฌ ๊ณ์ธต์ ์ผ๋ก ๊ตฌ์ฑ
|
1285 |
-
- ์ค์ํ ๋ด์ฉ์ **๊ตต๊ฒ** ํ์
|
1286 |
-
- ๋ฆฌ์คํธ๋ -, * ๋๋ 1. 2. 3. ํ์ ์ฌ์ฉ
|
1287 |
-
- ํ๊ฐ ํ์ํ ๊ฒฝ์ฐ ๋งํฌ๋ค์ด ํ ํ์ ์ฌ์ฉ:
|
1288 |
-
| ํญ๋ชฉ | ๋ด์ฉ | ๋น๊ณ |
|
1289 |
-
|------|------|------|
|
1290 |
-
| ์์1 | ์ค๋ช
1 | ์ฐธ๊ณ 1 |
|
1291 |
-
- ์ฝ๋๋ ``` ๋ก ๊ฐ์ธ์ ํ์
|
1292 |
-
- ์ธ์ฉ๊ตฌ๋ > ๋ฅผ ์ฌ์ฉ
|
1293 |
-
- ๊ตฌ๋ถ์ ์ --- ์ฌ์ฉ"""
|
1294 |
-
|
1295 |
-
final_executor_response = ""
|
1296 |
-
|
1297 |
-
executor_text += "\n\n---\n\n[์ต์ข
๋ณด๊ณ ์] ๐ ์์ฑ ์ค...\n"
|
1298 |
-
for chunk in llm_system.call_llm_streaming(
|
1299 |
-
[{"role": "user", "content": final_executor_prompt}],
|
1300 |
-
"executor"
|
1301 |
-
):
|
1302 |
-
final_executor_response += chunk
|
1303 |
-
temp_text = f"[์ด๊ธฐ ๊ตฌํ] - {datetime.now().strftime('%H:%M:%S')}\n{all_responses['executor'][0]}\n\n---\n\n[์ต์ข
๋ณด๊ณ ์] - {datetime.now().strftime('%H:%M:%S')}\n{final_executor_response}"
|
1304 |
-
executor_text = temp_text
|
1305 |
-
yield supervisor_text, researcher_text, executor_text, evaluator_text, "", "๐ ์ต์ข
๋ณด๊ณ ์ ์์ฑ ์ค..."
|
1306 |
-
|
1307 |
-
all_responses["executor"].append(final_executor_response)
|
1308 |
-
|
1309 |
-
# ์ต์ข
๊ฒฐ๊ณผ ์์ฑ (์ต์ข
๋ณด๊ณ ์๋ฅผ ๋ฉ์ธ์ผ๋ก)
|
1310 |
-
final_summary = f"""# ๐ฏ ์ต์ข
์ข
ํฉ ๋ณด๊ณ ์
|
1311 |
-
|
1312 |
-
## ๐ ์ฌ์ฉ์ ์ง๋ฌธ
|
1313 |
-
**{user_query}**
|
1314 |
-
|
1315 |
-
---
|
1316 |
-
|
1317 |
-
## ๐ ์ต์ข
๋ณด๊ณ ์ (์คํ์ AI - ๋ชจ๋ ํผ๋๋ฐฑ ๋ฐ์)
|
1318 |
-
|
1319 |
-
{final_executor_response}
|
1320 |
-
|
1321 |
-
---
|
1322 |
-
|
1323 |
-
## ๐ ์ ์ฒด ํ๋ก์ธ์ค ํ๊ฐ (ํ๊ฐ์ AI)
|
1324 |
-
|
1325 |
-
{evaluator_final_response}
|
1326 |
-
|
1327 |
-
---
|
1328 |
-
|
1329 |
-
## ๐ ํต์ฌ ์กฐ์ฌ ๊ฒฐ๊ณผ ์์ฝ (์กฐ์ฌ์ AI)
|
1330 |
-
|
1331 |
-
{researcher_response[:800]}...
|
1332 |
-
|
1333 |
-
---
|
1334 |
-
|
1335 |
-
## ๐ ํ๋ก์ธ์ค ์๋ฃ
|
1336 |
-
|
1337 |
-
| ํญ๋ชฉ | ๋ด์ฉ |
|
1338 |
-
|------|------|
|
1339 |
-
| **์ฌ์ฉ ๋ชจ๋ธ** | {'Gemini 2.5 Pro' if llm_system.use_gemini else '๊ธฐ๋ณธ LLM'} |
|
1340 |
-
| **ํ๋ก์ธ์ค** | ๊ฐ๋
โ์กฐ์ฌโํ๊ฐโ๊ฐ๋
โ์คํโํ๊ฐโ๊ฐ๋
โํ๊ฐโ์คํ |
|
1341 |
-
| **์ด ๋จ๊ณ** | 9๋จ๊ณ ํ๋ ฅ ์๋ฃ |
|
1342 |
-
| **์์ฑ ์๊ฐ** | {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} |
|
1343 |
-
|
1344 |
-
---
|
1345 |
-
|
1346 |
-
> ๐ก **์ฐธ๊ณ **: ์ด ๋ณด๊ณ ์๋ 4๊ฐ AI์ ํ๋ ฅ์ ํตํด ์์ฑ๋์์ผ๋ฉฐ, ๋ค๋จ๊ณ ํ๊ฐ ํ๋ก์ธ์ค๋ฅผ ๊ฑฐ์ณ ํ์ง์ด ๊ฒ์ฆ๋์์ต๋๋ค."""
|
1347 |
-
|
1348 |
-
# ๋ด๋ถ ํ์คํ ๋ฆฌ ์
๋ฐ์ดํธ (UI์๋ ํ์ํ์ง ์์)
|
1349 |
-
internal_history.append((user_query, final_summary))
|
1350 |
-
|
1351 |
-
yield supervisor_text, researcher_text, executor_text, evaluator_text, final_summary, "โ
์ต์ข
๋ณด๊ณ ์ ์์ฑ!"
|
1352 |
-
|
1353 |
-
except Exception as e:
|
1354 |
-
error_msg = f"โ ์ฒ๋ฆฌ ์ค ์ค๋ฅ: {str(e)}"
|
1355 |
-
yield "", "", "", "", error_msg, error_msg
|
1356 |
-
|
1357 |
-
def clear_all():
|
1358 |
-
"""๋ชจ๋ ๋ด์ฉ ์ด๊ธฐํ"""
|
1359 |
-
global internal_history
|
1360 |
-
internal_history = []
|
1361 |
-
return "", "", "", "", "", "๐ ์ด๊ธฐํ๋์์ต๋๋ค."
|
1362 |
-
|
1363 |
-
# Gradio ์ธํฐํ์ด์ค
|
1364 |
-
css = """
|
1365 |
-
.gradio-container {
|
1366 |
-
font-family: 'Arial', sans-serif;
|
1367 |
-
}
|
1368 |
-
.supervisor-box textarea {
|
1369 |
-
border-left: 4px solid #667eea !important;
|
1370 |
-
padding-left: 10px !important;
|
1371 |
-
background-color: #f8f9ff !important;
|
1372 |
-
}
|
1373 |
-
.researcher-box textarea {
|
1374 |
-
border-left: 4px solid #10b981 !important;
|
1375 |
-
padding-left: 10px !important;
|
1376 |
-
background-color: #f0fdf4 !important;
|
1377 |
-
}
|
1378 |
-
.executor-box textarea {
|
1379 |
-
border-left: 4px solid #764ba2 !important;
|
1380 |
-
padding-left: 10px !important;
|
1381 |
-
background-color: #faf5ff !important;
|
1382 |
-
}
|
1383 |
-
.evaluator-box textarea {
|
1384 |
-
border-left: 4px solid #f59e0b !important;
|
1385 |
-
padding-left: 10px !important;
|
1386 |
-
background-color: #fffbeb !important;
|
1387 |
-
}
|
1388 |
-
.final-report-box {
|
1389 |
-
border: 2px solid #3b82f6 !important;
|
1390 |
-
border-radius: 8px !important;
|
1391 |
-
padding: 16px !important;
|
1392 |
-
background-color: #eff6ff !important;
|
1393 |
-
margin-top: 10px !important;
|
1394 |
-
font-size: 14px !important;
|
1395 |
-
max-height: 700px !important;
|
1396 |
-
overflow-y: auto !important;
|
1397 |
-
line-height: 1.6 !important;
|
1398 |
-
}
|
1399 |
-
.final-report-box h1 {
|
1400 |
-
color: #1e40af !important;
|
1401 |
-
font-size: 24px !important;
|
1402 |
-
margin-bottom: 12px !important;
|
1403 |
-
}
|
1404 |
-
.final-report-box h2 {
|
1405 |
-
color: #2563eb !important;
|
1406 |
-
font-size: 20px !important;
|
1407 |
-
margin-top: 16px !important;
|
1408 |
-
margin-bottom: 10px !important;
|
1409 |
-
}
|
1410 |
-
.final-report-box h3 {
|
1411 |
-
color: #3b82f6 !important;
|
1412 |
-
font-size: 18px !important;
|
1413 |
-
margin-top: 12px !important;
|
1414 |
-
margin-bottom: 8px !important;
|
1415 |
-
}
|
1416 |
-
.final-report-box table {
|
1417 |
-
border-collapse: collapse !important;
|
1418 |
-
width: 100% !important;
|
1419 |
-
margin: 16px 0 !important;
|
1420 |
-
}
|
1421 |
-
.final-report-box th, .final-report-box td {
|
1422 |
-
border: 1px solid #cbd5e1 !important;
|
1423 |
-
padding: 8px 10px !important;
|
1424 |
-
text-align: left !important;
|
1425 |
-
}
|
1426 |
-
.final-report-box th {
|
1427 |
-
background-color: #e0e7ff !important;
|
1428 |
-
font-weight: bold !important;
|
1429 |
-
color: #1e40af !important;
|
1430 |
-
}
|
1431 |
-
.final-report-box tr:nth-child(even) {
|
1432 |
-
background-color: #f8fafc !important;
|
1433 |
-
}
|
1434 |
-
.final-report-box tr:hover {
|
1435 |
-
background-color: #f0f4f8 !important;
|
1436 |
-
}
|
1437 |
-
.final-report-box code {
|
1438 |
-
background-color: #f1f5f9 !important;
|
1439 |
-
padding: 2px 6px !important;
|
1440 |
-
border-radius: 4px !important;
|
1441 |
-
font-family: 'Consolas', 'Monaco', monospace !important;
|
1442 |
-
color: #dc2626 !important;
|
1443 |
-
}
|
1444 |
-
.final-report-box pre {
|
1445 |
-
background-color: #1e293b !important;
|
1446 |
-
color: #e2e8f0 !important;
|
1447 |
-
padding: 12px !important;
|
1448 |
-
border-radius: 6px !important;
|
1449 |
-
overflow-x: auto !important;
|
1450 |
-
margin: 12px 0 !important;
|
1451 |
-
font-size: 13px !important;
|
1452 |
-
}
|
1453 |
-
.final-report-box pre code {
|
1454 |
-
background-color: transparent !important;
|
1455 |
-
color: #e2e8f0 !important;
|
1456 |
-
padding: 0 !important;
|
1457 |
-
}
|
1458 |
-
.final-report-box blockquote {
|
1459 |
-
border-left: 4px solid #3b82f6 !important;
|
1460 |
-
padding-left: 12px !important;
|
1461 |
-
margin-left: 0 !important;
|
1462 |
-
margin: 12px 0 !important;
|
1463 |
-
color: #475569 !important;
|
1464 |
-
font-style: italic !important;
|
1465 |
-
background-color: #f0f9ff !important;
|
1466 |
-
padding: 10px 12px !important;
|
1467 |
-
border-radius: 0 6px 6px 0 !important;
|
1468 |
-
}
|
1469 |
-
.final-report-box ul, .final-report-box ol {
|
1470 |
-
margin-left: 20px !important;
|
1471 |
-
margin-bottom: 12px !important;
|
1472 |
-
}
|
1473 |
-
.final-report-box li {
|
1474 |
-
margin-bottom: 6px !important;
|
1475 |
-
line-height: 1.6 !important;
|
1476 |
-
}
|
1477 |
-
.final-report-box strong {
|
1478 |
-
color: #1e40af !important;
|
1479 |
-
font-weight: 600 !important;
|
1480 |
-
}
|
1481 |
-
.final-report-box em {
|
1482 |
-
color: #3730a3 !important;
|
1483 |
-
}
|
1484 |
-
.final-report-box hr {
|
1485 |
-
border: none !important;
|
1486 |
-
border-top: 2px solid #cbd5e1 !important;
|
1487 |
-
margin: 24px 0 !important;
|
1488 |
-
}
|
1489 |
-
.final-report-box a {
|
1490 |
-
color: #2563eb !important;
|
1491 |
-
text-decoration: underline !important;
|
1492 |
-
}
|
1493 |
-
.final-report-box a:hover {
|
1494 |
-
color: #1d4ed8 !important;
|
1495 |
-
}
|
1496 |
-
"""
|
1497 |
-
|
1498 |
-
with gr.Blocks(title="ํ๋ ฅ์ LLM ์์คํ
- ๋ค๋จ๊ณ ํ๊ฐ", theme=gr.themes.Soft(), css=css) as app:
|
1499 |
-
gr.Markdown(
|
1500 |
-
"""
|
1501 |
-
# ๐ค ํ๋ ฅ์ LLM ์์คํ
(๋ค๋จ๊ณ ํ๊ฐ ํ๋ก์ธ์ค)
|
1502 |
-
|
1503 |
-
### ๐ ํ๋ก์ธ์ค ํ๋ก์ฐ
|
1504 |
-
```
|
1505 |
-
๊ฐ๋
(๋ถ์) โ ์กฐ์ฌ(๊ฒ์) โ ํ๊ฐ(์กฐ์ฌ) โ ๊ฐ๋
(์ง์) โ ์คํ(์ด์)
|
1506 |
-
โ ํ๊ฐ(์ด์) โ ๊ฐ๋
(๊ฐ์ ) โ ํ๊ฐ(์ต์ข
) โ ์คํ(์์ฑ)
|
1507 |
-
```
|
1508 |
-
|
1509 |
-
**4๊ฐ AI์ ํ๋ ฅ์ ํตํ ์ต๊ณ ํ์ง์ ๋ต๋ณ ์์ฑ**
|
1510 |
-
"""
|
1511 |
-
)
|
1512 |
-
|
1513 |
-
# ์
๋ ฅ ์น์
|
1514 |
-
with gr.Row():
|
1515 |
-
with gr.Column():
|
1516 |
-
gr.Markdown("""
|
1517 |
-
## ๐ 4๊ฐ AI์ ํ๋ ฅ ์์คํ
|
1518 |
-
- **๊ฐ๋
์ AI**: ๊ฑฐ์์ ๋ถ์๊ณผ ์ ๋ต ์๋ฆฝ
|
1519 |
-
- **์กฐ์ฌ์ AI**: ์น ๊ฒ์๊ณผ ์ ๋ณด ์์ง/์ ๋ฆฌ
|
1520 |
-
- **์คํ์ AI**: ๊ตฌ์ฒด์ ๊ณํ ์๋ฆฝ๊ณผ ์คํ
|
1521 |
-
- **ํ๊ฐ์ AI**: ์ ์ฒด ๊ณผ์ ํ๊ฐ์ ๊ฐ์ ์ ์ ์
|
1522 |
-
|
1523 |
-
### ๐ ์ฃผ์ ๊ธฐ๋ฅ
|
1524 |
-
- ์ต๋ 4096 ํ ํฐ ์ง์ (๊ธด ์๋ต ๊ฐ๋ฅ)
|
1525 |
-
- 20๊ฐ ๊ฒ์ ๊ฒฐ๊ณผ์ ๋์์ด ๊ฒ์
|
1526 |
-
- ์ ๋ขฐ๋ ๊ธฐ๋ฐ ์ ๋ณด ํ๊ฐ
|
1527 |
-
- ๋ค๋จ๊ณ ํ๊ฐ์ ํผ๋๋ฐฑ ๋ฐ์
|
1528 |
-
|
1529 |
-
### ๐ ํ๋ก์ธ์ค
|
1530 |
-
๊ฐ๋
โ ์กฐ์ฌ โ ํ๊ฐ โ ๊ฐ๋
โ ์คํ โ ํ๊ฐ โ ๊ฐ๋
โ ํ๊ฐ โ ์คํ
|
1531 |
-
""")
|
1532 |
-
|
1533 |
-
# LLM ์ ํ ์ต์
|
1534 |
-
llm_mode = gr.Radio(
|
1535 |
-
choices=["default", "commercial"],
|
1536 |
-
value="default",
|
1537 |
-
label="LLM ๋ชจ๋ ์ ํ",
|
1538 |
-
info="commercial์ ์ ํํ๋ฉด Gemini 2.5 Pro๋ฅผ ์ฌ์ฉํฉ๋๋ค"
|
1539 |
-
)
|
1540 |
-
|
1541 |
-
user_input = gr.Textbox(
|
1542 |
-
label="์ง๋ฌธ ์
๋ ฅ",
|
1543 |
-
placeholder="์: ๊ธฐ๊ณํ์ต ๋ชจ๋ธ์ ์ฑ๋ฅ์ ํฅ์์ํค๋ ๋ฐฉ๋ฒ์?",
|
1544 |
-
lines=3
|
1545 |
-
)
|
1546 |
-
|
1547 |
-
with gr.Row():
|
1548 |
-
submit_btn = gr.Button("๐ ๋ถ์ ์์", variant="primary", scale=2)
|
1549 |
-
clear_btn = gr.Button("๐๏ธ ์ด๊ธฐํ", scale=1)
|
1550 |
-
|
1551 |
-
status_text = gr.Textbox(
|
1552 |
-
label="์ํ",
|
1553 |
-
interactive=False,
|
1554 |
-
value="๋๊ธฐ ์ค...",
|
1555 |
-
max_lines=2
|
1556 |
-
)
|
1557 |
-
|
1558 |
-
# ์ต์ข
๊ฒฐ๊ณผ ์น์
์ถ๊ฐ
|
1559 |
-
with gr.Row():
|
1560 |
-
with gr.Column():
|
1561 |
-
gr.Markdown("### ๐ ์ต์ข
์ข
ํฉ ๋ณด๊ณ ์")
|
1562 |
-
final_report = gr.Markdown(
|
1563 |
-
value="*์ต์ข
๋ณด๊ณ ์๊ฐ ์ฌ๊ธฐ์ ํ์๋ฉ๋๋ค.*",
|
1564 |
-
elem_classes=["final-report-box"]
|
1565 |
-
)
|
1566 |
-
|
1567 |
-
# AI ์ถ๋ ฅ๋ค - 2x2 ๊ทธ๋ฆฌ๋
|
1568 |
-
with gr.Row():
|
1569 |
-
# ์๋จ ํ
|
1570 |
-
with gr.Column():
|
1571 |
-
gr.Markdown("### ๐ง ๊ฐ๋
์ AI (๊ฑฐ์์ ๋ถ์)")
|
1572 |
-
supervisor_output = gr.Textbox(
|
1573 |
-
label="",
|
1574 |
-
lines=12,
|
1575 |
-
max_lines=18,
|
1576 |
-
interactive=False,
|
1577 |
-
elem_classes=["supervisor-box"]
|
1578 |
-
)
|
1579 |
-
|
1580 |
-
with gr.Column():
|
1581 |
-
gr.Markdown("### ๐ ์กฐ์ฌ์ AI (์น ๊ฒ์ & ์ ๋ฆฌ)")
|
1582 |
-
researcher_output = gr.Textbox(
|
1583 |
-
label="",
|
1584 |
-
lines=12,
|
1585 |
-
max_lines=18,
|
1586 |
-
interactive=False,
|
1587 |
-
elem_classes=["researcher-box"]
|
1588 |
-
)
|
1589 |
-
|
1590 |
-
with gr.Row():
|
1591 |
-
# ํ๋จ ํ
|
1592 |
-
with gr.Column():
|
1593 |
-
gr.Markdown("### ๐๏ธ ์คํ์ AI (๋ฏธ์์ ๊ตฌํ)")
|
1594 |
-
executor_output = gr.Textbox(
|
1595 |
-
label="",
|
1596 |
-
lines=12,
|
1597 |
-
max_lines=18,
|
1598 |
-
interactive=False,
|
1599 |
-
elem_classes=["executor-box"]
|
1600 |
-
)
|
1601 |
-
|
1602 |
-
with gr.Column():
|
1603 |
-
gr.Markdown("### ๐ ํ๊ฐ์ AI (์ ์ฒด ํ๊ฐ)")
|
1604 |
-
evaluator_output = gr.Textbox(
|
1605 |
-
label="",
|
1606 |
-
lines=12,
|
1607 |
-
max_lines=18,
|
1608 |
-
interactive=False,
|
1609 |
-
elem_classes=["evaluator-box"]
|
1610 |
-
)
|
1611 |
-
|
1612 |
-
# ์์
|
1613 |
-
gr.Examples(
|
1614 |
-
examples=[
|
1615 |
-
"๊ธฐ๊ณํ์ต ๋ชจ๋ธ์ ์ฑ๋ฅ์ ํฅ์์ํค๋ ์ต์ ๋ฐฉ๋ฒ์?",
|
1616 |
-
"2025๋
ํจ๊ณผ์ ์ธ ํ๋ก์ ํธ ๊ด๋ฆฌ ๋๊ตฌ์ ์ ๋ต์?",
|
1617 |
-
"์ง์ ๊ฐ๋ฅํ ๋น์ฆ๋์ค ๋ชจ๋ธ์ ์ต์ ํธ๋ ๋๋?",
|
1618 |
-
"์ต์ ๋ฐ์ดํฐ ์๊ฐํ ๋๊ตฌ์ ๊ธฐ๋ฒ์?",
|
1619 |
-
"์๊ฒฉ ํ์ ์์ฐ์ฑ์ ๋์ด๋ ๊ฒ์ฆ๋ ๋ฐฉ๋ฒ์?",
|
1620 |
-
"์คํํธ์
์ ์ํ ํจ๊ณผ์ ์ธ ๋ง์ผํ
์ ๋ต์?",
|
1621 |
-
"AI ์ค๋ฆฌ์ ๊ท์ ์ ์ต์ ๋ํฅ์?",
|
1622 |
-
"ํด๋ผ์ฐ๋ ๋ค์ดํฐ๋ธ ์ ํ๋ฆฌ์ผ์ด์
๊ฐ๋ฐ ๋ชจ๋ฒ ์ฌ๋ก๋?"
|
1623 |
-
],
|
1624 |
-
inputs=user_input,
|
1625 |
-
label="๐ก ์์ ์ง๋ฌธ"
|
1626 |
-
)
|
1627 |
-
|
1628 |
-
# ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
1629 |
-
submit_btn.click(
|
1630 |
-
fn=process_query_streaming,
|
1631 |
-
inputs=[user_input, llm_mode],
|
1632 |
-
outputs=[supervisor_output, researcher_output, executor_output, evaluator_output, final_report, status_text]
|
1633 |
-
).then(
|
1634 |
-
fn=lambda: "",
|
1635 |
-
outputs=[user_input]
|
1636 |
-
)
|
1637 |
-
|
1638 |
-
user_input.submit(
|
1639 |
-
fn=process_query_streaming,
|
1640 |
-
inputs=[user_input, llm_mode],
|
1641 |
-
outputs=[supervisor_output, researcher_output, executor_output, evaluator_output, final_report, status_text]
|
1642 |
-
).then(
|
1643 |
-
fn=lambda: "",
|
1644 |
-
outputs=[user_input]
|
1645 |
-
)
|
1646 |
-
|
1647 |
-
clear_btn.click(
|
1648 |
-
fn=clear_all,
|
1649 |
-
outputs=[supervisor_output, researcher_output, executor_output, evaluator_output, final_report, status_text]
|
1650 |
-
)
|
1651 |
-
|
1652 |
-
|
1653 |
-
if __name__ == "__main__":
|
1654 |
-
app.queue() # ์คํธ๋ฆฌ๋ฐ์ ์ํ ํ ํ์ฑํ
|
1655 |
-
app.launch(
|
1656 |
-
server_name="0.0.0.0",
|
1657 |
-
server_port=7860,
|
1658 |
-
share=True,
|
1659 |
-
show_error=True
|
1660 |
-
)
|
1661 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|