# 로컬 개발 — exdev AI 연동 로컬에서 **chatbotApi · chatbotApp · exAiChatBot · kakaoChatbotSkill** 을 실행하고, **LLM / Embedding / Reranker** 는 SSH 터널로, **MongoDB / Qdrant** 는 `stock.exdev.co.kr` 원격 인스턴스를 사용합니다. ## exdev AI 구조 | 포트 | 서비스 | API | |------|--------|-----| | 16000 | MLX LLM | `/v1/chat/completions` | | 16001 | Embedding (MPS) | `/embed` (`EMBED_API_STYLE=tei`) | | 16002 | Reranker | `/rerank` (`RERANK_API_STYLE=legacy`) | `https://chatbot.exdev.co.kr` 은 RAG API URL이며 LLM 직접 URL이 아닙니다. ## 한 번에 기동 / 중지 ```bash chmod +x local-dev/*.sh ./local-dev/stop-all.sh # 먼저 중지 ./local-dev/start-all.sh # 전체 기동 + 헬스체크 # 옵션 ./local-dev/start-all.sh --no-tunnel # AI 터널이 이미 떠 있을 때 ./local-dev/start-all.sh --skip-java # Docker(RAG + chatbotApp)만 ./local-dev/start-all.sh --no-build # RAG 이미지 빌드 생략 ./local-dev/stop-all.sh --tunnel # SSH 터널까지 종료 ``` - RAG는 **`docker-compose.local.yml`** 사용 (Mac Docker `:28012` 포트 바인딩) - Mongo: `stock.exdev.co.kr:27017` / Qdrant: `http://stock.exdev.co.kr:6333/dashboard` - 로컬 Mongo·Qdrant 컨테이너는 기동하지 않습니다 기동 후 UI: `http://localhost:8089/chatbot/app/` --- ## 1. exdev AI 기동 (서버에서 한 번) exdev SSH 접속 후: ```bash bash /Users/aidev/dev/exAIChatbot2.0/scripts/exdev/start-host-ai.sh curl -s http://127.0.0.1:28012/health # llm/tei_embed/tei_rerank: true 확인 ``` ## 2. 로컬 SSH 터널 ```bash chmod +x local-dev/start-exdev-ai-tunnel.sh ./local-dev/start-exdev-ai-tunnel.sh ``` 터널 확인: ```bash curl -s http://127.0.0.1:16000/v1/models | head curl -s http://127.0.0.1:16001/health curl -s -X POST http://127.0.0.1:16002/rerank \ -H 'Content-Type: application/json' \ -d '{"query":"test","documents":["doc"]}' ``` ## 3. exAiChatBot .env ```bash cp local-dev/env.exdev-ai.template exAiChatBot-chatbot2.0-agent/.env ./local-dev/start-all.sh --skip-java --no-build # RAG만 (원격 Mongo/Qdrant) curl -s http://127.0.0.1:28012/health ``` RAG 컨테이너는 `.env` 의 `MONGO_HOST` / `QDRANT_HOST` (= `stock.exdev.co.kr`) 로 원격 DB에 접속합니다. ## 4. Java 서비스 + chatbotApp ```bash # WAS (Mongo → stock.exdev.co.kr) cd chatbotApi-chatbot2.0-agent export INTERNAL_TOOL_API_KEY=local-dev-key export MONGODB_URI='mongodb://exDev:ehfhrhdtk!!@stock.exdev.co.kr:27017/chatbot?authSource=chatbot' export SKILL_INTERNAL_BASE_URL=http://127.0.0.1:8083 ./gradlew bootRun # Skill cd kakaoChatbotSkill-chatbot2.0-agent export AGENT_MODE=agent export RAG_AGENT_CHAT_URL=http://127.0.0.1:28012/agent/chat export CHATBOT_API_BASE_URL=http://127.0.0.1:8086/api/ export INTERNAL_TOOL_API_KEY=local-dev-key ./gradlew bootRun # UI cd chatbotApp-chatbot2.0-agent CHATBOT_API_UPSTREAM=http://host.docker.internal:8083/web/ \ CHATBOT_API_HOST=host.docker.internal ./start.sh ``` ## api_clients.py 스타일 변수 | 변수 | exdev 값 | 설명 | |------|----------|------| | `EMBED_API_STYLE` | `tei` | `/embed` | | `RERANK_API_STYLE` | `legacy` | `/rerank` | | `EMBED_API_STYLE` | `openai` | 게이트웨이 `/v1/embeddings` | | `RERANK_API_STYLE` | `gateway` | 게이트웨이 `/score` | 로컬 exdev 연동 시 **`tei` + `legacy`** 조합을 사용합니다.