Spaces:
Running
Running
Deploy 17930aef
Browse files- Dockerfile +7 -4
- eval_data/ragas_eval.py +4 -2
- requirements.txt +6 -1
Dockerfile
CHANGED
|
@@ -49,7 +49,8 @@ RUN pip install --no-cache-dir \
|
|
| 49 |
langchain-groq \
|
| 50 |
langfuse \
|
| 51 |
langchain-google-genai \
|
| 52 |
-
"ragas>=0.
|
|
|
|
| 53 |
litellm
|
| 54 |
|
| 55 |
# -- Stage 2: Runtime (default) -----------------------------------------------
|
|
@@ -73,9 +74,11 @@ COPY --from=builder /usr/local/bin /usr/local/bin
|
|
| 73 |
COPY . .
|
| 74 |
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
| 75 |
|
| 76 |
-
# Install ragas+litellm as fallback in case multi-stage COPY missed them
|
| 77 |
-
#
|
| 78 |
-
|
|
|
|
|
|
|
| 79 |
|
| 80 |
# Non-root user
|
| 81 |
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app \
|
|
|
|
| 49 |
langchain-groq \
|
| 50 |
langfuse \
|
| 51 |
langchain-google-genai \
|
| 52 |
+
"ragas>=0.4,<0.5" \
|
| 53 |
+
"langchain-community>=0.4.1,<0.4.2" \
|
| 54 |
litellm
|
| 55 |
|
| 56 |
# -- Stage 2: Runtime (default) -----------------------------------------------
|
|
|
|
| 74 |
COPY . .
|
| 75 |
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
| 76 |
|
| 77 |
+
# Install ragas+litellm as fallback in case multi-stage COPY missed them.
|
| 78 |
+
# ragas 0.4.x keeps the single_turn_score API used by the code; langchain-community
|
| 79 |
+
# must stay <0.4.2 (0.4.2 removed chat_models.vertexai, which ragas imports at
|
| 80 |
+
# startup — previously masked as "ragas not installed").
|
| 81 |
+
RUN pip install --no-cache-dir "ragas>=0.4,<0.5" "langchain-community>=0.4.1,<0.4.2" litellm
|
| 82 |
|
| 83 |
# Non-root user
|
| 84 |
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app \
|
eval_data/ragas_eval.py
CHANGED
|
@@ -349,8 +349,10 @@ def _compute_mmr(
|
|
| 349 |
f"Answer with exactly one word: YES or NO"
|
| 350 |
)
|
| 351 |
# Use the wrapped LangChain model for fast synchronous invoke.
|
| 352 |
-
# LangchainLLMWrapper stores the
|
| 353 |
-
|
|
|
|
|
|
|
| 354 |
response_text = raw.content.strip().upper() if hasattr(raw, "content") else str(raw).strip().upper()
|
| 355 |
if response_text.startswith("Y"):
|
| 356 |
return 1.0 / rank
|
|
|
|
| 349 |
f"Answer with exactly one word: YES or NO"
|
| 350 |
)
|
| 351 |
# Use the wrapped LangChain model for fast synchronous invoke.
|
| 352 |
+
# LangchainLLMWrapper stores the model as .langchain_llm in ragas
|
| 353 |
+
# 0.4.x and as .llm in 0.3.x — accept both.
|
| 354 |
+
langchain_model = getattr(llm, "langchain_llm", None) or getattr(llm, "llm", None)
|
| 355 |
+
raw = langchain_model.invoke(prompt)
|
| 356 |
response_text = raw.content.strip().upper() if hasattr(raw, "content") else str(raw).strip().upper()
|
| 357 |
if response_text.startswith("Y"):
|
| 358 |
return 1.0 / rank
|
requirements.txt
CHANGED
|
@@ -12,5 +12,10 @@ chromadb==1.5.8
|
|
| 12 |
langsmith>=0.7
|
| 13 |
langfuse>=4.13,<5
|
| 14 |
requests-cache>=1.2
|
| 15 |
-
ragas
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
litellm
|
|
|
|
| 12 |
langsmith>=0.7
|
| 13 |
langfuse>=4.13,<5
|
| 14 |
requests-cache>=1.2
|
| 15 |
+
# ragas 0.4.x keeps the single_turn_score API used by eval_data/ragas_eval.py.
|
| 16 |
+
# langchain-community must stay <0.4.2: ragas imports
|
| 17 |
+
# langchain_community.chat_models.vertexai at startup, and 0.4.2 removed that
|
| 18 |
+
# module (the app then misreports it as "ragas not installed").
|
| 19 |
+
ragas>=0.4,<0.5
|
| 20 |
+
langchain-community>=0.4.1,<0.4.2
|
| 21 |
litellm
|