Skip to content

Commit efa97ed

Browse files
authored
Merge pull request #187 from #180
180 기능 cli 실행 옵션을 UI에서 통합 관리하도록 개선
2 parents 36a9b66 + 4f47b58 commit efa97ed

23 files changed

+2339
-48
lines changed

cli/__init__.py

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Lang2SQL CLI 프로그램입니다.
2-
이 프로그램은 Datahub GMS 서버 URL을 설정하고, 필요 시 Streamlit 인터페이스를 실행합니다.
2+
이 프로그램은 환경 초기화와 Streamlit 실행을 제공합니다.
33
4-
명령어 예시: lang2sql --datahub_server http://localhost:8080 --run-streamlit
4+
주의: --datahub_server 옵션은 더 이상 사용되지 않습니다(deprecated).
5+
DataHub 설정은 UI의 설정 > 데이터 소스 탭에서 관리하세요.
56
"""
67

78
import click
@@ -11,8 +12,7 @@
1112
from cli.core.environment import initialize_environment
1213
from cli.core.streamlit_runner import run_streamlit_command
1314
from cli.utils.logger import configure_logging
14-
from infra.monitoring.check_server import CheckServer
15-
from llm_utils.tools import set_gms_server
15+
1616
from version import __version__
1717

1818
logger = configure_logging()
@@ -24,12 +24,8 @@
2424
@click.pass_context
2525
@click.option(
2626
"--datahub_server",
27-
default="http://localhost:8080",
28-
help=(
29-
"Datahub GMS 서버의 URL을 설정합니다. "
30-
"기본값은 'http://localhost:8080'이며, "
31-
"운영 환경 또는 테스트 환경에 맞게 변경할 수 있습니다."
32-
),
27+
default=None,
28+
help=("[Deprecated] DataHub GMS URL. 이제는 UI 설정 > 데이터 소스에서 관리하세요."),
3329
)
3430
@click.option(
3531
"--run-streamlit",
@@ -61,60 +57,57 @@
6157
)
6258
@click.option(
6359
"--vectordb-type",
64-
type=click.Choice(["faiss", "pgvector"]),
65-
default="faiss",
66-
help="사용할 벡터 데이터베이스 타입 (기본값: faiss)",
60+
default=None,
61+
help="[Deprecated] VectorDB 타입. 이제는 UI 설정 > 데이터 소스에서 관리하세요.",
6762
)
6863
@click.option(
6964
"--vectordb-location",
70-
help=(
71-
"VectorDB 위치 설정\n"
72-
"- FAISS: 디렉토리 경로 (예: ./my_vectordb)\n"
73-
"- pgvector: 연결 문자열 (예: postgresql://user:pass@host:port/db)\n"
74-
"기본값: FAISS는 './dev/table_info_db', pgvector는 환경변수 사용"
75-
),
65+
default=None,
66+
help="[Deprecated] VectorDB 위치. 이제는 UI 설정 > 데이터 소스에서 관리하세요.",
7667
)
7768
def cli(
7869
ctx: click.Context,
79-
datahub_server: str,
70+
datahub_server: str | None,
8071
run_streamlit: bool,
8172
port: int,
8273
env_file_path: str | None = None,
8374
prompt_dir_path: str | None = None,
84-
vectordb_type: str = "faiss",
85-
vectordb_location: str = None,
75+
vectordb_type: str | None = None,
76+
vectordb_location: str | None = None,
8677
) -> None:
8778
"""Lang2SQL CLI 엔트리포인트.
8879
8980
- 환경 변수 및 VectorDB 설정 초기화
90-
- GMS 서버 연결 및 헬스체크
9181
- 필요 시 Streamlit 애플리케이션 실행
9282
"""
9383

9484
try:
9585
initialize_environment(
96-
env_file_path=env_file_path,
97-
prompt_dir_path=prompt_dir_path,
98-
vectordb_type=vectordb_type,
99-
vectordb_location=vectordb_location,
86+
env_file_path=env_file_path, prompt_dir_path=prompt_dir_path
10087
)
10188
except Exception:
10289
logger.error("Initialization failed.", exc_info=True)
10390
ctx.exit(1)
10491

10592
logger.info(
106-
"Initialization started: GMS server = %s, run_streamlit = %s, port = %d",
107-
datahub_server,
93+
"Initialization started: run_streamlit = %s, port = %d",
10894
run_streamlit,
10995
port,
11096
)
11197

112-
if CheckServer.is_gms_server_healthy(url=datahub_server):
113-
set_gms_server(datahub_server)
114-
logger.info("GMS server URL successfully set: %s", datahub_server)
115-
else:
116-
logger.error("GMS server health check failed. URL: %s", datahub_server)
117-
# ctx.exit(1)
98+
# Deprecated 안내: CLI에서 DataHub 설정은 더 이상 처리하지 않습니다
99+
if datahub_server:
100+
click.secho(
101+
"[Deprecated] --datahub_server 옵션은 더 이상 사용되지 않습니다. 설정 > 데이터 소스 탭에서 설정하세요.",
102+
fg="yellow",
103+
)
104+
105+
# Deprecated 안내: CLI에서 VectorDB 설정은 더 이상 처리하지 않습니다
106+
if vectordb_type or vectordb_location:
107+
click.secho(
108+
"[Deprecated] --vectordb-type/--vectordb-location 옵션은 더 이상 사용되지 않습니다. 설정 > 데이터 소스 탭에서 설정하세요.",
109+
fg="yellow",
110+
)
118111

119112
if run_streamlit:
120113
run_streamlit_command(port)

cli/core/environment.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
"""환경 변수 VectorDB 초기화 모듈."""
1+
"""환경 변수 초기화 모듈 (VectorDB 설정은 UI에서 관리)."""
22

33
from typing import Optional
44

5-
from cli.utils.env_loader import load_env, set_prompt_dir, set_vectordb
5+
from cli.utils.env_loader import load_env, set_prompt_dir
66

77

88
def initialize_environment(
99
*,
1010
env_file_path: Optional[str],
1111
prompt_dir_path: Optional[str],
12-
vectordb_type: str,
13-
vectordb_location: Optional[str],
1412
) -> None:
15-
"""환경 변수와 VectorDB 설정을 초기화합니다.
13+
"""환경 변수를 초기화합니다. VectorDB 설정은 UI에서 관리합니다.
1614
1715
Args:
1816
env_file_path (Optional[str]): 로드할 .env 파일 경로. None이면 기본값 사용.
1917
prompt_dir_path (Optional[str]): 프롬프트 템플릿 디렉토리 경로. None이면 설정하지 않음.
20-
vectordb_type (str): VectorDB 타입 ("faiss" 또는 "pgvector").
21-
vectordb_location (Optional[str]): VectorDB 위치. None이면 기본값 사용.
2218
2319
Raises:
2420
Exception: 초기화 과정에서 오류가 발생한 경우.
2521
"""
2622
load_env(env_file_path=env_file_path)
2723
set_prompt_dir(prompt_dir_path=prompt_dir_path)
28-
set_vectordb(vectordb_type=vectordb_type, vectordb_location=vectordb_location)

