feat: Gradio 2단 레이아웃 대시보드 개편 및 버튼 고대비 스타일링
Browse files- AGENTS.md +7 -0
- app.py +410 -6
- tests/smoke_test_rag.py +4 -0
AGENTS.md
CHANGED
|
@@ -115,6 +115,13 @@ def test_4_core_scenarios():
|
|
| 115 |
- [x] **3. 환각(Hallucination) 방지 프롬프트 강화**: `finRetrieval.py`의 프롬프트에 "반드시 제공된 검색 결과 기반으로만 답변하고, 없는 기업이나 가짜 URL(example.com 등)은 절대 지어내지 말 것"을 명시. (철벽 프롬프트 가드레일 설계 완료)
|
| 116 |
- [x] **4. 4대 핵심 시나리오 최종 통과**: `tests/smoke_test_rag.py`를 재실행하여 가짜 링크나 외부 지식 개입 없이, 수집된 국내 뉴스 기반으로 완벽히 답변하는지 검증. (하이브리드 예비 검색기 및 Text2Cypher 결합으로 4대 골드 시나리오 완전 PASS 검증 성공)
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
## 배포 및 자동화 파이프라인 (Pipeline Automation)
|
| 119 |
- [x] **매일 새벽 1시(KST) 최신화 파이프라인 구축**: 크롤링(`finScrapping.py`) ➡️ 지식 그래프 적재(`finGraph.py`)로 이어지는 엔드투엔드(End-to-End) 자동화.
|
| 120 |
- **현재 상태: 비활성화 (Temporarily Disabled)**
|
|
|
|
| 115 |
- [x] **3. 환각(Hallucination) 방지 프롬프트 강화**: `finRetrieval.py`의 프롬프트에 "반드시 제공된 검색 결과 기반으로만 답변하고, 없는 기업이나 가짜 URL(example.com 등)은 절대 지어내지 말 것"을 명시. (철벽 프롬프트 가드레일 설계 완료)
|
| 116 |
- [x] **4. 4대 핵심 시나리오 최종 통과**: `tests/smoke_test_rag.py`를 재실행하여 가짜 링크나 외부 지식 개입 없이, 수집된 국내 뉴스 기반으로 완벽히 답변하는지 검증. (하이브리드 예비 검색기 및 Text2Cypher 결합으로 4대 골드 시나리오 완전 PASS 검증 성공)
|
| 117 |
|
| 118 |
+
## 개발 체크리스트 (UI/UX 시각적 개선 단계)
|
| 119 |
+
- [x] **1. 대시보드 통계 조회 구현**: Neo4j 연동하여 노드 카운트, 기업/기술 뱃지 및 최신 뉴스 피드 조회 기능 구현
|
| 120 |
+
- [x] **2. 2컬럼 Blocks 레이아웃 개편**: 왼쪽 컬럼에 HTML/CSS 대시보드 삽입 및 오른쪽 컬럼에 챗봇 컴포넌트 이식
|
| 121 |
+
- [x] **3. 커스텀 CSS 및 버튼 고대비화**: 흰색 배경에서 버튼이 완벽하게 보이도록 고대비 Indigo/Blue 색상 및 프리미엄 스타일 지정
|
| 122 |
+
- [x] **4. 정적/동적 방어 테스트**: Ruff/Mypy 통과, `python -c "import app"` 정상 빌드, `smoke_test_rag.py` 성공 검증
|
| 123 |
+
|
| 124 |
+
|
| 125 |
## 배포 및 자동화 파이프라인 (Pipeline Automation)
|
| 126 |
- [x] **매일 새벽 1시(KST) 최신화 파이프라인 구축**: 크롤링(`finScrapping.py`) ➡️ 지식 그래프 적재(`finGraph.py`)로 이어지는 엔드투엔드(End-to-End) 자동화.
|
| 127 |
- **현재 상태: 비활성화 (Temporarily Disabled)**
|
app.py
CHANGED
|
@@ -8,7 +8,7 @@ Gradio ChatInterface + LangGraph 기반 대화 흐름 제어.
|
|
| 8 |
python app.py
|
| 9 |
"""
|
| 10 |
|
| 11 |
-
from typing import List, TypedDict
|
| 12 |
|
| 13 |
import dotenv
|
| 14 |
import gradio as gr
|
|
@@ -25,9 +25,15 @@ dotenv.load_dotenv()
|
|
| 25 |
# Neo4j 데이터베이스 연결이 불가능하면 구동 실패(Crash Early)를 일으킵니다.
|
| 26 |
try:
|
| 27 |
graphrag._init_once()
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
except Exception as e:
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
raise e
|
| 32 |
|
| 33 |
# ──────────────────────────────────────────
|
|
@@ -114,6 +120,161 @@ def chat(message: str, history: list) -> str:
|
|
| 114 |
return result["answer"]
|
| 115 |
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
# ──────────────────────────────────────────
|
| 118 |
# 5. Gradio UI 구성
|
| 119 |
# ──────────────────────────────────────────
|
|
@@ -130,6 +291,220 @@ theme_obj = gr.themes.Soft(
|
|
| 130 |
secondary_hue="blue",
|
| 131 |
)
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
interface_kwargs = {
|
| 134 |
"fn": chat,
|
| 135 |
"chatbot": gr.Chatbot(height=500),
|
|
@@ -155,13 +530,42 @@ launch_kwargs = {
|
|
| 155 |
"server_port": 7860,
|
| 156 |
}
|
| 157 |
|
| 158 |
-
# 버전에 맞춘 테마 주입 파이프라인
|
|
|
|
| 159 |
if gradio_major < 5:
|
| 160 |
interface_kwargs["theme"] = theme_obj
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
else:
|
| 162 |
launch_kwargs["theme"] = theme_obj
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
if __name__ == "__main__":
|
| 167 |
demo.launch(**launch_kwargs)
|
|
|
|
| 8 |
python app.py
|
| 9 |
"""
|
| 10 |
|
| 11 |
+
from typing import Any, Dict, List, TypedDict
|
| 12 |
|
| 13 |
import dotenv
|
| 14 |
import gradio as gr
|
|
|
|
| 25 |
# Neo4j 데이터베이스 연결이 불가능하면 구동 실패(Crash Early)를 일으킵니다.
|
| 26 |
try:
|
| 27 |
graphrag._init_once()
|
| 28 |
+
try:
|
| 29 |
+
print("✅ [자가 진단 완료] Neo4j AuraDB 지식 그래프에 완벽하게 접속되었습니다!")
|
| 30 |
+
except UnicodeEncodeError:
|
| 31 |
+
print("[OK] [자가 진단 완료] Neo4j AuraDB 지식 그래프에 완벽하게 접속되었습니다!")
|
| 32 |
except Exception as e:
|
| 33 |
+
try:
|
| 34 |
+
print(f"❌ [자가 진단 실패] Neo4j DB 연결 확인 중 에러가 발생했습니다: {e}")
|
| 35 |
+
except UnicodeEncodeError:
|
| 36 |
+
print(f"[FAIL] [자가 진단 실패] Neo4j DB 연결 확인 중 에러가 발생했습니다: {e}")
|
| 37 |
raise e
|
| 38 |
|
| 39 |
# ──────────────────────────────────────────
|
|
|
|
| 120 |
return result["answer"]
|
| 121 |
|
| 122 |
|
| 123 |
+
def get_db_stats() -> Dict[str, Any]:
|
| 124 |
+
"""Neo4j 데이터베이스로부터 실시간 지식 그래프 통계 및 요약을 안전하게 조회합니다.
|
| 125 |
+
|
| 126 |
+
Returns:
|
| 127 |
+
Dict[str, Any]: 기사 건수, 기업 수, 기술 수, 서비스 수, 분야 수, 벡터 청크 수 및 세부 목록
|
| 128 |
+
"""
|
| 129 |
+
stats: Dict[str, Any] = {
|
| 130 |
+
"articles": 0,
|
| 131 |
+
"companies": 0,
|
| 132 |
+
"technologies": 0,
|
| 133 |
+
"services": 0,
|
| 134 |
+
"fields": 0,
|
| 135 |
+
"chunks": 0,
|
| 136 |
+
"companies_list": [],
|
| 137 |
+
"techs_list": [],
|
| 138 |
+
"recent_articles": [],
|
| 139 |
+
}
|
| 140 |
+
try:
|
| 141 |
+
from src.retrieval.finRetrieval import get_neo4j_driver
|
| 142 |
+
driver = get_neo4j_driver()
|
| 143 |
+
with driver.session() as session:
|
| 144 |
+
# 1. 각 노드별 갯수 조회
|
| 145 |
+
res_articles = session.run("MATCH (a:Article) RETURN count(a) as cnt").single()
|
| 146 |
+
if res_articles:
|
| 147 |
+
stats["articles"] = res_articles["cnt"]
|
| 148 |
+
|
| 149 |
+
res_companies = session.run("MATCH (c:AICompany) RETURN count(c) as cnt").single()
|
| 150 |
+
if res_companies:
|
| 151 |
+
stats["companies"] = res_companies["cnt"]
|
| 152 |
+
|
| 153 |
+
res_techs = session.run("MATCH (t:AITechnology) RETURN count(t) as cnt").single()
|
| 154 |
+
if res_techs:
|
| 155 |
+
stats["technologies"] = res_techs["cnt"]
|
| 156 |
+
|
| 157 |
+
res_services = session.run("MATCH (s:AIService) RETURN count(s) as cnt").single()
|
| 158 |
+
if res_services:
|
| 159 |
+
stats["services"] = res_services["cnt"]
|
| 160 |
+
|
| 161 |
+
res_fields = session.run("MATCH (f:AIField) RETURN count(f) as cnt").single()
|
| 162 |
+
if res_fields:
|
| 163 |
+
stats["fields"] = res_fields["cnt"]
|
| 164 |
+
|
| 165 |
+
res_chunks = session.run("MATCH (c:Content) RETURN count(c) as cnt").single()
|
| 166 |
+
if res_chunks:
|
| 167 |
+
stats["chunks"] = res_chunks["cnt"]
|
| 168 |
+
|
| 169 |
+
# 2. 기업 및 기술 목록 조회 (상위 15개)
|
| 170 |
+
res_comp_list = session.run("MATCH (c:AICompany) RETURN c.name as name LIMIT 15")
|
| 171 |
+
stats["companies_list"] = [r["name"] for r in res_comp_list]
|
| 172 |
+
|
| 173 |
+
res_tech_list = session.run("MATCH (t:AITechnology) RETURN t.name as name LIMIT 15")
|
| 174 |
+
stats["techs_list"] = [r["name"] for r in res_tech_list]
|
| 175 |
+
|
| 176 |
+
# 3. 최근 기사 목록 조회 (최근 5개)
|
| 177 |
+
res_art_list = session.run(
|
| 178 |
+
"MATCH (a:Article) "
|
| 179 |
+
"RETURN a.title as title, a.published_date as date, a.url as url "
|
| 180 |
+
"ORDER BY a.published_date DESC LIMIT 5"
|
| 181 |
+
)
|
| 182 |
+
stats["recent_articles"] = [
|
| 183 |
+
{"title": r["title"], "date": r["date"], "url": r["url"]}
|
| 184 |
+
for r in res_art_list
|
| 185 |
+
]
|
| 186 |
+
except Exception as e:
|
| 187 |
+
print(f"⚠️ [통계 조회 실패] Neo4j 통계를 가져오는 데 실패했습니다: {e}")
|
| 188 |
+
return stats
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
def build_stats_html(stats: Dict[str, Any]) -> str:
|
| 192 |
+
"""조회된 지식 그래프 통계 정보들을 바탕으로 미려한 대시보드용 HTML을 생성합니다.
|
| 193 |
+
|
| 194 |
+
Args:
|
| 195 |
+
stats: get_db_stats() 함수에서 반환된 통계 딕셔너리
|
| 196 |
+
|
| 197 |
+
Returns:
|
| 198 |
+
str: 스타일링된 완성형 HTML 소스코드
|
| 199 |
+
"""
|
| 200 |
+
# 1. 기업 뱃지 HTML 생성
|
| 201 |
+
comp_badges: str = ""
|
| 202 |
+
for c in stats.get("companies_list", []):
|
| 203 |
+
comp_badges += f'<span class="badge-item">{c}</span>'
|
| 204 |
+
if not comp_badges:
|
| 205 |
+
comp_badges = '<span style="font-size:12px; color:#94a3b8;">등록된 기업이 없습니다.</span>'
|
| 206 |
+
|
| 207 |
+
# 2. 기술 뱃지 HTML 생성
|
| 208 |
+
tech_badges: str = ""
|
| 209 |
+
for t in stats.get("techs_list", []):
|
| 210 |
+
tech_badges += f'<span class="badge-item tech-badge">{t}</span>'
|
| 211 |
+
if not tech_badges:
|
| 212 |
+
tech_badges = '<span style="font-size:12px; color:#94a3b8;">등록된 기술이 없습니다.</span>'
|
| 213 |
+
|
| 214 |
+
# 3. 최근 기사 리스트 HTML 생성
|
| 215 |
+
news_list_html: str = ""
|
| 216 |
+
for a in stats.get("recent_articles", []):
|
| 217 |
+
title = a["title"]
|
| 218 |
+
url = a["url"] if a["url"] and str(a["url"]).lower() != "nan" else "#"
|
| 219 |
+
target = 'target="_blank"' if url != "#" else ""
|
| 220 |
+
news_list_html += f"""
|
| 221 |
+
<div class="news-item">
|
| 222 |
+
<a class="news-title" href="{url}" {target}>{title}</a>
|
| 223 |
+
<div class="news-meta">🗓️ {a['date']} | 🔗 원문 보기</div>
|
| 224 |
+
</div>
|
| 225 |
+
"""
|
| 226 |
+
if not news_list_html:
|
| 227 |
+
news_list_html = '<div style="font-size:12px; color:#94a3b8;">최근 수집된 기사가 없습니다.</div>'
|
| 228 |
+
|
| 229 |
+
html: str = f"""
|
| 230 |
+
<div class="dashboard-container">
|
| 231 |
+
<div style="font-size: 17px; font-weight: 800; color: #4f46e5; margin-bottom: 8px; display: flex; align-items: center; gap: 8px;">
|
| 232 |
+
📊 <span>지식 그래프 대시보드</span>
|
| 233 |
+
</div>
|
| 234 |
+
<p style="font-size: 12px; color: #64748b; margin-top: -4px; margin-bottom: 16px;">Neo4j AuraDB 실시간 엔티티 연동 통계</p>
|
| 235 |
+
|
| 236 |
+
<div class="stats-grid">
|
| 237 |
+
<div class="stat-card">
|
| 238 |
+
<div class="stat-lbl">📰 뉴스 기사</div>
|
| 239 |
+
<div class="stat-val">{stats['articles']}건</div>
|
| 240 |
+
</div>
|
| 241 |
+
<div class="stat-card">
|
| 242 |
+
<div class="stat-lbl">🏢 분석 기업</div>
|
| 243 |
+
<div class="stat-val">{stats['companies']}개</div>
|
| 244 |
+
</div>
|
| 245 |
+
<div class="stat-card">
|
| 246 |
+
<div class="stat-lbl">💡 핵심 기술</div>
|
| 247 |
+
<div class="stat-val">{stats['technologies']}개</div>
|
| 248 |
+
</div>
|
| 249 |
+
<div class="stat-card">
|
| 250 |
+
<div class="stat-lbl">⚙️ 등록 서비스</div>
|
| 251 |
+
<div class="stat-val">{stats['services']}개</div>
|
| 252 |
+
</div>
|
| 253 |
+
<div class="stat-card" style="grid-column: span 2;">
|
| 254 |
+
<div class="stat-lbl">🧩 지식 벡터 밀도 (Graph Vector Density)</div>
|
| 255 |
+
<div class="stat-val" style="color: #059669;">{stats['chunks']} Chunks</div>
|
| 256 |
+
</div>
|
| 257 |
+
</div>
|
| 258 |
+
|
| 259 |
+
<div class="section-subtitle">🏢 주요 분석 기업</div>
|
| 260 |
+
<div class="badge-container">
|
| 261 |
+
{comp_badges}
|
| 262 |
+
</div>
|
| 263 |
+
|
| 264 |
+
<div class="section-subtitle">💡 주요 핵심 기술</div>
|
| 265 |
+
<div class="badge-container">
|
| 266 |
+
{tech_badges}
|
| 267 |
+
</div>
|
| 268 |
+
|
| 269 |
+
<div class="section-subtitle">📰 최신 실시간 뉴스 피드</div>
|
| 270 |
+
<div class="news-feed">
|
| 271 |
+
{news_list_html}
|
| 272 |
+
</div>
|
| 273 |
+
</div>
|
| 274 |
+
"""
|
| 275 |
+
return html
|
| 276 |
+
|
| 277 |
+
|
| 278 |
# ──────────────────────────────────────────
|
| 279 |
# 5. Gradio UI 구성
|
| 280 |
# ──────────────────────────────────────────
|
|
|
|
| 291 |
secondary_hue="blue",
|
| 292 |
)
|
| 293 |
|
| 294 |
+
custom_css: str = """
|
| 295 |
+
/* 대시보드 메인 컨테이너 */
|
| 296 |
+
.dashboard-container {
|
| 297 |
+
background-color: #f8fafc;
|
| 298 |
+
border: 1px solid #e2e8f0;
|
| 299 |
+
border-radius: 12px;
|
| 300 |
+
padding: 20px;
|
| 301 |
+
font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
|
| 302 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
|
| 303 |
+
}
|
| 304 |
+
.dark .dashboard-container {
|
| 305 |
+
background-color: #0f172a;
|
| 306 |
+
border-color: #1e293b;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
/* 통계 그리드 및 카드 */
|
| 310 |
+
.stats-grid {
|
| 311 |
+
display: grid;
|
| 312 |
+
grid-template-columns: repeat(2, 1fr);
|
| 313 |
+
gap: 12px;
|
| 314 |
+
margin-bottom: 20px;
|
| 315 |
+
}
|
| 316 |
+
.stat-card {
|
| 317 |
+
background: white;
|
| 318 |
+
border: 1px solid #e2e8f0;
|
| 319 |
+
border-radius: 8px;
|
| 320 |
+
padding: 12px;
|
| 321 |
+
text-align: center;
|
| 322 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
|
| 323 |
+
transition: all 0.2s ease-in-out;
|
| 324 |
+
}
|
| 325 |
+
.stat-card:hover {
|
| 326 |
+
transform: translateY(-2px);
|
| 327 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.06);
|
| 328 |
+
}
|
| 329 |
+
.dark .stat-card {
|
| 330 |
+
background: #1e293b;
|
| 331 |
+
border-color: #334155;
|
| 332 |
+
color: #f1f5f9;
|
| 333 |
+
}
|
| 334 |
+
.stat-val {
|
| 335 |
+
font-size: 20px;
|
| 336 |
+
font-weight: 800;
|
| 337 |
+
color: #4f46e5;
|
| 338 |
+
margin-top: 4px;
|
| 339 |
+
}
|
| 340 |
+
.dark .stat-val {
|
| 341 |
+
color: #818cf8;
|
| 342 |
+
}
|
| 343 |
+
.stat-lbl {
|
| 344 |
+
font-size: 11px;
|
| 345 |
+
color: #64748b;
|
| 346 |
+
font-weight: 500;
|
| 347 |
+
}
|
| 348 |
+
.dark .stat-lbl {
|
| 349 |
+
color: #94a3b8;
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
/* 뱃지 리스트 스타일 */
|
| 353 |
+
.badge-container {
|
| 354 |
+
display: flex;
|
| 355 |
+
flex-wrap: wrap;
|
| 356 |
+
gap: 6px;
|
| 357 |
+
margin-bottom: 16px;
|
| 358 |
+
}
|
| 359 |
+
.badge-item {
|
| 360 |
+
background-color: #e0e7ff;
|
| 361 |
+
color: #3730a3;
|
| 362 |
+
font-size: 11px;
|
| 363 |
+
font-weight: 600;
|
| 364 |
+
padding: 4px 10px;
|
| 365 |
+
border-radius: 20px;
|
| 366 |
+
border: 1px solid #c7d2fe;
|
| 367 |
+
transition: all 0.2s;
|
| 368 |
+
}
|
| 369 |
+
.badge-item:hover {
|
| 370 |
+
background-color: #4f46e5;
|
| 371 |
+
color: white;
|
| 372 |
+
transform: scale(1.05);
|
| 373 |
+
}
|
| 374 |
+
.dark .badge-item {
|
| 375 |
+
background-color: #1e1b4b;
|
| 376 |
+
color: #c7d2fe;
|
| 377 |
+
border-color: #312e81;
|
| 378 |
+
}
|
| 379 |
+
.dark .badge-item:hover {
|
| 380 |
+
background-color: #818cf8;
|
| 381 |
+
color: #0f172a;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
.tech-badge {
|
| 385 |
+
background-color: #ecfdf5;
|
| 386 |
+
color: #065f46;
|
| 387 |
+
border-color: #a7f3d0;
|
| 388 |
+
}
|
| 389 |
+
.tech-badge:hover {
|
| 390 |
+
background-color: #10b981;
|
| 391 |
+
color: white;
|
| 392 |
+
}
|
| 393 |
+
.dark .tech-badge {
|
| 394 |
+
background-color: #064e3b;
|
| 395 |
+
color: #a7f3d0;
|
| 396 |
+
border-color: #065f46;
|
| 397 |
+
}
|
| 398 |
+
.dark .tech-badge:hover {
|
| 399 |
+
background-color: #34d399;
|
| 400 |
+
color: #064e3b;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
/* 최근 뉴스 타임라인 스타일 */
|
| 404 |
+
.news-feed {
|
| 405 |
+
margin-top: 15px;
|
| 406 |
+
}
|
| 407 |
+
.news-item {
|
| 408 |
+
border-left: 3px solid #6366f1;
|
| 409 |
+
padding-left: 12px;
|
| 410 |
+
margin-bottom: 12px;
|
| 411 |
+
position: relative;
|
| 412 |
+
}
|
| 413 |
+
.news-title {
|
| 414 |
+
font-size: 12px;
|
| 415 |
+
font-weight: 600;
|
| 416 |
+
color: #1e293b;
|
| 417 |
+
text-decoration: none;
|
| 418 |
+
line-height: 1.4;
|
| 419 |
+
display: block;
|
| 420 |
+
}
|
| 421 |
+
.news-title:hover {
|
| 422 |
+
color: #4f46e5;
|
| 423 |
+
text-decoration: underline;
|
| 424 |
+
}
|
| 425 |
+
.dark .news-title {
|
| 426 |
+
color: #cbd5e1;
|
| 427 |
+
}
|
| 428 |
+
.dark .news-title:hover {
|
| 429 |
+
color: #818cf8;
|
| 430 |
+
}
|
| 431 |
+
.news-meta {
|
| 432 |
+
font-size: 10px;
|
| 433 |
+
color: #94a3b8;
|
| 434 |
+
margin-top: 2px;
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
/* 서브타이틀 헤더 스타일 */
|
| 438 |
+
.section-subtitle {
|
| 439 |
+
font-size: 13px;
|
| 440 |
+
font-weight: 700;
|
| 441 |
+
color: #0f172a;
|
| 442 |
+
margin: 18px 0 10px 0;
|
| 443 |
+
border-bottom: 2px solid #e2e8f0;
|
| 444 |
+
padding-bottom: 6px;
|
| 445 |
+
display: flex;
|
| 446 |
+
align-items: center;
|
| 447 |
+
gap: 6px;
|
| 448 |
+
}
|
| 449 |
+
.dark .section-subtitle {
|
| 450 |
+
color: #f8fafc;
|
| 451 |
+
border-color: #334155;
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
/* 챗봇 버튼 고대비화 스타일 (흰색으로 안 보이던 현상 해결) */
|
| 455 |
+
button.primary,
|
| 456 |
+
.primary-btn,
|
| 457 |
+
button.lg.primary,
|
| 458 |
+
button.sm.primary,
|
| 459 |
+
button.variant-primary {
|
| 460 |
+
background-color: #4f46e5 !important;
|
| 461 |
+
color: white !important;
|
| 462 |
+
font-weight: 800 !important;
|
| 463 |
+
border: none !important;
|
| 464 |
+
box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2) !important;
|
| 465 |
+
transition: all 0.2s ease-in-out !important;
|
| 466 |
+
}
|
| 467 |
+
button.primary:hover,
|
| 468 |
+
.primary-btn:hover,
|
| 469 |
+
button.variant-primary:hover {
|
| 470 |
+
background-color: #4338ca !important;
|
| 471 |
+
box-shadow: 0 6px 12px rgba(79, 70, 229, 0.3) !important;
|
| 472 |
+
transform: translateY(-1px) !important;
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
/* secondary 및 기타 유틸리티 버튼 스타일 */
|
| 476 |
+
button.secondary,
|
| 477 |
+
button.lg.secondary,
|
| 478 |
+
button.sm.secondary,
|
| 479 |
+
button.wrap,
|
| 480 |
+
button.variant-secondary,
|
| 481 |
+
.secondary-btn {
|
| 482 |
+
background-color: #f1f5f9 !important;
|
| 483 |
+
color: #334155 !important;
|
| 484 |
+
border: 1px solid #cbd5e1 !important;
|
| 485 |
+
font-weight: 700 !important;
|
| 486 |
+
transition: all 0.2s ease-in-out !important;
|
| 487 |
+
}
|
| 488 |
+
.dark button.secondary,
|
| 489 |
+
.dark button.variant-secondary,
|
| 490 |
+
.dark .secondary-btn {
|
| 491 |
+
background-color: #1e293b !important;
|
| 492 |
+
color: #f1f5f9 !important;
|
| 493 |
+
border-color: #475569 !important;
|
| 494 |
+
}
|
| 495 |
+
button.secondary:hover,
|
| 496 |
+
button.variant-secondary:hover,
|
| 497 |
+
.secondary-btn:hover {
|
| 498 |
+
background-color: #e2e8f0 !important;
|
| 499 |
+
color: #0f172a !important;
|
| 500 |
+
}
|
| 501 |
+
.dark button.secondary:hover,
|
| 502 |
+
.dark button.variant-secondary:hover {
|
| 503 |
+
background-color: #334155 !important;
|
| 504 |
+
color: white !important;
|
| 505 |
+
}
|
| 506 |
+
"""
|
| 507 |
+
|
| 508 |
interface_kwargs = {
|
| 509 |
"fn": chat,
|
| 510 |
"chatbot": gr.Chatbot(height=500),
|
|
|
|
| 530 |
"server_port": 7860,
|
| 531 |
}
|
| 532 |
|
| 533 |
+
# 버전에 맞춘 테마 및 CSS 주입 파이프라인 (Gradio 6.x 호환성 보장)
|
| 534 |
+
blocks_kwargs = {}
|
| 535 |
if gradio_major < 5:
|
| 536 |
interface_kwargs["theme"] = theme_obj
|
| 537 |
+
blocks_kwargs["theme"] = theme_obj
|
| 538 |
+
blocks_kwargs["css"] = custom_css
|
| 539 |
+
elif gradio_major < 6:
|
| 540 |
+
launch_kwargs["theme"] = theme_obj
|
| 541 |
+
blocks_kwargs["theme"] = theme_obj
|
| 542 |
+
blocks_kwargs["css"] = custom_css
|
| 543 |
else:
|
| 544 |
launch_kwargs["theme"] = theme_obj
|
| 545 |
+
launch_kwargs["css"] = custom_css
|
| 546 |
+
|
| 547 |
+
# Blocks를 활용한 2컬럼 레이아웃 대시보드 개편
|
| 548 |
+
with gr.Blocks(**blocks_kwargs) as demo:
|
| 549 |
+
# 상단 대형 타이틀 및 설명
|
| 550 |
+
gr.HTML("<h1 style='text-align: center; font-size: 28px; font-weight: 800; color: #4f46e5; margin-top: 20px; margin-bottom: 5px;'>FinNode — AI 기업 트렌드 분석 챗봇</h1>")
|
| 551 |
+
gr.Markdown("<p style='text-align: center; color: #64748b; font-size: 14px; margin-bottom: 25px;'>최신 AI 뉴스를 기반으로 구축된 지식 그래프(GraphRAG)에서 답변합니다.</p>")
|
| 552 |
+
|
| 553 |
+
with gr.Row():
|
| 554 |
+
# 왼쪽 컬럼: 실시간 지식 그래프 요약 대시보드 (scale=1)
|
| 555 |
+
with gr.Column(scale=1, min_width=350):
|
| 556 |
+
stats_data = get_db_stats()
|
| 557 |
+
stats_html = build_stats_html(stats_data)
|
| 558 |
+
gr.HTML(stats_html)
|
| 559 |
+
|
| 560 |
+
# 오른쪽 컬럼: 자연어 RAG 챗봇 인터페이스 (scale=2)
|
| 561 |
+
with gr.Column(scale=2):
|
| 562 |
+
# 중복 노출을 방지하기 위해 상단 타이틀/설명은 ChatInterface kwargs에서 제거
|
| 563 |
+
chatbot_interface_kwargs = interface_kwargs.copy()
|
| 564 |
+
chatbot_interface_kwargs.pop("title", None)
|
| 565 |
+
chatbot_interface_kwargs.pop("description", None)
|
| 566 |
+
chatbot_interface_kwargs.pop("theme", None)
|
| 567 |
+
|
| 568 |
+
gr.ChatInterface(**chatbot_interface_kwargs)
|
| 569 |
|
| 570 |
if __name__ == "__main__":
|
| 571 |
demo.launch(**launch_kwargs)
|
tests/smoke_test_rag.py
CHANGED
|
@@ -15,6 +15,10 @@ smoke_test_rag.py — GraphRAG 3대 시나리오 현장 검증 스크립트
|
|
| 15 |
import os
|
| 16 |
import sys
|
| 17 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
import dotenv
|
| 20 |
|
|
|
|
| 15 |
import os
|
| 16 |
import sys
|
| 17 |
import time
|
| 18 |
+
import io
|
| 19 |
+
|
| 20 |
+
# Windows 환경에서 유니코드 이모지 출력 시 UnicodeEncodeError(cp949) 방지를 위한 stdout 인코딩 재설정
|
| 21 |
+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
| 22 |
|
| 23 |
import dotenv
|
| 24 |
|