feat(animal-chat): LanceDB 벡터 검색 RAG 통합

- LanceDB로 MD 문서 252개 청크 인덱싱
- /api/animal-chat에 벡터 검색 컨텍스트 주입
- 마지막 사용자 메시지로 관련 문서 검색 (top 3)
- ChromaDB Windows crash로 LanceDB 채택
This commit is contained in:
thug0bin
2026-03-08 15:00:39 +09:00
parent 3631da2953
commit be1e6c2bb7
16 changed files with 400 additions and 1 deletions

27
backend/test_rag.py Normal file
View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
import sys
import os
sys.path.insert(0, os.path.dirname(__file__))
print("1. Starting...")
print(f" CWD: {os.getcwd()}")
from dotenv import load_dotenv
load_dotenv()
print(f"2. API Key: {os.getenv('OPENAI_API_KEY', 'NOT SET')[:20]}...")
from utils.animal_rag import AnimalDrugRAG
print("3. Module imported")
rag = AnimalDrugRAG()
print("4. RAG created")
try:
count = rag.index_md_files()
print(f"5. Indexed: {count} chunks")
except Exception as e:
print(f"5. Error: {e}")
import traceback
traceback.print_exc()
print("6. Done")