25 lines
1004 B
Kotlin
25 lines
1004 B
Kotlin
|
|
package service
|
||
|
|
|
||
|
|
import network.NewsService
|
||
|
|
|
||
|
|
object StockAnalysisManager {
|
||
|
|
|
||
|
|
suspend fun analyzeStockWithRealTimeData(stockName: String, currentPrice: String): String {
|
||
|
|
println("🔍 [1/3] '${stockName}' 실시간 뉴스 수집 및 학습 시작...")
|
||
|
|
|
||
|
|
// 1. 실시간 뉴스 검색 및 DB 저장 (Embedding 서버 8081 활용)
|
||
|
|
// 키워드를 "종목명 주가 전망"으로 최적화하여 검색
|
||
|
|
NewsService.fetchAndIngestNews("$stockName 주가 전망")
|
||
|
|
|
||
|
|
println("🧠 [2/3] 관련 컨텍스트 추출 중...")
|
||
|
|
|
||
|
|
// 2. 방금 저장된 뉴스를 포함하여 DB에서 관련성 높은 정보 추출
|
||
|
|
val question = "${stockName}의 현재가 ${currentPrice}원 기준, 최근 뉴스 수급 상황과 향후 단기 전망을 분석해줘."
|
||
|
|
val context = RagService.askWithContext(question)
|
||
|
|
|
||
|
|
println("🤖 [3/3] AI 분석 생성 중 (Chat 서버 8080)...")
|
||
|
|
|
||
|
|
// 3. 최종 분석 결과 반환
|
||
|
|
return context
|
||
|
|
}
|
||
|
|
}
|