feat(rag): support hybrid Ollama/local embedding routing with Lucene DB maintenance
- Added automatic Ollama embedding model discovery in LlamaServerManager (bge, nomic, embed, minilm) - Implemented dynamic routing in RagService for embeddings (Ollama 11434 vs local llama-server 8081) - Added embedding model consistency check with embed_model.tag to prevent Lucene vector dimension mismatches - Added Lucene store maintenance functions: getLuceneStats, resetLuceneStore, and automatic 50MB retention cleanup - Added real-time Lucene status display and one-click '벡터 DB 초기화' button to TradeConfigPanel - Verified with compileKotlin and full project build
This commit is contained in:
@@ -52,18 +52,43 @@ import java.util.concurrent.TimeUnit
|
|||||||
object RagService {
|
object RagService {
|
||||||
val isSafetyBeltStockCodes = ConcurrentHashMap.newKeySet<String>()
|
val isSafetyBeltStockCodes = ConcurrentHashMap.newKeySet<String>()
|
||||||
|
|
||||||
// (매일 아침 8시 30분 시스템 초기화 시 호출해주어야 함)
|
// (매일 아침 8시 30분 시스템 초기화 시 호출)
|
||||||
fun clearDailyCache() {
|
fun clearDailyCache() {
|
||||||
isSafetyBeltStockCodes.clear()
|
isSafetyBeltStockCodes.clear()
|
||||||
println("🧹 [System] 일일 재무 미달 캐시 초기화 완료")
|
checkAndCleanOldIndices(50L) // 50MB 초과 시 오래된 인덱스 자동 정리
|
||||||
|
println("🧹 [System] 일일 재무 미달 캐시 및 루씬 DB 상태 점검 완료")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 임베딩 모델은 포트 할당 완료 후 지연 초기화되도록 by lazy 적용
|
@Volatile
|
||||||
private val embeddingModel by lazy {
|
private var _embeddingModel: dev.langchain4j.model.embedding.EmbeddingModel? = null
|
||||||
OpenAiEmbeddingModel.builder()
|
|
||||||
.baseUrl("http://127.0.0.1:${EMBEDDING_PORT}/v1")
|
// 임베딩 모델: Ollama 임베딩 활성 시 Ollama(11434)로, 아니면 내장 llama-server(8081)로 자동 분기
|
||||||
.apiKey("unused")
|
val currentEmbeddingModel: dev.langchain4j.model.embedding.EmbeddingModel
|
||||||
.build()
|
get() {
|
||||||
|
_embeddingModel?.let { return it }
|
||||||
|
return synchronized(this) {
|
||||||
|
_embeddingModel ?: run {
|
||||||
|
val port = LlamaServerManager.activeEmbeddingPort
|
||||||
|
val modelName = if (LlamaServerManager.isOllamaEmbeddingActive) {
|
||||||
|
LlamaServerManager.ollamaEmbeddingModel.ifBlank { "bge-m3:latest" }
|
||||||
|
} else {
|
||||||
|
"local-model"
|
||||||
|
}
|
||||||
|
val model = OpenAiEmbeddingModel.builder()
|
||||||
|
.baseUrl("http://127.0.0.1:$port/v1")
|
||||||
|
.modelName(modelName)
|
||||||
|
.apiKey("unused")
|
||||||
|
.timeout(Duration.ofSeconds(30))
|
||||||
|
.build()
|
||||||
|
_embeddingModel = model
|
||||||
|
println("🤖 [RagService] 임베딩 모델 바인딩 완료 (Port: $port, Model: $modelName)")
|
||||||
|
model
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun invalidateEmbeddingModel() {
|
||||||
|
_embeddingModel = null
|
||||||
}
|
}
|
||||||
|
|
||||||
// 채팅 모델은 LlamaServerManager의 활성 포트(Ollama 11434 또는 기존 LLM_PORT)를 지연 바인딩
|
// 채팅 모델은 LlamaServerManager의 활성 포트(Ollama 11434 또는 기존 LLM_PORT)를 지연 바인딩
|
||||||
@@ -78,18 +103,30 @@ object RagService {
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val embeddingStore: LuceneEmbeddingStore by lazy {
|
@Volatile
|
||||||
val path = Paths.get("db/lucene_idx")
|
private var _embeddingStore: LuceneEmbeddingStore? = null
|
||||||
val directory = MMapDirectory(path)
|
|
||||||
|
|
||||||
LuceneEmbeddingStore.builder()
|
val currentEmbeddingStore: LuceneEmbeddingStore
|
||||||
.directory(directory)
|
get() {
|
||||||
.build()
|
_embeddingStore?.let { return it }
|
||||||
}
|
return synchronized(this) {
|
||||||
|
_embeddingStore ?: run {
|
||||||
|
val path = Paths.get("db/lucene_idx")
|
||||||
|
java.nio.file.Files.createDirectories(path)
|
||||||
|
checkEmbeddingModelConsistency()
|
||||||
|
val directory = MMapDirectory(path)
|
||||||
|
val store = LuceneEmbeddingStore.builder()
|
||||||
|
.directory(directory)
|
||||||
|
.build()
|
||||||
|
_embeddingStore = store
|
||||||
|
store
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun active() {
|
fun active() {
|
||||||
if (UrlCacheManager.isInitialized()) return
|
if (UrlCacheManager.isInitialized()) return
|
||||||
UrlCacheManager.initialize(embeddingStore, embeddingModel)
|
UrlCacheManager.initialize(currentEmbeddingStore, currentEmbeddingModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,8 +177,8 @@ object RagService {
|
|||||||
metadata.put("stockCode", stockCode)
|
metadata.put("stockCode", stockCode)
|
||||||
|
|
||||||
val segment = TextSegment.from(chunk, metadata)
|
val segment = TextSegment.from(chunk, metadata)
|
||||||
val embedding = embeddingModel.embed(segment).content()
|
val embedding = currentEmbeddingModel.embed(segment).content()
|
||||||
embeddingStore.add(embedding, segment)
|
currentEmbeddingStore.add(embedding, segment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,10 +302,10 @@ object RagService {
|
|||||||
checkAndFetchRecentNews(stockName, stockCode)
|
checkAndFetchRecentNews(stockName, stockCode)
|
||||||
|
|
||||||
val question = "$stockName 실적 및 향후 전망"
|
val question = "$stockName 실적 및 향후 전망"
|
||||||
val questionEmbedding = embeddingModel.embed(question).content()
|
val questionEmbedding = currentEmbeddingModel.embed(question).content()
|
||||||
var finalSearchResult: EmbeddingSearchResult<TextSegment>? = null
|
var finalSearchResult: EmbeddingSearchResult<TextSegment>? = null
|
||||||
try {
|
try {
|
||||||
finalSearchResult = embeddingStore.search(
|
finalSearchResult = currentEmbeddingStore.search(
|
||||||
EmbeddingSearchRequest.builder()
|
EmbeddingSearchRequest.builder()
|
||||||
.queryEmbedding(questionEmbedding)
|
.queryEmbedding(questionEmbedding)
|
||||||
.filter(MetadataFilterBuilder.metadataKey("stockCode").isEqualTo(stockCode))
|
.filter(MetadataFilterBuilder.metadataKey("stockCode").isEqualTo(stockCode))
|
||||||
@@ -304,11 +341,11 @@ object RagService {
|
|||||||
|
|
||||||
private suspend fun checkAndFetchRecentNews(stockName: String, stockCode: String) {
|
private suspend fun checkAndFetchRecentNews(stockName: String, stockCode: String) {
|
||||||
val question = "$stockName 실적 전망 및 최근 이슈"
|
val question = "$stockName 실적 전망 및 최근 이슈"
|
||||||
val questionEmbedding = embeddingModel.embed(question).content()
|
val questionEmbedding = currentEmbeddingModel.embed(question).content()
|
||||||
|
|
||||||
var searchResult: EmbeddingSearchResult<TextSegment>? = null
|
var searchResult: EmbeddingSearchResult<TextSegment>? = null
|
||||||
try {
|
try {
|
||||||
searchResult = embeddingStore.search(
|
searchResult = currentEmbeddingStore.search(
|
||||||
EmbeddingSearchRequest.builder()
|
EmbeddingSearchRequest.builder()
|
||||||
.queryEmbedding(questionEmbedding)
|
.queryEmbedding(questionEmbedding)
|
||||||
.filter(MetadataFilterBuilder.metadataKey("stockCode").isEqualTo(stockCode))
|
.filter(MetadataFilterBuilder.metadataKey("stockCode").isEqualTo(stockCode))
|
||||||
@@ -350,7 +387,7 @@ object RagService {
|
|||||||
.maxResults(1)
|
.maxResults(1)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val result = embeddingStore.search(searchRequest)
|
val result = currentEmbeddingStore.search(searchRequest)
|
||||||
return result.matches().isNotEmpty()
|
return result.matches().isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,6 +439,145 @@ object RagService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI 표시용 활성 RAG 임베딩 모델명을 반환합니다.
|
||||||
|
*/
|
||||||
|
fun getDisplayEmbeddingModelName(): String {
|
||||||
|
return if (LlamaServerManager.isOllamaEmbeddingActive) {
|
||||||
|
"[Ollama] ${LlamaServerManager.ollamaEmbeddingModel}"
|
||||||
|
} else if (KisSession.config.embedModelPath.isNotBlank()) {
|
||||||
|
val fileName = java.io.File(KisSession.config.embedModelPath).name
|
||||||
|
"[내장] $fileName"
|
||||||
|
} else {
|
||||||
|
"[내장] bge-m3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 루씬 벡터 DB 통계 조회 (색인 기사 수, 디스크 파일 크기)
|
||||||
|
*/
|
||||||
|
fun getLuceneStats(): Pair<Int, String> {
|
||||||
|
val count = service.UrlCacheManager.getProcessedCount()
|
||||||
|
val idxPath = Paths.get("db/lucene_idx")
|
||||||
|
val sizeBytes = if (java.nio.file.Files.exists(idxPath)) {
|
||||||
|
try {
|
||||||
|
java.nio.file.Files.walk(idxPath)
|
||||||
|
.filter { java.nio.file.Files.isRegularFile(it) }
|
||||||
|
.mapToLong { java.nio.file.Files.size(it) }
|
||||||
|
.sum()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
0L
|
||||||
|
}
|
||||||
|
} else 0L
|
||||||
|
|
||||||
|
val formattedSize = when {
|
||||||
|
sizeBytes >= 1024 * 1024 -> String.format(Locale.KOREA, "%.1f MB", sizeBytes / (1024.0 * 1024.0))
|
||||||
|
sizeBytes >= 1024 -> String.format(Locale.KOREA, "%.1f KB", sizeBytes / 1024.0)
|
||||||
|
else -> "$sizeBytes B"
|
||||||
|
}
|
||||||
|
return count to formattedSize
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 루씬 벡터 DB 완전 초기화 (메모리 캐시 및 디스크 인덱스 삭제 후 재생성)
|
||||||
|
*/
|
||||||
|
fun resetLuceneStore(): Boolean {
|
||||||
|
return try {
|
||||||
|
synchronized(this) {
|
||||||
|
_embeddingStore = null
|
||||||
|
service.UrlCacheManager.clear()
|
||||||
|
val idxPath = Paths.get("db/lucene_idx")
|
||||||
|
if (java.nio.file.Files.exists(idxPath)) {
|
||||||
|
java.nio.file.Files.walk(idxPath)
|
||||||
|
.sorted(Comparator.reverseOrder())
|
||||||
|
.forEach { path ->
|
||||||
|
try {
|
||||||
|
if (path != idxPath) {
|
||||||
|
java.nio.file.Files.deleteIfExists(path)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// 잠긴 파일 예외 처리
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
java.nio.file.Files.createDirectories(idxPath)
|
||||||
|
recordCurrentEmbeddingTag()
|
||||||
|
val directory = MMapDirectory(idxPath)
|
||||||
|
val newStore = LuceneEmbeddingStore.builder().directory(directory).build()
|
||||||
|
_embeddingStore = newStore
|
||||||
|
println("🧹 [RagService] 루씬 벡터 DB 완전 초기화 성공")
|
||||||
|
true
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("❌ [RagService] 루씬 초기화 실패: ${e.message}")
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 현재 사용 중인 임베딩 모델 식별자 (올라마 vs 내장)
|
||||||
|
*/
|
||||||
|
private fun getCurrentEmbeddingTag(): String {
|
||||||
|
return if (LlamaServerManager.isOllamaEmbeddingActive) {
|
||||||
|
"ollama:${LlamaServerManager.ollamaEmbeddingModel}"
|
||||||
|
} else if (KisSession.config.embedModelPath.isNotBlank()) {
|
||||||
|
"local:${java.io.File(KisSession.config.embedModelPath).name}"
|
||||||
|
} else {
|
||||||
|
"local:default"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 임베딩 모델 변경 감지 (차원 불일치 방지 및 자동 리셋)
|
||||||
|
*/
|
||||||
|
private fun checkEmbeddingModelConsistency() {
|
||||||
|
try {
|
||||||
|
val tagFile = Paths.get("db/lucene_idx/embed_model.tag")
|
||||||
|
val currentTag = getCurrentEmbeddingTag()
|
||||||
|
if (java.nio.file.Files.exists(tagFile)) {
|
||||||
|
val savedTag = java.nio.file.Files.readString(tagFile).trim()
|
||||||
|
if (savedTag.isNotBlank() && savedTag != currentTag) {
|
||||||
|
println("🔄 [RagService] 임베딩 모델 변경 감지 ($savedTag -> $currentTag). 벡터 차원 불일치 방지를 위해 루씬 인덱스를 재색인합니다.")
|
||||||
|
resetLuceneStore()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
recordCurrentEmbeddingTag()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// 무시
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun recordCurrentEmbeddingTag() {
|
||||||
|
try {
|
||||||
|
val tagFile = Paths.get("db/lucene_idx/embed_model.tag")
|
||||||
|
java.nio.file.Files.writeString(tagFile, getCurrentEmbeddingTag())
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// 무시
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일정 크기(기본 50MB) 초과 시 루씬 인덱스 자동 정리
|
||||||
|
*/
|
||||||
|
fun checkAndCleanOldIndices(maxMegabytes: Long = 50L) {
|
||||||
|
val (count, sizeStr) = getLuceneStats()
|
||||||
|
val idxPath = Paths.get("db/lucene_idx")
|
||||||
|
val sizeBytes = if (java.nio.file.Files.exists(idxPath)) {
|
||||||
|
try {
|
||||||
|
java.nio.file.Files.walk(idxPath)
|
||||||
|
.filter { java.nio.file.Files.isRegularFile(it) }
|
||||||
|
.mapToLong { java.nio.file.Files.size(it) }
|
||||||
|
.sum()
|
||||||
|
} catch (e: Exception) { 0L }
|
||||||
|
} else 0L
|
||||||
|
|
||||||
|
if (sizeBytes > maxMegabytes * 1024 * 1024) {
|
||||||
|
println("🧹 [RagService] 루씬 DB 용량($sizeStr)이 임계치(${maxMegabytes}MB)를 초과하여 자동 정리합니다.")
|
||||||
|
resetLuceneStore()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun callLlamaWithSchema(prompt: String): String {
|
private suspend fun callLlamaWithSchema(prompt: String): String {
|
||||||
val jsonMediaType = "application/json; charset=utf-8".toMediaType()
|
val jsonMediaType = "application/json; charset=utf-8".toMediaType()
|
||||||
val activeModel = resolveActiveModelName()
|
val activeModel = resolveActiveModelName()
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.jsonArray
|
||||||
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
import network.RagService
|
import network.RagService
|
||||||
import ui.store.TradingLogStore
|
import ui.store.TradingLogStore
|
||||||
import util.HardwareDetector
|
import util.HardwareDetector
|
||||||
@@ -28,9 +32,20 @@ object LlamaServerManager {
|
|||||||
var isOllamaActive: Boolean = false
|
var isOllamaActive: Boolean = false
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
var isOllamaEmbeddingActive: Boolean = false
|
||||||
|
private set
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
var ollamaEmbeddingModel: String = ""
|
||||||
|
private set
|
||||||
|
|
||||||
val activeLlmPort: Int
|
val activeLlmPort: Int
|
||||||
get() = if (isOllamaActive) 11434 else LLM_PORT
|
get() = if (isOllamaActive) 11434 else LLM_PORT
|
||||||
|
|
||||||
|
val activeEmbeddingPort: Int
|
||||||
|
get() = if (isOllamaEmbeddingActive) 11434 else EMBEDDING_PORT
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Runtime.getRuntime().addShutdownHook(Thread {
|
Runtime.getRuntime().addShutdownHook(Thread {
|
||||||
stopAll()
|
stopAll()
|
||||||
@@ -54,6 +69,40 @@ object LlamaServerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ollama에 설치된 임베딩 전용 모델을 자동 탐색 (bge, embed, nomic, minilm 키워드 매칭)
|
||||||
|
fun findOllamaEmbeddingModel(ollamaPort: Int = 11434): String? {
|
||||||
|
return try {
|
||||||
|
val url = URL("http://127.0.0.1:$ollamaPort/api/tags")
|
||||||
|
val conn = (url.openConnection() as HttpURLConnection).apply {
|
||||||
|
requestMethod = "GET"
|
||||||
|
connectTimeout = 1000
|
||||||
|
readTimeout = 1000
|
||||||
|
}
|
||||||
|
val responseText = conn.inputStream.bufferedReader().readText()
|
||||||
|
conn.disconnect()
|
||||||
|
val json = Json.parseToJsonElement(responseText).jsonObject
|
||||||
|
val models = json["models"]?.jsonArray ?: return null
|
||||||
|
|
||||||
|
// 1순위: bge 계열 (다국어/한국어 고성능 bge-m3 등)
|
||||||
|
val bgeModel = models.firstOrNull { model ->
|
||||||
|
val name = model.jsonObject["name"]?.jsonPrimitive?.content?.lowercase() ?: ""
|
||||||
|
name.contains("bge")
|
||||||
|
}?.jsonObject?.get("name")?.jsonPrimitive?.content
|
||||||
|
|
||||||
|
if (bgeModel != null) return bgeModel
|
||||||
|
|
||||||
|
// 2순위: 기타 임베딩 모델 (embed, nomic, minilm)
|
||||||
|
val embedModel = models.firstOrNull { model ->
|
||||||
|
val name = model.jsonObject["name"]?.jsonPrimitive?.content?.lowercase() ?: ""
|
||||||
|
name.contains("embed") || name.contains("nomic") || name.contains("minilm")
|
||||||
|
}?.jsonObject?.get("name")?.jsonPrimitive?.content
|
||||||
|
|
||||||
|
embedModel
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 특정 포트를 점유하고 있는 프로세스만 선별적으로 종료 (다른 사용자의 llama-server 프로세스 보호)
|
// 특정 포트를 점유하고 있는 프로세스만 선별적으로 종료 (다른 사용자의 llama-server 프로세스 보호)
|
||||||
fun killProcessOnPort(port: Int) {
|
fun killProcessOnPort(port: Int) {
|
||||||
try {
|
try {
|
||||||
@@ -118,6 +167,26 @@ object LlamaServerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 임베딩 서버 기동 요청 시 외부 Ollama(11434)에 임베딩 모델이 있다면 공유 모드로 우회
|
||||||
|
if (port == EMBEDDING_PORT) {
|
||||||
|
if (checkOllamaRunning(11434)) {
|
||||||
|
val embedModel = findOllamaEmbeddingModel(11434)
|
||||||
|
if (embedModel != null) {
|
||||||
|
isOllamaEmbeddingActive = true
|
||||||
|
ollamaEmbeddingModel = embedModel
|
||||||
|
println("🔗 [System] 로컬 Ollama(11434) 임베딩 모델($embedModel) 감지 -> 내장 임베딩 서버 대신 Ollama를 공유합니다.")
|
||||||
|
AutoTradingManager.llmNews = true
|
||||||
|
RagService.active()
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
isOllamaEmbeddingActive = false
|
||||||
|
println("ℹ️ [System] Ollama에 임베딩 모델(bge/nomic/embed 등) 미보유 -> 내장 llama-server(Port: $port)를 기동합니다.")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isOllamaEmbeddingActive = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val os = System.getProperty("os.name").lowercase()
|
val os = System.getProperty("os.name").lowercase()
|
||||||
val arch = System.getProperty("os.arch").lowercase()
|
val arch = System.getProperty("os.arch").lowercase()
|
||||||
val isWin = os.contains("win")
|
val isWin = os.contains("win")
|
||||||
|
|||||||
@@ -52,4 +52,17 @@ object UrlCacheManager {
|
|||||||
fun addToCache(url: String) {
|
fun addToCache(url: String) {
|
||||||
processedUrls.add(url)
|
processedUrls.add(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 현재 캐시된 URL 수
|
||||||
|
*/
|
||||||
|
fun getProcessedCount(): Int = processedUrls.size
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 캐시 완전 초기화
|
||||||
|
*/
|
||||||
|
fun clear() {
|
||||||
|
processedUrls.clear()
|
||||||
|
println("🧹 [UrlCacheManager] URL 캐시 초기화 완료")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -750,14 +750,27 @@ private fun ScheduleFilterTabContent(tradeConfig: TradeConfig) {
|
|||||||
shape = RoundedCornerShape(8.dp),
|
shape = RoundedCornerShape(8.dp),
|
||||||
border = BorderStroke(1.dp, Color(0xFFE2E8F0))
|
border = BorderStroke(1.dp, Color(0xFFE2E8F0))
|
||||||
) {
|
) {
|
||||||
|
var luceneStats by remember { mutableStateOf(RagService.getLuceneStats()) }
|
||||||
|
|
||||||
Column(modifier = Modifier.padding(12.dp)) {
|
Column(modifier = Modifier.padding(12.dp)) {
|
||||||
Text(
|
Row(
|
||||||
"🤖 AI 분석 엔진 및 모델 현황",
|
modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp),
|
||||||
fontSize = 12.sp,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
fontWeight = FontWeight.Bold,
|
verticalAlignment = Alignment.CenterVertically
|
||||||
color = Color(0xFF1E293B),
|
) {
|
||||||
modifier = Modifier.padding(bottom = 8.dp)
|
Text(
|
||||||
)
|
"🤖 AI 분석 엔진 및 모델 현황",
|
||||||
|
fontSize = 12.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color(0xFF1E293B)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
"하이브리드 자동 분기 활성화",
|
||||||
|
fontSize = 10.sp,
|
||||||
|
color = Color(0xFF10B981),
|
||||||
|
fontWeight = FontWeight.SemiBold
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
@@ -794,13 +807,8 @@ private fun ScheduleFilterTabContent(tradeConfig: TradeConfig) {
|
|||||||
Column(modifier = Modifier.padding(8.dp)) {
|
Column(modifier = Modifier.padding(8.dp)) {
|
||||||
Text("뉴스/공시 RAG 임베딩", fontSize = 10.sp, color = Color(0xFF64748B))
|
Text("뉴스/공시 RAG 임베딩", fontSize = 10.sp, color = Color(0xFF64748B))
|
||||||
Spacer(Modifier.height(2.dp))
|
Spacer(Modifier.height(2.dp))
|
||||||
val embedName = if (KisSession.config.embedModelPath.isNotBlank()) {
|
|
||||||
java.io.File(KisSession.config.embedModelPath).name
|
|
||||||
} else {
|
|
||||||
"bge-m3 (내장 임베딩)"
|
|
||||||
}
|
|
||||||
Text(
|
Text(
|
||||||
embedName,
|
RagService.getDisplayEmbeddingModelName(),
|
||||||
fontSize = 11.sp,
|
fontSize = 11.sp,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
color = Color(0xFF0F172A),
|
color = Color(0xFF0F172A),
|
||||||
@@ -810,6 +818,54 @@ private fun ScheduleFilterTabContent(tradeConfig: TradeConfig) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spacer(Modifier.height(8.dp))
|
||||||
|
|
||||||
|
// 루씬 벡터 DB 실시간 상태 및 관리 버튼
|
||||||
|
Surface(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = RoundedCornerShape(6.dp),
|
||||||
|
color = Color(0xFFF1F5F9),
|
||||||
|
border = BorderStroke(1.dp, Color(0xFFE2E8F0))
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.padding(horizontal = 10.dp, vertical = 6.dp),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
|
) {
|
||||||
|
Text("🗄️", fontSize = 12.sp)
|
||||||
|
Text(
|
||||||
|
"루씬 벡터 DB:",
|
||||||
|
fontSize = 11.sp,
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
color = Color(0xFF334155)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
"기사 ${luceneStats.first}건 (${luceneStats.second})",
|
||||||
|
fontSize = 11.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color(0xFF4F46E5)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
OutlinedButton(
|
||||||
|
onClick = {
|
||||||
|
RagService.resetLuceneStore()
|
||||||
|
luceneStats = RagService.getLuceneStats()
|
||||||
|
},
|
||||||
|
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 2.dp),
|
||||||
|
modifier = Modifier.height(26.dp),
|
||||||
|
shape = RoundedCornerShape(4.dp),
|
||||||
|
border = BorderStroke(1.dp, Color(0xFFCBD5E1))
|
||||||
|
) {
|
||||||
|
Text("🧹 벡터 DB 초기화", fontSize = 10.sp, color = Color(0xFF475569), fontWeight = FontWeight.Bold)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user