feat: security(CORS/API key), OpenAI-compatible endpoint, Paperless hook indexing; .env support

This commit is contained in:
hyungi
2025-08-13 07:36:27 +09:00
parent 325dde803d
commit d17ec57b2e
6 changed files with 164 additions and 6 deletions

View File

@@ -228,6 +228,34 @@ curl -s -X POST http://localhost:26000/paperless/hook \
- `EMBEDDING_MODEL`(기본 `nomic-embed-text`)
- `INDEX_PATH`(기본 `data/index.jsonl`)
- `PAPERLESS_BASE_URL`, `PAPERLESS_TOKEN`(선택): Paperless API 연동 시 사용
- `API_KEY`(선택): 설정 시 모든 민감 엔드포인트 호출에 `X-API-Key` 헤더 필요
- `CORS_ORIGINS`(선택): CORS 허용 오리진(쉼표 구분), 미설정 시 `*`
`.env` 예시:
```bash
AI_SERVER_PORT=26000
OLLAMA_HOST=http://localhost:11434
BASE_MODEL=qwen2.5:7b-instruct
BOOST_MODEL=qwen2.5:14b-instruct
EMBEDDING_MODEL=nomic-embed-text
INDEX_PATH=data/index.jsonl
API_KEY=changeme
CORS_ORIGINS=http://localhost:5173,http://synology.local
```
OpenAI 호환 호출 예시:
```bash
curl -s -X POST http://localhost:26000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: changeme" \
-d '{
"model":"qwen2.5:14b-instruct",
"messages":[{"role":"user","content":"이 서버 기능을 한 줄로 설명"}],
"temperature":0.3
}'
```
## 이 저장소 사용 계획