192.168.219.45 → 192.168.0.100 일괄 변경 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4.0 KiB
4.0 KiB
skill-rag-file RAG 시스템 초기 구축
작성일: 2025-09-15
작성자: Claude (51123 서버 관리자)
관련 문서:
1. 구현 사항
PostgreSQL 테이블 생성 (51123)
- 테이블명: team_document
- 주요 컬럼: team_id, filename, file_hash, storage_path, text_content, metadata
- 인덱스: idx_team_doc_hash (team_id, file_hash) UNIQUE
- 외래키: team_id → team(id)
- metadata 활용: uploaded_by를 JSONB에 저장 (삼각형 의존성 회피)
파일 저장 구조 설정
- 51123 디렉토리: /mnt/hdd/data/documents/
- 51124 마운트: /mnt/51123data/ (SSHFS)
- SSHFS 명령 (초기):
sshfs -o IdentityFile=/home/admin/.ssh/id_rsa_deploy,reconnect,uid=$(id -u),gid=$(id -g) admin@192.168.0.100:/mnt/hdd/data /mnt/51123data -p 51123 - SSHFS 명령 (2025-10-14 수정):
sshfs -o allow_other,default_permissions,IdentityFile=/home/admin/.ssh/id_rsa_deploy,reconnect,uid=1001,gid=1000 admin@192.168.0.100:/mnt/hdd/data /mnt/51123data -p 51123 - 권한: admin:xusers (읽기/쓰기 가능)
- 주의: allow_other 사용 시 /etc/fuse.conf에 user_allow_other 필요
서비스 구성
- Gitea 레포: https://git.ro-being.com/ivada_Ro-being/skill-rag-file
- 프로젝트 구조: app/{api,core,models,services,utils} 디렉토리만 생성, 구현 파일 없음
2. 핵심 결정 사항
저장 위치 변경
- 기존 계획: /mnt/hdd/uploads/
- 변경: /mnt/hdd/data/documents/ (업계 표준 준수)
- 이유: data/ 구조가 더 확장 가능 (logs/, models/ 추가 가능)
uploaded_by 처리
- 문제: user → team, team_document → team, team_document → user (삼각형)
- 해결: uploaded_by 컬럼 제거, metadata JSONB에 기록
- 조회:
metadata->>'uploaded_by'
SSHFS 활용
- 기존: /mnt/51123logs (로그 전용)
- 추가: /mnt/51123data (데이터/문서 전용)
- 장점: 51124 로컬 쓰기 → 51123 HDD 직접 저장
3. 확인된 시스템 정보
51124 서버 환경
- SSHFS 마운트: /mnt/51123data → 192.168.0.100:/mnt/hdd/data
- documents 디렉토리: /mnt/51123data/documents/ 존재
- ChromaDB: 0.5.20 설치됨
ChromaDB 연결 정보
- 호스트: localhost
- 포트: 8000
skill-embedding 서비스
- URL: http://localhost:8515
- 엔드포인트: POST /embed
- 요청 형식: {"texts": ["텍스트1", "텍스트2"]}
- 응답 형식: {"embeddings": ..., "model": "...", "dimensions": 768}
- 최대 배치: 100개 텍스트
Docker 패턴 (기존 스킬 참조)
- skill-email 방식: network_mode: host
- skill-news 방식: ports 매핑, robeing-network
- 헬스체크: curl http://localhost:[PORT]/health
FastAPI 패턴 (기존 서비스 참조)
- 미들웨어: CORSMiddleware (allow_origins=["*"])
- 환경변수: load_dotenv() 사용
- lifespan: 컨텍스트 매니저 패턴
미설치 라이브러리
- PyPDF2: 현재 미설치
- python-docx: 현재 미설치
Slack 통합 고려사항
- 파일 수신: Slack 봇 files:read 스코프 필요
- 토큰: slack_workspace 테이블 bot_token 사용
- 기존 연동: rb8001/rb10508이 Slack 메시지 처리 중
- 통합 방식: rb8001에서 호출 또는 직접 이벤트 수신 필요
4. 확정 사항
| 항목 | 확정값 |
|---|---|
| 포트 | 8508 |
| 헬스체크 | /healthz |
| 컬렉션명 | rb8001_{team_id}_documents |
| 엔드포인트 | /upload, /search, /healthz |
| 저장 경로 | /mnt/51123data/documents/{team_id}/YYYY-MM/ |
5. 다음 단계
- FastAPI 서버 구현 (app/ 디렉토리 내 실제 코드 작성)
- PyPDF2, python-docx 설치 및 텍스트 추출 구현
- ChromaDB rb8001_{team_id}_documents 컬렉션 연동
- Slack 파일 수신 로직 구현 또는 rb8001 연동
- Docker 컨테이너화 (포트 8508)