Skip to content

Commit

Permalink
* deployment of the API
Browse files Browse the repository at this point in the history
  • Loading branch information
asofter committed May 10, 2024
1 parent 5c8e815 commit 547602f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/api/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ This will start the API on port 8000. You can now access the API at `http://loca
If you want to use a custom configuration, you can mount a volume to `/home/user/app/config`:

```bash
docker run -d -p 8000:8000 -e LOG_LEVEL='INFO' -v ./config:/home/user/app/config laiyer/llm-guard-api:latest
docker run -d -p 8000:8000 -e APP_WORKERS=1 -e AUTH_TOKEN='my-token' -e LOG_LEVEL='DEBUG' -v ./entrypoint.sh:/home/user/app/entrypoint.sh -v ./config/scanners.yml:/home/user/app/config/scanners.yml laiyer/llm-guard-api:latest
```

!!! warning
Expand Down
2 changes: 2 additions & 0 deletions llm_guard_api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ COPY --chown=user:user entrypoint.sh ./entrypoint.sh

RUN chmod +x ./entrypoint.sh

ENV PYTHONPATH=$HOME/app

EXPOSE 8000

ENTRYPOINT ["./entrypoint.sh"]
2 changes: 2 additions & 0 deletions llm_guard_api/Dockerfile-cuda
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ COPY --chown=user:user entrypoint.sh ./entrypoint.sh

RUN chmod +x ./entrypoint.sh

ENV PYTHONPATH=$HOME/app

EXPOSE 8000

ENTRYPOINT ["./entrypoint.sh"]
4 changes: 2 additions & 2 deletions llm_guard_api/config/scanners.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
app:
name: ${APP_NAME:LLM Guard API}
log_level: ${LOG_LEVEL:INFO}
log_json: ${LOG_JSON:false}
log_json: ${LOG_JSON:true}
scan_fail_fast: ${SCAN_FAIL_FAST:false}
scan_prompt_timeout: ${SCAN_PROMPT_TIMEOUT:30}
scan_output_timeout: ${SCAN_OUTPUT_TIMEOUT:30}
lazy_load: ${LAZY_LOAD:false}
lazy_load: ${LAZY_LOAD:true}

cache:
ttl: ${CACHE_TTL:3600}
Expand Down
6 changes: 5 additions & 1 deletion llm_guard_api/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

APP_WORKERS=${APP_WORKERS:-1}

gunicorn --workers "$APP_WORKERS" --preload --worker-class uvicorn.workers.UvicornWorker 'app.app:create_app(config_file="./config/scanners.yml")'
# Uvicorn
# llm_guard_api ./config/scanners.yml

# Gunicorn
gunicorn --workers "$APP_WORKERS" --bind 0.0.0.0:8000 --preload --worker-class uvicorn.workers.UvicornWorker 'app.app:create_app(config_file="./config/scanners.yml")'

0 comments on commit 547602f

Please sign in to comment.