Skip to content

Commit 24ec4e0

Browse files
committed
Qdrant 설정 추가
1 parent ae939f1 commit 24ec4e0

File tree

9 files changed

+348
-34
lines changed

9 files changed

+348
-34
lines changed

cli/utils/env_loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ def set_vectordb(
7171
"""VectorDB 타입과 위치를 설정합니다.
7272
7373
Args:
74-
vectordb_type (str): VectorDB 타입 ("faiss" 또는 "pgvector").
74+
vectordb_type (str): VectorDB 타입 ("faiss" 또는 "pgvector" 또는 "qdrant").
7575
vectordb_location (Optional[str]): 경로 또는 연결 URL.
7676
7777
Raises:
7878
ValueError: 잘못된 타입이나 경로/URL일 경우.
7979
"""
8080

81-
if vectordb_type not in ("faiss", "pgvector"):
81+
if vectordb_type not in ("faiss", "pgvector", "qdrant"):
8282
raise ValueError(f"지원하지 않는 VectorDB 타입: {vectordb_type}")
8383

8484
os.environ["VECTORDB_TYPE"] = vectordb_type

interface/app_pages/settings_sections/data_source_section.py

Lines changed: 95 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,36 @@ def render_data_source_section(config: Config | None = None) -> None:
103103
new_url = st.text_input(
104104
"URL", value=existing.url, key="dh_edit_url"
105105
)
106-
new_faiss = st.text_input(
107-
"FAISS 저장 경로(선택)",
108-
value=existing.faiss_path or "",
109-
key="dh_edit_faiss",
106+
new_vdb_type = st.selectbox(
107+
"VectorDB 타입",
108+
options=["faiss", "pgvector", "qdrant"],
109+
index=(
110+
0
111+
if existing.vectordb_type == "faiss"
112+
else (1 if existing.vectordb_type == "pgvector" else 2)
113+
),
114+
key="dh_edit_vdb_type",
115+
)
116+
new_vdb_loc_placeholder = (
117+
"FAISS 디렉토리 경로 (예: ./dev/table_info_db)"
118+
if new_vdb_type == "faiss"
119+
else (
120+
"pgvector 연결 문자열 (postgresql://...)"
121+
if new_vdb_type == "pgvector"
122+
else "Qdrant URL (예: http://localhost:6333)"
123+
)
124+
)
125+
new_vdb_location = st.text_input(
126+
"VectorDB 위치",
127+
value=existing.vectordb_location or existing.faiss_path or "",
128+
key="dh_edit_vdb_loc",
129+
placeholder=new_vdb_loc_placeholder,
130+
)
131+
new_vdb_api_key = st.text_input(
132+
"VectorDB API Key (선택)",
133+
value=existing.vectordb_api_key or "",
134+
type="password",
135+
key="dh_edit_vdb_key",
110136
)
111137
new_note = st.text_input(
112138
"메모", value=existing.note or "", key="dh_edit_note"
@@ -128,7 +154,14 @@ def render_data_source_section(config: Config | None = None) -> None:
128154
update_datahub_source(
129155
name=edit_dh,
130156
url=new_url,
131-
faiss_path=(new_faiss or None),
157+
faiss_path=(
158+
new_vdb_location
159+
if new_vdb_type == "faiss"
160+
else None
161+
),
162+
vectordb_type=new_vdb_type,
163+
vectordb_location=(new_vdb_location or None),
164+
vectordb_api_key=(new_vdb_api_key or None),
132165
note=(new_note or None),
133166
)
134167
st.success("저장되었습니다.")
@@ -147,10 +180,29 @@ def render_data_source_section(config: Config | None = None) -> None:
147180
dh_url = st.text_input(
148181
"URL", key="dh_url", placeholder="http://localhost:8080"
149182
)
150-
dh_faiss = st.text_input(
151-
"FAISS 저장 경로(선택)",
152-
key="dh_faiss",
153-
placeholder="예: ./dev/table_info_db",
183+
dh_vdb_type = st.selectbox(
184+
"VectorDB 타입",
185+
options=["faiss", "pgvector", "qdrant"],
186+
key="dh_new_vdb_type",
187+
)
188+
dh_vdb_loc_placeholder = (
189+
"FAISS 디렉토리 경로 (예: ./dev/table_info_db)"
190+
if dh_vdb_type == "faiss"
191+
else (
192+
"pgvector 연결 문자열 (postgresql://...)"
193+
if dh_vdb_type == "pgvector"
194+
else "Qdrant URL (예: http://localhost:6333)"
195+
)
196+
)
197+
dh_vdb_location = st.text_input(
198+
"VectorDB 위치",
199+
key="dh_new_vdb_loc",
200+
placeholder=dh_vdb_loc_placeholder,
201+
)
202+
dh_vdb_api_key = st.text_input(
203+
"VectorDB API Key (선택)",
204+
type="password",
205+
key="dh_new_vdb_key",
154206
)
155207
dh_note = st.text_input("메모", key="dh_note", placeholder="선택")
156208

@@ -174,7 +226,12 @@ def render_data_source_section(config: Config | None = None) -> None:
174226
add_datahub_source(
175227
name=dh_name,
176228
url=dh_url,
177-
faiss_path=(dh_faiss or None),
229+
faiss_path=(
230+
dh_vdb_location if dh_vdb_type == "faiss" else None
231+
),
232+
vectordb_type=dh_vdb_type,
233+
vectordb_location=(dh_vdb_location or None),
234+
vectordb_api_key=(dh_vdb_api_key or None),
178235
note=dh_note or None,
179236
)
180237
st.success("추가되었습니다.")
@@ -216,21 +273,35 @@ def render_data_source_section(config: Config | None = None) -> None:
216273
if existing:
217274
new_type = st.selectbox(
218275
"타입",
219-
options=["faiss", "pgvector"],
220-
index=(0 if existing.type == "faiss" else 1),
276+
options=["faiss", "pgvector", "qdrant"],
277+
index=(
278+
0
279+
if existing.type == "faiss"
280+
else (1 if existing.type == "pgvector" else 2)
281+
),
221282
key="vdb_edit_type",
222283
)
223284
new_loc_placeholder = (
224285
"FAISS 디렉토리 경로 (예: ./dev/table_info_db)"
225286
if new_type == "faiss"
226-
else "pgvector 연결 문자열 (postgresql://user:pass@host:port/db)"
287+
else (
288+
"pgvector 연결 문자열 (postgresql://user:pass@host:port/db)"
289+
if new_type == "pgvector"
290+
else "Qdrant URL (예: http://localhost:6333)"
291+
)
227292
)
228293
new_location = st.text_input(
229294
"위치",
230295
value=existing.location,
231296
key="vdb_edit_location",
232297
placeholder=new_loc_placeholder,
233298
)
299+
new_api_key = st.text_input(
300+
"API Key (선택)",
301+
value=existing.api_key or "",
302+
type="password",
303+
key="vdb_edit_key",
304+
)
234305
new_prefix = st.text_input(
235306
"컬렉션 접두사(선택)",
236307
value=existing.collection_prefix or "",
@@ -258,6 +329,7 @@ def render_data_source_section(config: Config | None = None) -> None:
258329
name=edit_vdb,
259330
vtype=new_type,
260331
location=new_location,
332+
api_key=(new_api_key or None),
261333
collection_prefix=(new_prefix or None),
262334
note=(new_note or None),
263335
)
@@ -275,16 +347,23 @@ def render_data_source_section(config: Config | None = None) -> None:
275347
st.write("VectorDB 추가")
276348
vdb_name = st.text_input("이름", key="vdb_name")
277349
vdb_type = st.selectbox(
278-
"타입", options=["faiss", "pgvector"], key="vdb_type"
350+
"타입", options=["faiss", "pgvector", "qdrant"], key="vdb_type"
279351
)
280352
vdb_loc_placeholder = (
281353
"FAISS 디렉토리 경로 (예: ./dev/table_info_db)"
282354
if vdb_type == "faiss"
283-
else "pgvector 연결 문자열 (postgresql://user:pass@host:port/db)"
355+
else (
356+
"pgvector 연결 문자열 (postgresql://user:pass@host:port/db)"
357+
if vdb_type == "pgvector"
358+
else "Qdrant URL (예: http://localhost:6333)"
359+
)
284360
)
285361
vdb_location = st.text_input(
286362
"위치", key="vdb_location", placeholder=vdb_loc_placeholder
287363
)
364+
vdb_api_key = st.text_input(
365+
"API Key (선택)", type="password", key="vdb_new_key"
366+
)
288367
vdb_prefix = st.text_input(
289368
"컬렉션 접두사(선택)", key="vdb_prefix", placeholder="예: app1_"
290369
)
@@ -312,6 +391,7 @@ def render_data_source_section(config: Config | None = None) -> None:
312391
name=vdb_name,
313392
vtype=vdb_type,
314393
location=vdb_location,
394+
api_key=(vdb_api_key or None),
315395
collection_prefix=(vdb_prefix or None),
316396
note=(vdb_note or None),
317397
)

interface/app_pages/sidebar_components/data_source_selector.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ def render_sidebar_data_source_selector(config=None) -> None:
3939
return
4040
try:
4141
update_datahub_server(config, selected.url)
42-
# DataHub 선택 시, FAISS 경로가 정의되어 있으면 기본 VectorDB 로케이션으로도 반영
43-
if selected.faiss_path:
42+
# DataHub 선택 시, VectorDB 설정이 정의되어 있으면 기본 VectorDB 로케이션으로도 반영
43+
if selected.vectordb_location:
44+
try:
45+
update_vectordb_settings(
46+
config,
47+
vectordb_type=selected.vectordb_type or "faiss",
48+
vectordb_location=selected.vectordb_location,
49+
)
50+
except Exception as e:
51+
st.sidebar.warning(f"VectorDB 설정 적용 경고: {e}")
52+
elif selected.faiss_path:
53+
# Backward compatibility
4454
try:
4555
update_vectordb_settings(
4656
config,

interface/core/config/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ class DataHubSource:
1717
name: str
1818
url: str
1919
faiss_path: Optional[str] = None
20+
vectordb_type: str = "faiss"
21+
vectordb_location: Optional[str] = None
22+
vectordb_api_key: Optional[str] = None
2023
note: Optional[str] = None
2124

2225

2326
@dataclass
2427
class VectorDBSource:
2528
name: str
26-
type: str # 'faiss' | 'pgvector'
29+
type: str # 'faiss' | 'pgvector' | 'qdrant'
2730
location: str
31+
api_key: Optional[str] = None
2832
collection_prefix: Optional[str] = None
2933
note: Optional[str] = None
3034

interface/core/config/persist.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,22 @@ def _parse_datahub_list(items: List[Dict[str, Any]]) -> List[DataHubSource]:
6363
name = str(item.get("name", "")).strip()
6464
url = str(item.get("url", "")).strip()
6565
faiss_path = item.get("faiss_path")
66+
vectordb_type = item.get("vectordb_type", "faiss")
67+
vectordb_location = item.get("vectordb_location")
68+
vectordb_api_key = item.get("vectordb_api_key")
6669
note = item.get("note")
6770
if not name or not url:
6871
continue
6972
parsed.append(
70-
DataHubSource(name=name, url=url, faiss_path=faiss_path, note=note)
73+
DataHubSource(
74+
name=name,
75+
url=url,
76+
faiss_path=faiss_path,
77+
vectordb_type=vectordb_type,
78+
vectordb_location=vectordb_location,
79+
vectordb_api_key=vectordb_api_key,
80+
note=note,
81+
)
7182
)
7283
return parsed
7384

@@ -81,12 +92,14 @@ def _parse_vectordb_list(items: List[Dict[str, Any]]) -> List[VectorDBSource]:
8192
if not name or not vtype or not location:
8293
continue
8394
collection_prefix = item.get("collection_prefix")
95+
api_key = item.get("api_key")
8496
note = item.get("note")
8597
parsed.append(
8698
VectorDBSource(
8799
name=name,
88100
type=vtype,
89101
location=location,
102+
api_key=api_key,
90103
collection_prefix=collection_prefix,
91104
note=note,
92105
)

interface/core/config/registry_data_sources.py

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,53 @@ def _save_registry(registry: DataSourcesRegistry) -> None:
4141

4242

4343
def add_datahub_source(
44-
*, name: str, url: str, faiss_path: Optional[str] = None, note: Optional[str] = None
44+
*,
45+
name: str,
46+
url: str,
47+
faiss_path: Optional[str] = None,
48+
vectordb_type: str = "faiss",
49+
vectordb_location: Optional[str] = None,
50+
vectordb_api_key: Optional[str] = None,
51+
note: Optional[str] = None,
4552
) -> None:
4653
registry = get_data_sources_registry()
4754
if any(s.name == name for s in registry.datahub):
4855
raise ValueError(f"이미 존재하는 DataHub 이름입니다: {name}")
4956
registry.datahub.append(
50-
DataHubSource(name=name, url=url, faiss_path=faiss_path, note=note)
57+
DataHubSource(
58+
name=name,
59+
url=url,
60+
faiss_path=faiss_path,
61+
vectordb_type=vectordb_type,
62+
vectordb_location=vectordb_location,
63+
vectordb_api_key=vectordb_api_key,
64+
note=note,
65+
)
5166
)
5267
_save_registry(registry)
5368

5469

5570
def update_datahub_source(
56-
*, name: str, url: str, faiss_path: Optional[str], note: Optional[str]
71+
*,
72+
name: str,
73+
url: str,
74+
faiss_path: Optional[str],
75+
vectordb_type: str = "faiss",
76+
vectordb_location: Optional[str] = None,
77+
vectordb_api_key: Optional[str] = None,
78+
note: Optional[str],
5779
) -> None:
5880
registry = get_data_sources_registry()
5981
for idx, s in enumerate(registry.datahub):
6082
if s.name == name:
6183
registry.datahub[idx] = DataHubSource(
62-
name=name, url=url, faiss_path=faiss_path, note=note
84+
name=name,
85+
url=url,
86+
faiss_path=faiss_path,
87+
vectordb_type=vectordb_type,
88+
vectordb_location=vectordb_location,
89+
vectordb_api_key=vectordb_api_key,
90+
note=note,
6391
)
6492
_save_registry(registry)
6593
return
@@ -77,12 +105,15 @@ def add_vectordb_source(
77105
name: str,
78106
vtype: str,
79107
location: str,
108+
api_key: Optional[str] = None,
80109
collection_prefix: Optional[str] = None,
81110
note: Optional[str] = None,
82111
) -> None:
83112
vtype = (vtype or "").lower()
84-
if vtype not in ("faiss", "pgvector"):
85-
raise ValueError("VectorDB 타입은 'faiss' 또는 'pgvector'여야 합니다")
113+
if vtype not in ("faiss", "pgvector", "qdrant"):
114+
raise ValueError(
115+
"VectorDB 타입은 'faiss', 'pgvector', 'qdrant' 중 하나여야 합니다"
116+
)
86117
registry = get_data_sources_registry()
87118
if any(s.name == name for s in registry.vectordb):
88119
raise ValueError(f"이미 존재하는 VectorDB 이름입니다: {name}")
@@ -91,6 +122,7 @@ def add_vectordb_source(
91122
name=name,
92123
type=vtype,
93124
location=location,
125+
api_key=api_key,
94126
collection_prefix=collection_prefix,
95127
note=note,
96128
)
@@ -103,19 +135,23 @@ def update_vectordb_source(
103135
name: str,
104136
vtype: str,
105137
location: str,
138+
api_key: Optional[str] = None,
106139
collection_prefix: Optional[str],
107140
note: Optional[str],
108141
) -> None:
109142
vtype = (vtype or "").lower()
110-
if vtype not in ("faiss", "pgvector"):
111-
raise ValueError("VectorDB 타입은 'faiss' 또는 'pgvector'여야 합니다")
143+
if vtype not in ("faiss", "pgvector", "qdrant"):
144+
raise ValueError(
145+
"VectorDB 타입은 'faiss', 'pgvector', 'qdrant' 중 하나여야 합니다"
146+
)
112147
registry = get_data_sources_registry()
113148
for idx, s in enumerate(registry.vectordb):
114149
if s.name == name:
115150
registry.vectordb[idx] = VectorDBSource(
116151
name=name,
117152
type=vtype,
118153
location=location,
154+
api_key=api_key,
119155
collection_prefix=collection_prefix,
120156
note=note,
121157
)

0 commit comments

Comments
 (0)