interface/app_pages/home.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#### 사용 방법
2020
1. 왼쪽 메뉴에서 원하는 기능 페이지를 선택하세요.
2121
2. **🔍 Lang2SQL**: 자연어 → SQL 변환 및 결과 분석
22-
3. **📊 그래프 빌더**: 데이터 시각화를 위한 차트 구성
22+
3. **📊 그래프 빌더**: LangGraph 실행 순서를 프리셋/커스텀으로 구성하고 세션에 적용
23+
4. **⚙️ 설정**: 데이터 소스, LLM, DB 연결 등 환경 설정
2324
"""
2425
)
2526

interface/app_pages/lang2sql.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
from interface.core.lang2sql_runner import run_lang2sql
2121
from interface.core.result_renderer import display_result
2222
from interface.core.session_utils import init_graph
23+
from interface.core.config import load_config
24+
from interface.app_pages.sidebar_components import (
25+
render_sidebar_data_source_selector,
26+
render_sidebar_llm_selector,
27+
render_sidebar_embedding_selector,
28+
render_sidebar_db_selector,
29+
)
30+
2331

2432
TITLE = "Lang2SQL"
2533
DEFAULT_QUERY = "고객 데이터를 기반으로 유니크한 유저 수를 카운트하는 쿼리"
@@ -37,6 +45,21 @@
3745

3846
st.title(TITLE)
3947

48+
config = load_config()
49+
50+
render_sidebar_data_source_selector(config)
51+
st.sidebar.divider()
52+
render_sidebar_llm_selector()
53+
st.sidebar.divider()
54+
render_sidebar_embedding_selector()
55+
st.sidebar.divider()
56+
render_sidebar_db_selector()
57+
st.sidebar.divider()
58+
59+
st.sidebar.title("Output Settings")
60+
for key, label in SIDEBAR_OPTIONS.items():
61+
st.sidebar.checkbox(label, value=True, key=key)
62+
4063
st.sidebar.markdown("### 워크플로우 선택")
4164
use_enriched = st.sidebar.checkbox(
4265
"프로파일 추출 & 컨텍스트 보강 워크플로우 사용", value=False
@@ -55,6 +78,8 @@
5578
f"Lang2SQL이 성공적으로 새로고침되었습니다. ({GRAPH_TYPE} 워크플로우)"
5679
)
5780

81+
## moved to component: render_sidebar_llm_selector()
82+
5883
user_query = st.text_area("쿼리를 입력하세요:", value=DEFAULT_QUERY)
5984

6085
if "dialects" not in st.session_state:
@@ -110,10 +135,6 @@
110135
)
111136
user_top_n = st.slider("검색할 테이블 정보 개수:", min_value=1, max_value=20, value=5)
112137

113-
st.sidebar.title("Output Settings")
114-
for key, label in SIDEBAR_OPTIONS.items():
115-
st.sidebar.checkbox(label, value=True, key=key)
116-
117138
if st.button("쿼리 실행"):
118139
res = run_lang2sql(
119140
query=user_query,

interface/app_pages/settings.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Settings 페이지 – 섹션 기반 UI
3+
"""
4+
5+
import streamlit as st
6+
7+
from interface.core.config import load_config
8+
from interface.app_pages.settings_sections.data_source_section import (
9+
render_data_source_section,
10+
)
11+
from interface.app_pages.settings_sections.llm_section import render_llm_section
12+
from interface.app_pages.settings_sections.db_section import render_db_section
13+
14+
15+
st.title("⚙️ 설정")
16+
17+
config = load_config()
18+
19+
tabs = st.tabs(["데이터 소스", "LLM", "DB"])
20+
21+
with tabs[0]:
22+
render_data_source_section(config)
23+
24+
with tabs[1]:
25+
render_llm_section(config)
26+
27+
with tabs[2]:
28+
render_db_section()
29+
30+
st.divider()
31+
st.caption("민감 정보는 로그에 기록되지 않으며, 이 설정은 현재 세션에 우선 반영됩니다.")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Namespace package for settings page sections
2+
3+
__all__ = [
4+
"data_source_section",
5+
"llm_section",
6+
"db_section",
7+
"vectordb_section",
8+
"device_section",
9+
]

0 commit comments

Comments
 (0)