Skip to content

Commit 143eb3a

Browse files
authored
Merge pull request #205 from #204
204 qdrant 지원
2 parents 7a96120 + dc96a25 commit 143eb3a

23 files changed

+804
-202
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

docker/docker-compose-pgvector.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
# docker compose -f docker-compose-pgvector.yml up
2-
# docker compose -f docker-compose-pgvector.yml down
1+
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-pgvector.yml up
2+
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-pgvector.yml down
33

44
services:
5+
streamlit:
6+
environment:
7+
- DATABASE_URL=postgresql://pgvector:pgvector@pgvector:5432/streamlit
8+
depends_on:
9+
- pgvector
10+
511
pgvector:
612
image: pgvector/pgvector:pg17
713
hostname: pgvector
@@ -12,7 +18,7 @@ services:
1218
environment:
1319
POSTGRES_USER: pgvector
1420
POSTGRES_PASSWORD: pgvector
15-
POSTGRES_DB: pgvector
21+
POSTGRES_DB: streamlit
1622
TZ: Asia/Seoul
1723
LANG: en_US.utf8
1824
volumes:

docker/docker-compose-postgres.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
# docker compose -f docker-compose-postgres.yml up
2-
# docker compose -f docker-compose-postgres.yml down
1+
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-postgres.yml up
2+
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-postgres.yml down
33

44
services:
5+
streamlit:
6+
environment:
7+
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/streamlit
8+
depends_on:
9+
- postgres
10+
511
postgres:
612
image: postgres:15
713
hostname: postgres
@@ -12,7 +18,7 @@ services:
1218
environment:
1319
POSTGRES_USER: postgres
1420
POSTGRES_PASSWORD: postgres
15-
POSTGRES_DB: postgres
21+
POSTGRES_DB: streamlit
1622
TZ: Asia/Seoul
1723
LANG: en_US.utf8
1824
volumes:

docker/docker-compose-qdrant.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-qdrant.yml up
2+
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-qdrant.yml down
3+
4+
services:
5+
streamlit:
6+
environment:
7+
- QDRANT_HOST=qdrant
8+
- QDRANT_PORT=6333
9+
depends_on:
10+
- qdrant
11+
12+
qdrant:
13+
image: qdrant/qdrant:latest
14+
hostname: qdrant
15+
container_name: qdrant
16+
restart: always
17+
ports:
18+
- "6333:6333"
19+
volumes:
20+
- qdrant_data:/qdrant/storage
21+
22+
volumes:
23+
qdrant_data:

docker/docker-compose.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,4 @@ services:
1313
- ../.env
1414
environment:
1515
- STREAMLIT_SERVER_PORT=8501
16-
- DATABASE_URL=postgresql://pgvector:pgvector@localhost:5432/streamlit
17-
depends_on:
18-
- pgvector
1916

20-
pgvector:
21-
image: pgvector/pgvector:pg17
22-
hostname: pgvector
23-
container_name: pgvector
24-
environment:
25-
POSTGRES_USER: pgvector
26-
POSTGRES_PASSWORD: pgvector
27-
POSTGRES_DB: streamlit
28-
ports:
29-
- "5432:5432"
30-
volumes:
31-
- pgdata:/var/lib/postgresql/data
32-
33-
volumes:
34-
pgdata:

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
)

0 commit comments

Comments
 (0)