- rb8001 파일 처리 로직 구현 완료 - skill-rag-file DB 모델 동기화 완료 - 남은 작업: Slack team_id → DB UUID 매핑 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
4.1 KiB
4.1 KiB
rb8001-skill-rag-file Slack 파일 처리 연동 구조
작성일: 2025-09-16
작성자: Claude (51123 서버 관리자)
1. 현재 상황
확인된 상태
- team_document 테이블: 생성 완료 (51123 PostgreSQL)
- processing_status, chunk_count, mime_type, file_size 컬럼 포함
- idx_team_doc_hash 유니크 인덱스 생성됨
- 파일 저장 디렉터리: /mnt/hdd/data/documents/ 생성 완료
- slack_workspace: 2개 팀 등록, bot_token 보유
- Robeing (T0925SXPS4D)
- Company-X Team (T09C98KB933)
- Slack 스코프: files:read 포함 (설치 URL에서 확인)
구현 완료 (2025-09-16)
- rb8001: 파일 처리 로직 추가됨
- slack_handler.py:286-288: 파일 있으면 process_slack_files_async() 호출
- slack_handler.py:50-97: Slack API로 파일 다운로드 후 skill-rag-file 전송
- 임시 team_id 사용 중 (TODO: Slack team_id → DB UUID 매핑)
skill-rag-file 구현 상태 (51124)
- 구현 완료: app/main.py, api/{upload.py,search.py}, services/* (텍스트 추출/청킹/임베딩/ChromaDB)
- DB 모델: 실제 테이블과 동기화 완료 (file_size, mime_type, chunk_count, processing_status 추가)
- 기본 경로: DOCUMENT_BASE_PATH=/mnt/51123data/documents (app/core/config.py)
2. 실제 메시지 플로우 (확인됨)
현재 Slack 메시지 처리 경로
Slack Event API
↓
nginx (51123)
↓
robeing-gateway (51123)
- team_id에서 bot_token 조회 (slack_workspace 테이블)
- Slack user ID → UUID 변환
- 헤더 추가: X-Slack-Bot-Token, X-User-Id
↓
rb8001:8001 (51124)
/api/slack/events
- slack_endpoint.py → slack_handler.py
- handle_slack_events()에서 파일 추출
- asyncio.create_task(process_slack_message_async())로 비동기 처리
↓
brain_service/llm_service (파일 처리 없이 텍스트만 처리)
## 3. rb8001 파일 처리 현황 (51124)
### 구현 완료 코드
- **파일 추출**: rb8001/app/router/slack_handler.py:244
- **파일 처리 호출**: 286-288행에서 process_slack_files_async() 비동기 호출
- **파일 다운로드 및 전송**: 50-97행 process_slack_files_async() 함수
- Slack API로 파일 다운로드 (bot_token 사용)
- skill-rag-file:8508/api/upload로 전송
- 임시 team UUID 사용 중
## 4. skill-rag-file 현황 (51124)
### API 엔드포인트 (구현됨)
- POST /api/upload: 파일 업로드
- POST /api/search: 검색 (GET 아님)
- GET /api/search/collections: 컬렉션 목록
- GET /healthz: 헬스체크
### 네트워크 연결 상태
- rb8001 → skill-rag-file:8508: 연결 가능 (확인됨)
- 컨테이너 네트워크: host 모드 사용
## 5. 데이터베이스 상태 (51123 PostgreSQL)
### team_document 테이블 상태
**PostgreSQL 실제 테이블** (file_size, mime_type, chunk_count, processing_status 포함):
```sql
id UUID PRIMARY KEY DEFAULT gen_random_uuid()
team_id UUID NOT NULL REFERENCES team(id)
filename VARCHAR(255) NOT NULL
file_hash VARCHAR(64) NOT NULL
file_size BIGINT
mime_type VARCHAR(100)
storage_path TEXT NOT NULL
text_content TEXT
chunk_count INTEGER DEFAULT 0
processing_status VARCHAR(20) DEFAULT 'pending'
metadata JSONB DEFAULT '{}'
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
skill-rag-file 코드 모델 (app/models/database.py - 수정 완료):
# 실제 테이블과 동기화됨
id, team_id, filename, file_hash, file_size, mime_type,
storage_path, text_content, chunk_count, processing_status,
metadata, created_at, updated_at
6. 확인 완료 사항
- ✅ team_document 테이블 생성됨 (코드 모델 동기화 완료)
- ✅ /mnt/hdd/data/documents/ 디렉터리 생성됨
- ✅ Slack bot_token 2개 팀 보유 (Robeing, Company-X Team)
- ✅ files:read 스코프 포함
- ✅ rb8001 → skill-rag-file:8508 네트워크 연결 가능
- ✅ rb8001 파일 처리 로직 구현됨
- ✅ skill-rag-file DB 모델 동기화 완료
7. 남은 작업
- Slack team_id → DB team UUID 매핑 (현재 임시 UUID 사용)