Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/utils/env_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ def set_vectordb(
"""VectorDB 타입과 위치를 설정합니다.

Args:
vectordb_type (str): VectorDB 타입 ("faiss" 또는 "pgvector").
vectordb_type (str): VectorDB 타입 ("faiss" 또는 "pgvector" 또는 "qdrant").
vectordb_location (Optional[str]): 경로 또는 연결 URL.

Raises:
ValueError: 잘못된 타입이나 경로/URL일 경우.
"""

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

os.environ["VECTORDB_TYPE"] = vectordb_type
Expand Down
12 changes: 9 additions & 3 deletions docker/docker-compose-pgvector.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# docker compose -f docker-compose-pgvector.yml up
# docker compose -f docker-compose-pgvector.yml down
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-pgvector.yml up
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-pgvector.yml down

services:
streamlit:
environment:
- DATABASE_URL=postgresql://pgvector:pgvector@pgvector:5432/streamlit
depends_on:
- pgvector

pgvector:
image: pgvector/pgvector:pg17
hostname: pgvector
Expand All @@ -12,7 +18,7 @@ services:
environment:
POSTGRES_USER: pgvector
POSTGRES_PASSWORD: pgvector
POSTGRES_DB: pgvector
POSTGRES_DB: streamlit
TZ: Asia/Seoul
LANG: en_US.utf8
volumes:
Expand Down
12 changes: 9 additions & 3 deletions docker/docker-compose-postgres.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# docker compose -f docker-compose-postgres.yml up
# docker compose -f docker-compose-postgres.yml down
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-postgres.yml up
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-postgres.yml down

services:
streamlit:
environment:
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/streamlit
depends_on:
- postgres

postgres:
image: postgres:15
hostname: postgres
Expand All @@ -12,7 +18,7 @@ services:
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_DB: streamlit
TZ: Asia/Seoul
LANG: en_US.utf8
volumes:
Expand Down
23 changes: 23 additions & 0 deletions docker/docker-compose-qdrant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-qdrant.yml up
# docker compose -f docker/docker-compose.yml -f docker/docker-compose-qdrant.yml down

services:
streamlit:
environment:
- QDRANT_HOST=qdrant
- QDRANT_PORT=6333
depends_on:
- qdrant

qdrant:
image: qdrant/qdrant:latest
hostname: qdrant
container_name: qdrant
restart: always
ports:
- "6333:6333"
volumes:
- qdrant_data:/qdrant/storage

volumes:
qdrant_data:
18 changes: 0 additions & 18 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,4 @@ services:
- ../.env
environment:
- STREAMLIT_SERVER_PORT=8501
- DATABASE_URL=postgresql://pgvector:pgvector@localhost:5432/streamlit
depends_on:
- pgvector

pgvector:
image: pgvector/pgvector:pg17
hostname: pgvector
container_name: pgvector
environment:
POSTGRES_USER: pgvector
POSTGRES_PASSWORD: pgvector
POSTGRES_DB: streamlit
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data

volumes:
pgdata:
110 changes: 95 additions & 15 deletions interface/app_pages/settings_sections/data_source_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,36 @@ def render_data_source_section(config: Config | None = None) -> None:
new_url = st.text_input(
"URL", value=existing.url, key="dh_edit_url"
)
new_faiss = st.text_input(
"FAISS 저장 경로(선택)",
value=existing.faiss_path or "",
key="dh_edit_faiss",
new_vdb_type = st.selectbox(
"VectorDB 타입",
options=["faiss", "pgvector", "qdrant"],
index=(
0
if existing.vectordb_type == "faiss"
else (1 if existing.vectordb_type == "pgvector" else 2)
),
key="dh_edit_vdb_type",
)
new_vdb_loc_placeholder = (
"FAISS 디렉토리 경로 (예: ./dev/table_info_db)"
if new_vdb_type == "faiss"
else (
"pgvector 연결 문자열 (postgresql://...)"
if new_vdb_type == "pgvector"
else "Qdrant URL (예: http://localhost:6333)"
)
)
new_vdb_location = st.text_input(
"VectorDB 위치",
value=existing.vectordb_location or existing.faiss_path or "",
key="dh_edit_vdb_loc",
placeholder=new_vdb_loc_placeholder,
)
new_vdb_api_key = st.text_input(
"VectorDB API Key (선택)",
value=existing.vectordb_api_key or "",
type="password",
key="dh_edit_vdb_key",
)
new_note = st.text_input(
"메모", value=existing.note or "", key="dh_edit_note"
Expand All @@ -128,7 +154,14 @@ def render_data_source_section(config: Config | None = None) -> None:
update_datahub_source(
name=edit_dh,
url=new_url,
faiss_path=(new_faiss or None),
faiss_path=(
new_vdb_location
if new_vdb_type == "faiss"
else None
),
vectordb_type=new_vdb_type,
vectordb_location=(new_vdb_location or None),
vectordb_api_key=(new_vdb_api_key or None),
note=(new_note or None),
)
st.success("저장되었습니다.")
Expand All @@ -147,10 +180,29 @@ def render_data_source_section(config: Config | None = None) -> None:
dh_url = st.text_input(
"URL", key="dh_url", placeholder="http://localhost:8080"
)
dh_faiss = st.text_input(
"FAISS 저장 경로(선택)",
key="dh_faiss",
placeholder="예: ./dev/table_info_db",
dh_vdb_type = st.selectbox(
"VectorDB 타입",
options=["faiss", "pgvector", "qdrant"],
key="dh_new_vdb_type",
)
dh_vdb_loc_placeholder = (
"FAISS 디렉토리 경로 (예: ./dev/table_info_db)"
if dh_vdb_type == "faiss"
else (
"pgvector 연결 문자열 (postgresql://...)"
if dh_vdb_type == "pgvector"
else "Qdrant URL (예: http://localhost:6333)"
)
)
dh_vdb_location = st.text_input(
"VectorDB 위치",
key="dh_new_vdb_loc",
placeholder=dh_vdb_loc_placeholder,
)
dh_vdb_api_key = st.text_input(
"VectorDB API Key (선택)",
type="password",
key="dh_new_vdb_key",
)
dh_note = st.text_input("메모", key="dh_note", placeholder="선택")

Expand All @@ -174,7 +226,12 @@ def render_data_source_section(config: Config | None = None) -> None:
add_datahub_source(
name=dh_name,
url=dh_url,
faiss_path=(dh_faiss or None),
faiss_path=(
dh_vdb_location if dh_vdb_type == "faiss" else None
),
vectordb_type=dh_vdb_type,
vectordb_location=(dh_vdb_location or None),
vectordb_api_key=(dh_vdb_api_key or None),
note=dh_note or None,
)
st.success("추가되었습니다.")
Expand Down Expand Up @@ -216,21 +273,35 @@ def render_data_source_section(config: Config | None = None) -> None:
if existing:
new_type = st.selectbox(
"타입",
options=["faiss", "pgvector"],
index=(0 if existing.type == "faiss" else 1),
options=["faiss", "pgvector", "qdrant"],
index=(
0
if existing.type == "faiss"
else (1 if existing.type == "pgvector" else 2)
),
key="vdb_edit_type",
)
new_loc_placeholder = (
"FAISS 디렉토리 경로 (예: ./dev/table_info_db)"
if new_type == "faiss"
else "pgvector 연결 문자열 (postgresql://user:pass@host:port/db)"
else (
"pgvector 연결 문자열 (postgresql://user:pass@host:port/db)"
if new_type == "pgvector"
else "Qdrant URL (예: http://localhost:6333)"
)
)
new_location = st.text_input(
"위치",
value=existing.location,
key="vdb_edit_location",
placeholder=new_loc_placeholder,
)
new_api_key = st.text_input(
"API Key (선택)",
value=existing.api_key or "",
type="password",
key="vdb_edit_key",
)
new_prefix = st.text_input(
"컬렉션 접두사(선택)",
value=existing.collection_prefix or "",
Expand Down Expand Up @@ -258,6 +329,7 @@ def render_data_source_section(config: Config | None = None) -> None:
name=edit_vdb,
vtype=new_type,
location=new_location,
api_key=(new_api_key or None),
collection_prefix=(new_prefix or None),
note=(new_note or None),
)
Expand All @@ -275,16 +347,23 @@ def render_data_source_section(config: Config | None = None) -> None:
st.write("VectorDB 추가")
vdb_name = st.text_input("이름", key="vdb_name")
vdb_type = st.selectbox(
"타입", options=["faiss", "pgvector"], key="vdb_type"
"타입", options=["faiss", "pgvector", "qdrant"], key="vdb_type"
)
vdb_loc_placeholder = (
"FAISS 디렉토리 경로 (예: ./dev/table_info_db)"
if vdb_type == "faiss"
else "pgvector 연결 문자열 (postgresql://user:pass@host:port/db)"
else (
"pgvector 연결 문자열 (postgresql://user:pass@host:port/db)"
if vdb_type == "pgvector"
else "Qdrant URL (예: http://localhost:6333)"
)
)
vdb_location = st.text_input(
"위치", key="vdb_location", placeholder=vdb_loc_placeholder
)
vdb_api_key = st.text_input(
"API Key (선택)", type="password", key="vdb_new_key"
)
vdb_prefix = st.text_input(
"컬렉션 접두사(선택)", key="vdb_prefix", placeholder="예: app1_"
)
Expand Down Expand Up @@ -312,6 +391,7 @@ def render_data_source_section(config: Config | None = None) -> None:
name=vdb_name,
vtype=vdb_type,
location=vdb_location,
api_key=(vdb_api_key or None),
collection_prefix=(vdb_prefix or None),
note=(vdb_note or None),
)
Expand Down
14 changes: 12 additions & 2 deletions interface/app_pages/sidebar_components/data_source_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ def render_sidebar_data_source_selector(config=None) -> None:
return
try:
update_datahub_server(config, selected.url)
# DataHub 선택 시, FAISS 경로가 정의되어 있으면 기본 VectorDB 로케이션으로도 반영
if selected.faiss_path:
# DataHub 선택 시, VectorDB 설정이 정의되어 있으면 기본 VectorDB 로케이션으로도 반영
if selected.vectordb_location:
try:
update_vectordb_settings(
config,
vectordb_type=selected.vectordb_type or "faiss",
vectordb_location=selected.vectordb_location,
)
except Exception as e:
st.sidebar.warning(f"VectorDB 설정 적용 경고: {e}")
elif selected.faiss_path:
# Backward compatibility
try:
update_vectordb_settings(
config,
Expand Down
6 changes: 5 additions & 1 deletion interface/core/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ class DataHubSource:
name: str
url: str
faiss_path: Optional[str] = None
vectordb_type: str = "faiss"
vectordb_location: Optional[str] = None
vectordb_api_key: Optional[str] = None
note: Optional[str] = None


@dataclass
class VectorDBSource:
name: str
type: str # 'faiss' | 'pgvector'
type: str # 'faiss' | 'pgvector' | 'qdrant'
location: str
api_key: Optional[str] = None
collection_prefix: Optional[str] = None
note: Optional[str] = None

Expand Down
15 changes: 14 additions & 1 deletion interface/core/config/persist.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,22 @@ def _parse_datahub_list(items: List[Dict[str, Any]]) -> List[DataHubSource]:
name = str(item.get("name", "")).strip()
url = str(item.get("url", "")).strip()
faiss_path = item.get("faiss_path")
vectordb_type = item.get("vectordb_type", "faiss")
vectordb_location = item.get("vectordb_location")
vectordb_api_key = item.get("vectordb_api_key")
note = item.get("note")
if not name or not url:
continue
parsed.append(
DataHubSource(name=name, url=url, faiss_path=faiss_path, note=note)
DataHubSource(
name=name,
url=url,
faiss_path=faiss_path,
vectordb_type=vectordb_type,
vectordb_location=vectordb_location,
vectordb_api_key=vectordb_api_key,
note=note,
)
)
return parsed

Expand All @@ -81,12 +92,14 @@ def _parse_vectordb_list(items: List[Dict[str, Any]]) -> List[VectorDBSource]:
if not name or not vtype or not location:
continue
collection_prefix = item.get("collection_prefix")
api_key = item.get("api_key")
note = item.get("note")
parsed.append(
VectorDBSource(
name=name,
type=vtype,
location=location,
api_key=api_key,
collection_prefix=collection_prefix,
note=note,
)
Expand Down
Loading