From e2c2dca27873194576f44cb576506beb2e59bee6 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Tue, 17 Nov 2026 15:56:56 +0900 Subject: [PATCH] feat(ui): relocate CSV dropzone to settings tab and display active AI model name - Moved CsvDropZone from decision log stream to TradeConfigPanel under Schedule & Filters tab - Added universe stock pool card displaying current loaded stock count - Added active AI engine & model card showing main LLM and embedding models - Exposed RagService.getDisplayModelName() to dynamically resolve Ollama or local GGUF models - Display active model badge on the GlobalStatusBar for instant visibility - Verified with compileKotlin and full project build --- src/main/kotlin/network/RagService.kt | 16 ++- src/main/kotlin/ui/TradingDecisionLog.kt | 43 ++++--- src/main/kotlin/ui/panel/TradeConfigPanel.kt | 117 +++++++++++++++++++ 3 files changed, 161 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/network/RagService.kt b/src/main/kotlin/network/RagService.kt index 54d1111..1a37f47 100644 --- a/src/main/kotlin/network/RagService.kt +++ b/src/main/kotlin/network/RagService.kt @@ -364,7 +364,7 @@ object RagService { * 실행 환경에 맞는 모델 식별자를 반환합니다. * Ollama 구동 시 /api/tags에서 가용 모델을 자동 감지하고, 내장 llama-server 구동 시 로컬 모델명을 사용합니다. */ - private fun resolveActiveModelName(): String { + fun resolveActiveModelName(): String { if (!LlamaServerManager.isOllamaActive) { return "local-model" } @@ -388,6 +388,20 @@ object RagService { } } + /** + * UI 표시용 활성 LLM 모델명을 반환합니다. + */ + fun getDisplayModelName(): String { + return if (LlamaServerManager.isOllamaActive) { + "[Ollama] ${resolveActiveModelName()}" + } else if (KisSession.config.modelPath.isNotBlank()) { + val fileName = java.io.File(KisSession.config.modelPath).name + "[내장] $fileName" + } else { + "미설정" + } + } + private suspend fun callLlamaWithSchema(prompt: String): String { val jsonMediaType = "application/json; charset=utf-8".toMediaType() val activeModel = resolveActiveModelName() diff --git a/src/main/kotlin/ui/TradingDecisionLog.kt b/src/main/kotlin/ui/TradingDecisionLog.kt index 94a0a26..ee2d1d1 100644 --- a/src/main/kotlin/ui/TradingDecisionLog.kt +++ b/src/main/kotlin/ui/TradingDecisionLog.kt @@ -29,6 +29,7 @@ import kotlinx.coroutines.launch import model.KisSession import network.KisTradeService import network.NewsService +import network.RagService import service.AutoTradingManager import ui.component.CsvDropZone import ui.component.FilterChipWithRightClick @@ -104,7 +105,8 @@ fun TradingDecisionLog() { llmNews = llmNews, tradeToken = tradeToken, webSocketConnect = webSocketConnect, - maxBudget = KisSession.config.MAX_BUDGET + maxBudget = KisSession.config.MAX_BUDGET, + activeModelName = RagService.getDisplayModelName() ) Divider(color = Color(0xFFE2E8F0), thickness = 1.dp) @@ -282,17 +284,6 @@ fun TradingDecisionLog() { } } - Spacer(modifier = Modifier.height(6.dp)) - - // CSV 유니버스 로더 드롭존 - CsvDropZone( - onUniverseUpdated = { updatedList -> - AutoTradingManager.loadedTops.clear() - AutoTradingManager.loadedTops.addAll(updatedList) - AutoTradingManager.loadedTops.shuffle() - } - ) - Spacer(modifier = Modifier.height(6.dp)) Divider(color = Color(0xFFF1F5F9)) Spacer(modifier = Modifier.height(4.dp)) @@ -369,7 +360,8 @@ private fun GlobalStatusBar( llmNews: Boolean, tradeToken: Boolean, webSocketConnect: Boolean, - maxBudget: Double + maxBudget: Double, + activeModelName: String ) { val marketStatus = remember { getMarketStatus() } val formattedMaxBudget = remember(maxBudget) { @@ -414,7 +406,7 @@ private fun GlobalStatusBar( ) } - // 중앙 실시간 4대 엔진 인디케이터 배지 + // 중앙 실시간 4대 엔진 인디케이터 배지 및 활성 모델 Row( horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.CenterVertically @@ -423,6 +415,29 @@ private fun GlobalStatusBar( ModernStatusBadge("뉴스 처리기", llmNews) ModernStatusBadge("한투 인증서", tradeToken) ModernStatusBadge("실시간 감시", webSocketConnect) + + // 활성 AI 모델 뱃지 + Surface( + shape = RoundedCornerShape(12.dp), + color = Color(0xFFF1F5F9), + border = BorderStroke(1.dp, Color(0xFFCBD5E1)) + ) { + Row( + modifier = Modifier.padding(horizontal = 8.dp, vertical = 3.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(4.dp) + ) { + Text("🤖", fontSize = 10.sp) + Text( + activeModelName, + fontSize = 11.sp, + fontWeight = FontWeight.SemiBold, + color = Color(0xFF1E293B), + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) + } + } } // 우측 장 상태 및 1종목 한도 요약 diff --git a/src/main/kotlin/ui/panel/TradeConfigPanel.kt b/src/main/kotlin/ui/panel/TradeConfigPanel.kt index 8118894..b6f37df 100644 --- a/src/main/kotlin/ui/panel/TradeConfigPanel.kt +++ b/src/main/kotlin/ui/panel/TradeConfigPanel.kt @@ -18,6 +18,9 @@ import androidx.compose.ui.unit.sp import model.ConfigIndex import model.KisSession import model.TradeConfig +import network.RagService +import service.AutoTradingManager +import ui.component.CsvDropZone import ui.component.SettingInputField import ui.component.SettingSwitchField import ui.component.TimeInputRow @@ -695,5 +698,119 @@ private fun ScheduleFilterTabContent(tradeConfig: TradeConfig) { } } } + + // [카드 4] 매매 유니버스 종목 풀 (CSV 드래그 & 드롭) + Card( + modifier = Modifier.fillMaxWidth(), + elevation = 1.dp, + shape = RoundedCornerShape(8.dp), + border = BorderStroke(1.dp, Color(0xFFE2E8F0)) + ) { + Column(modifier = Modifier.padding(12.dp)) { + Row( + modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically + ) { + Text( + "📂 매매 유니버스 종목 풀 (CSV 업로드)", + fontSize = 12.sp, + fontWeight = FontWeight.Bold, + color = Color(0xFF1E293B) + ) + Surface( + shape = RoundedCornerShape(6.dp), + color = Color(0xFFEEF2FF), + border = BorderStroke(1.dp, Color(0xFFC7D2FE)) + ) { + Text( + "현재 ${AutoTradingManager.loadedTops.size}개 종목 로드됨", + fontSize = 10.sp, + fontWeight = FontWeight.Bold, + color = Color(0xFF4F46E5), + modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp) + ) + } + } + + CsvDropZone( + onUniverseUpdated = { updatedList -> + AutoTradingManager.loadedTops.clear() + AutoTradingManager.loadedTops.addAll(updatedList) + AutoTradingManager.loadedTops.shuffle() + } + ) + } + } + + // [카드 5] AI 분석 엔진 및 모델 상태 + Card( + modifier = Modifier.fillMaxWidth(), + elevation = 1.dp, + shape = RoundedCornerShape(8.dp), + border = BorderStroke(1.dp, Color(0xFFE2E8F0)) + ) { + Column(modifier = Modifier.padding(12.dp)) { + Text( + "🤖 AI 분석 엔진 및 모델 현황", + fontSize = 12.sp, + fontWeight = FontWeight.Bold, + color = Color(0xFF1E293B), + modifier = Modifier.padding(bottom = 8.dp) + ) + + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(8.dp) + ) { + // 주식 분석 모델 카드 + Surface( + modifier = Modifier.weight(1f), + shape = RoundedCornerShape(6.dp), + color = Color(0xFFF8FAFC), + border = BorderStroke(1.dp, Color(0xFFE2E8F0)) + ) { + Column(modifier = Modifier.padding(8.dp)) { + Text("주식 분석 LLM 모델", fontSize = 10.sp, color = Color(0xFF64748B)) + Spacer(Modifier.height(2.dp)) + Text( + RagService.getDisplayModelName(), + fontSize = 11.sp, + fontWeight = FontWeight.Bold, + color = Color(0xFF0F172A), + maxLines = 1, + overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis + ) + } + } + + // 뉴스 임베딩 모델 카드 + Surface( + modifier = Modifier.weight(1f), + shape = RoundedCornerShape(6.dp), + color = Color(0xFFF8FAFC), + border = BorderStroke(1.dp, Color(0xFFE2E8F0)) + ) { + Column(modifier = Modifier.padding(8.dp)) { + Text("뉴스/공시 RAG 임베딩", fontSize = 10.sp, color = Color(0xFF64748B)) + Spacer(Modifier.height(2.dp)) + val embedName = if (KisSession.config.embedModelPath.isNotBlank()) { + java.io.File(KisSession.config.embedModelPath).name + } else { + "bge-m3 (내장 임베딩)" + } + Text( + embedName, + fontSize = 11.sp, + fontWeight = FontWeight.Bold, + color = Color(0xFF0F172A), + maxLines = 1, + overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis + ) + } + } + } + } + } } }