mirror of
https://github.com/hwanny1128/HGZero.git
synced 2025-12-06 14:56:23 +00:00
63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
import asyncio
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
from src.utils.config import load_config, get_database_url
|
|
from src.db.rag_minutes_db import RagMinutesDB
|
|
from src.db.postgres_vector import PostgresVectorDB
|
|
from src.utils.embedding import EmbeddingGenerator
|
|
from src.services.eventhub_consumer import start_consumer
|
|
|
|
# 로깅 설정
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
async def main():
|
|
"""메인 함수"""
|
|
try:
|
|
# 설정 로드
|
|
config_path = Path(__file__).parent / "config.yaml"
|
|
config = load_config(str(config_path))
|
|
logger.info(config)
|
|
|
|
logger.info("설정 로드 완료")
|
|
|
|
# 데이터베이스 연결
|
|
db_url = get_database_url(config)
|
|
rag_minutes_db = RagMinutesDB(db_url)
|
|
logger.info("RAG Minutes DB 연결 완료")
|
|
|
|
# 용어집 데이터베이스 연결
|
|
term_db = PostgresVectorDB(db_url)
|
|
logger.info("용어집 DB 연결 완료")
|
|
|
|
# Embedding 생성기 초기화
|
|
azure_openai = config["azure_openai"]
|
|
embedding_gen = EmbeddingGenerator(
|
|
api_key=azure_openai["api_key"],
|
|
endpoint=azure_openai["endpoint"],
|
|
model=azure_openai["embedding_model"],
|
|
dimension=azure_openai["embedding_dimension"],
|
|
api_version=azure_openai["api_version"]
|
|
)
|
|
|
|
logger.info("Embedding 생성기 초기화 완료")
|
|
|
|
# Event Hub Consumer 시작
|
|
logger.info("Event Hub Consumer 시작...")
|
|
await start_consumer(config, rag_minutes_db, embedding_gen, term_db)
|
|
|
|
except KeyboardInterrupt:
|
|
logger.info("프로그램 종료")
|
|
except Exception as e:
|
|
logger.error(f"에러 발생: {str(e)}")
|
|
raise
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|