Spaces:
Running
Running
feat: ground RAGAS on PR diff when retrieval is disabled
Browse files
app.py
CHANGED
|
@@ -432,10 +432,15 @@ _ragas_lock = threading.Lock()
|
|
| 432 |
def _ragas_inputs_from_state(state, endpoint_name: str) -> dict | None:
|
| 433 |
"""Extract the inputs RAGAS needs from the finished graph state."""
|
| 434 |
context_chunks = state.values.get("context_chunks", [])
|
| 435 |
-
if not context_chunks:
|
| 436 |
-
return None
|
| 437 |
query = state.values.get("diff", "") or ""
|
| 438 |
contexts = [c.content for c in context_chunks if c.content]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
# Build answer text from findings + verdict for
|
| 441 |
# faithfulness & answer_relevancy metrics
|
|
|
|
| 432 |
def _ragas_inputs_from_state(state, endpoint_name: str) -> dict | None:
|
| 433 |
"""Extract the inputs RAGAS needs from the finished graph state."""
|
| 434 |
context_chunks = state.values.get("context_chunks", [])
|
|
|
|
|
|
|
| 435 |
query = state.values.get("diff", "") or ""
|
| 436 |
contexts = [c.content for c in context_chunks if c.content]
|
| 437 |
+
# When vector retrieval is disabled on a small host, evaluate against the
|
| 438 |
+
# PR diff itself. This preserves a grounded context for RAGAS instead of
|
| 439 |
+
# silently dropping quality measurement altogether.
|
| 440 |
+
if not contexts and query:
|
| 441 |
+
contexts = [query]
|
| 442 |
+
if not contexts:
|
| 443 |
+
return None
|
| 444 |
|
| 445 |
# Build answer text from findings + verdict for
|
| 446 |
# faithfulness & answer_relevancy metrics
|