Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
44 changes: 44 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "Dev AI API Server",
"dockerComposeFile": [
"../docker/docker-compose.yml"
],
"service": "dev",
"remoteUser": "developer",
"workspaceFolder": "/home/developer/workspace",
"remoteEnv": {
"UV_LINK_MODE": "copy"
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-toolsai.jupyter",
"mhutchie.git-graph",
"ms-azuretools.vscode-docker",
"charliermarsh.ruff"
],
"settings": {
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
}
},
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"ruff.path": [
"${workspaceFolder}/.venv/bin/ruff"
],
"ruff.organizeImports": true
}
}
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": true
}
},
"postCreateCommand": "bash -lc 'uv venv && if [ -f pyproject.toml ]; then uv sync --all-groups; else if [ -f requirements-dev.txt ]; then uv pip install -r requirements-dev.txt; elif [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi; fi && if [ -f .pre-commit-config.yaml ]; then uv run pre-commit install; fi'"
}
12 changes: 12 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DB 접속 정보 (컨테이너 네트워크 기준)
DB_USER=admin
DB_PASS=admin
DB_HOST=db
DB_PORT=5432
DB_NAME=dvdrental

# OpenAI
OPENAI_API_KEY=YOUR_OPENAI_API_KEY

# 초기 임베딩 생성: 첫 실행 때만 1, 이후 0
INIT_TABLE_DOCS=0
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
28 changes: 9 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,9 @@ git clone git@github.com:Pseudo-Lab/Query-VendingMachine.git
cd Query-VendingMachine
```
---

>파이썬 가상환경
>개발환경 및 postgres 컨테이너 실행
```
python -m venv .venv
source .venv/bin/activate
```

---
>postgres 컨테이너 실행
```

docker compose up -d
docker compose -f docker/docker-compose.yml up -d
```

---
Expand All @@ -193,7 +184,6 @@ docker exec -it postgres pg_restore -U admin -d dvdrental /tmp/dvdrental.tar

# 테이블 확인
docker exec -it postgres psql -U admin -d dvdrental -c "\dt"

```

---
Expand Down Expand Up @@ -223,23 +213,23 @@ CREATE TABLE table_docs (
```

---
> 패키지 설치
>UV 패키지 설치
```
pip install -r requirements.txt
uv sync
```

---
>text2sql 실행
```
# .env 파일에 OPENAI_API_KEY 입력
# .env.template에 맞게 KEY 입력

# 처음 실행시! (초기 테이블 벡터 임베딩 생성)
INIT_TABLE_DOCS=1 streamlit run main.py
INIT_TABLE_DOCS=1 uv streamlit run main.py

# 두번째부터 실행시
streamlit run main.py
uv streamlit run main.py
```

<!--
---
>테스트를 위한 주피터랩 커널
```
Expand All @@ -251,7 +241,7 @@ python -m ipykernel install --user --name=Query-VendingMachine --display-name="Q

# 실행
jupyter lab
```
``` -->



Expand Down
15 changes: 0 additions & 15 deletions docker-compose.yml

This file was deleted.

36 changes: 36 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Base image
FROM python:3.11-bookworm

# System deps (psycopg2 등 빌드 대비)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
sudo \
vim \
bash-completion \
ca-certificates \
curl \
git \
build-essential \
libpq-dev \
pipx && \
rm -rf /var/lib/apt/lists/*

# Add User
ARG USERNAME=developer
RUN adduser ${USERNAME} && \
echo "${USERNAME} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} && \
chmod 0440 /etc/sudoers.d/${USERNAME}

USER ${USERNAME}
WORKDIR /home/${USERNAME}
# pipx 기본 경로 가용화
ENV PATH="/home/${USERNAME}/.local/bin:${PATH}"

# (옵션) 개인 프로필 파일 복사 경로가 있을 때만 사용
# COPY --chown=${USERNAME} ./docker/dev_profile/* .

# Install uv (via pipx)
RUN pipx ensurepath && pipx install "uv~=0.6"

# Dev 컨테이너는 에디터가 접속해서 명령 내리는 용도
CMD ["bash", "-lc", "sleep infinity"]
41 changes: 41 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: "3.9"

name: devcontainer-query-vendingmachine

services:
db:
image: pgvector/pgvector:pg17
container_name: postgres
hostname: db
restart: always
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
POSTGRES_DB: dvdrental
ports:
- "5432:5432"
volumes:
- ../postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U admin -d dvdrental"]
interval: 5s
timeout: 3s
retries: 20

dev:
build:
context: ..
dockerfile: docker/Dockerfile
container_name: qvm-dev
hostname: api-dev
depends_on:
db:
condition: service_healthy
env_file:
- ../.env
volumes:
- ../:/home/developer/workspace:cached
working_dir: /home/developer/workspace
user: developer
init: true
command: sleep infinity
Loading