6464    type = click .Path (exists = True , file_okay = False , dir_okay = True , readable = True ), 
6565    help = "프롬프트 템플릿(.md 파일)이 저장된 디렉토리 경로를 지정합니다. 지정하지 않으면 기본 경로를 사용합니다." , 
6666) 
67+ @click .option ( 
68+     "--vectordb-type" , 
69+     type = click .Choice (["faiss" , "pgvector" ]), 
70+     default = "faiss" , 
71+     help = "사용할 벡터 데이터베이스 타입 (기본값: faiss)" , 
72+ ) 
73+ @click .option ( 
74+     "--vectordb-location" , 
75+     help = ( 
76+         "VectorDB 위치 설정\n "  
77+         "- FAISS: 디렉토리 경로 (예: ./my_vectordb)\n "  
78+         "- pgvector: 연결 문자열 (예: postgresql://user:pass@host:port/db)\n "  
79+         "기본값: FAISS는 './table_info_db', pgvector는 환경변수 사용"  
80+     ), 
81+ ) 
6782# pylint: disable=redefined-outer-name 
6883def  cli (
6984    ctx : click .Context ,
7085    datahub_server : str ,
7186    run_streamlit : bool ,
7287    port : int ,
73-     env_file_path : str  =  None ,
74-     prompt_dir_path : str  =  None ,
88+     env_file_path : str  |  None  =  None ,
89+     prompt_dir_path : str  |  None  =  None ,
90+     vectordb_type : str  =  "faiss" ,
91+     vectordb_location : str  =  None ,
7592) ->  None :
7693    """ 
7794    Datahub GMS 서버 URL을 설정하고, Streamlit 애플리케이션을 실행할 수 있는 CLI 명령 그룹입니다. 
@@ -117,6 +134,23 @@ def cli(
117134            click .secho (f"프롬프트 디렉토리 환경변수 설정 실패: { str (e )}  " , fg = "red" )
118135            ctx .exit (1 )
119136
137+     # VectorDB 타입을 환경 변수로 설정 
138+     try :
139+         os .environ ["VECTORDB_TYPE" ] =  vectordb_type 
140+         click .secho (f"VectorDB 타입 설정됨: { vectordb_type }  " , fg = "green" )
141+     except  Exception  as  e :
142+         click .secho (f"VectorDB 타입 설정 실패: { str (e )}  " , fg = "red" )
143+         ctx .exit (1 )
144+ 
145+     # VectorDB 경로를 환경 변수로 설정 
146+     if  vectordb_location :
147+         try :
148+             os .environ ["VECTORDB_LOCATION" ] =  vectordb_location 
149+             click .secho (f"VectorDB 경로 설정됨: { vectordb_location }  " , fg = "green" )
150+         except  Exception  as  e :
151+             click .secho (f"VectorDB 경로 설정 실패: { str (e )}  " , fg = "red" )
152+             ctx .exit (1 )
153+ 
120154    logger .info (
121155        "Initialization started: GMS server = %s, run_streamlit = %s, port = %d" ,
122156        datahub_server ,
@@ -129,7 +163,7 @@ def cli(
129163        logger .info ("GMS server URL successfully set: %s" , datahub_server )
130164    else :
131165        logger .error ("GMS server health check failed. URL: %s" , datahub_server )
132-         ctx .exit (1 )
166+         #  ctx.exit(1)
133167
134168    if  run_streamlit :
135169        run_streamlit_command (port )
@@ -234,6 +268,21 @@ def run_streamlit_cli_command(port: int) -> None:
234268    is_flag = True , 
235269    help = "단순화된 그래프(QUERY_REFINER 제거) 사용 여부" , 
236270) 
271+ @click .option ( 
272+     "--vectordb-type" , 
273+     type = click .Choice (["faiss" , "pgvector" ]), 
274+     default = "faiss" , 
275+     help = "사용할 벡터 데이터베이스 타입 (기본값: faiss)" , 
276+ ) 
277+ @click .option ( 
278+     "--vectordb-location" , 
279+     help = ( 
280+         "VectorDB 위치 설정\n "  
281+         "- FAISS: 디렉토리 경로 (예: ./my_vectordb)\n "  
282+         "- pgvector: 연결 문자열 (예: postgresql://user:pass@host:port/db)\n "  
283+         "기본값: FAISS는 './table_info_db', pgvector는 환경변수 사용"  
284+     ), 
285+ ) 
237286def  query_command (
238287    question : str ,
239288    database_env : str ,
@@ -242,6 +291,8 @@ def query_command(
242291    device : str ,
243292    use_enriched_graph : bool ,
244293    use_simplified_graph : bool ,
294+     vectordb_type : str  =  "faiss" ,
295+     vectordb_location : str  =  None ,
245296) ->  None :
246297    """ 
247298    자연어 질문을 SQL 쿼리로 변환하여 출력하는 명령어입니다. 
@@ -260,11 +311,19 @@ def query_command(
260311    예시: 
261312        lang2sql query "고객 데이터를 기반으로 유니크한 유저 수를 카운트하는 쿼리" 
262313        lang2sql query "고객 데이터를 기반으로 유니크한 유저 수를 카운트하는 쿼리" --use-enriched-graph 
314+         lang2sql query "고객 데이터를 기반으로 유니크한 유저 수를 카운트하는 쿼리" --vectordb-type pgvector 
263315    """ 
264316
265317    try :
266318        from  llm_utils .query_executor  import  execute_query , extract_sql_from_result 
267319
320+         # VectorDB 타입을 환경 변수로 설정 
321+         os .environ ["VECTORDB_TYPE" ] =  vectordb_type 
322+ 
323+         # VectorDB 위치를 환경 변수로 설정 
324+         if  vectordb_location :
325+             os .environ ["VECTORDB_LOCATION" ] =  vectordb_location 
326+ 
268327        # 공용 함수를 사용하여 쿼리 실행 
269328        res  =  execute_query (
270329            query = question ,
0 commit comments