Skip to content

Commit 3ca565f

Browse files
minor fixes and proper packaging
1 parent 3a4965a commit 3ca565f

File tree

6 files changed

+16
-24
lines changed

6 files changed

+16
-24
lines changed

detectors/Dockerfile.judge

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ RUN microdnf update -y && \
44
python-pip python-devel && \
55
pip install --upgrade --no-cache-dir pip wheel && \
66
microdnf clean all
7-
RUN pip install --no-cache-dir torch
87

9-
# FROM icr.io/fm-stack/ubi9-minimal-py39-torch as builder
108
FROM base as builder
119

1210
COPY ./common/requirements.txt .
@@ -20,12 +18,13 @@ FROM builder
2018
WORKDIR /app
2119
ARG CACHEBUST=1
2220
RUN echo "$CACHEBUST"
23-
COPY ./common /common
24-
COPY ./llm_judge/app.py /app
25-
COPY ./llm_judge/detector.py /app
26-
COPY ./llm_judge/scheme.py /app
21+
COPY ./common /app/detectors/common
22+
COPY ./llm_judge/app.py /app/detectors/llm_judge/app.py
23+
COPY ./llm_judge/detector.py /app/detectors/llm_judge/detector.py
24+
COPY ./llm_judge/scheme.py /app/detectors/llm_judge/scheme.py
25+
RUN touch /app/detectors/llm_judge/__init__.py
2726

2827
EXPOSE 8000
29-
CMD ["uvicorn", "app:app", "--workers", "4", "--host", "0.0.0.0", "--port", "8000", "--log-config", "/common/log_conf.yaml"]
28+
CMD ["uvicorn", "detectors.llm_judge.app:app", "--workers", "4", "--host", "0.0.0.0", "--port", "8000", "--log-config", "/app/detectors/common/log_conf.yaml"]
3029

3130
# gunicorn main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000

detectors/__init__.py

Whitespace-only changes.

detectors/llm_judge/app.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import os
2-
import sys
31
from contextlib import asynccontextmanager
42
from typing import Annotated, Dict
53

64
from fastapi import Header
75
from prometheus_fastapi_instrumentator import Instrumentator
8-
sys.path.insert(0, os.path.abspath(".."))
96

10-
from common.app import DetectorBaseAPI as FastAPI
11-
from .detector import LLMJudgeDetector
12-
from .scheme import (
7+
from detectors.common.app import DetectorBaseAPI as FastAPI
8+
from detectors.llm_judge.detector import LLMJudgeDetector
9+
from detectors.llm_judge.scheme import (
1310
ContentAnalysisHttpRequest,
1411
ContentsAnalysisResponse,
1512
MetricsListResponse,

detectors/llm_judge/deploy/servingruntime.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ spec:
1717
name: guardrails-detector-llm-judge
1818
containers:
1919
- name: kserve-container
20-
image: quay.io/rh-ee-spandraj/guardrails-detector-judge:latest
20+
image: quay.io/spandraj/guardrails-detector-judge:latest
2121
command:
2222
- uvicorn
23-
- app:app
23+
- detectors.llm_judge.app:app
2424
args:
2525
- "--workers"
2626
- "1"
@@ -29,7 +29,7 @@ spec:
2929
- "--port"
3030
- "8000"
3131
- "--log-config"
32-
- "/common/log_conf.yaml"
32+
- "/app/detectors/common/log_conf.yaml"
3333
env:
3434
- name: VLLM_BASE_URL
3535
value: "http://qwen2-predictor:8080" # <-- Change this to your vLLM URL

detectors/llm_judge/detector.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import os
2-
import sys
32
from typing import List, Dict, Any
43

5-
sys.path.insert(0, os.path.abspath(".."))
6-
74
from vllm_judge import Judge, EvaluationResult, BUILTIN_METRICS
85
from vllm_judge.exceptions import MetricNotFoundError
9-
from common.app import logger
10-
from .scheme import (
6+
from detectors.common.app import logger
7+
from detectors.llm_judge.scheme import (
118
ContentAnalysisHttpRequest,
129
ContentAnalysisResponse,
1310
ContentsAnalysisResponse,
@@ -24,7 +21,6 @@ def __init__(self) -> None:
2421

2522
# Get configuration from environment
2623
self.vllm_base_url = os.environ.get("VLLM_BASE_URL")
27-
self.vllm_model = os.environ.get("VLLM_MODEL")
2824

2925
if not self.vllm_base_url:
3026
raise ValueError("VLLM_BASE_URL environment variable is required")

detectors/llm_judge/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
vllm-judge>=0.1.5
2-
pyyaml>=6.0.2
1+
vllm-judge==0.1.6
2+
pyyaml==6.0.2

0 commit comments

Comments
 (0)