Skip to content

Commit bfbaa5d

Browse files
committed
fix test error
Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
1 parent 1e1f039 commit bfbaa5d

3 files changed

Lines changed: 12 additions & 18 deletions

File tree

docs/examples/citation_requirement_example.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,3 @@ async def main():
9898

9999
if __name__ == "__main__":
100100
asyncio.run(main())
101-
102-
# Made with Bob

mellea/stdlib/requirements/rag.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ async def validate(
192192

193193
context_before_response = ChatContext()
194194

195+
# Handle empty response before calling intrinsic
196+
total_chars = len(response)
197+
if total_chars == 0:
198+
return ValidationResult(
199+
True, reason="Empty response has 100% citation coverage", score=1.0
200+
)
201+
195202
# Call find_citations intrinsic
196203
try:
197204
# Import here to avoid circular dependency
@@ -206,11 +213,6 @@ async def validate(
206213
)
207214

208215
# Calculate citation coverage
209-
total_chars = len(response)
210-
if total_chars == 0:
211-
return ValidationResult(
212-
True, reason="Empty response has 100% citation coverage", score=1.0
213-
)
214216

215217
cited_chars = sum(
216218
citation["response_end"] - citation["response_begin"]
@@ -336,6 +338,3 @@ def citation_check(
336338
documents=documents,
337339
description=description,
338340
)
339-
340-
341-
# Made with Bob

test/stdlib/requirements/test_rag.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@pytest.mark.requires_heavy_ram
1515
async def test_citation_requirement_basic():
1616
"""Test basic citation requirement functionality."""
17-
backend = LocalHFBackend(model_id="meta-llama/Llama-3.2-1B-Instruct")
17+
backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
1818

1919
# Create documents
2020
docs = [
@@ -46,7 +46,7 @@ async def test_citation_requirement_basic():
4646
@pytest.mark.requires_heavy_ram
4747
async def test_citation_requirement_with_constructor_documents():
4848
"""Test citation requirement with documents in constructor."""
49-
backend = LocalHFBackend(model_id="meta-llama/Llama-3.2-1B-Instruct")
49+
backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
5050

5151
# Create documents
5252
docs = [
@@ -77,7 +77,7 @@ async def test_citation_requirement_with_constructor_documents():
7777
@pytest.mark.requires_heavy_ram
7878
async def test_citation_check_factory():
7979
"""Test citation_check factory function."""
80-
backend = LocalHFBackend(model_id="meta-llama/Llama-3.2-1B-Instruct")
80+
backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
8181

8282
# Create documents
8383
docs = [Document(doc_id="doc1", text="The sky is blue during the day.")]
@@ -241,7 +241,7 @@ def test_citation_requirement_default_description():
241241
@pytest.mark.requires_heavy_ram
242242
async def test_citation_requirement_empty_response():
243243
"""Test citation requirement with empty response."""
244-
backend = LocalHFBackend(model_id="meta-llama/Llama-3.2-1B-Instruct")
244+
backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
245245

246246
# Create documents
247247
docs = [Document(doc_id="doc1", text="The sky is blue.")]
@@ -266,7 +266,7 @@ async def test_citation_requirement_empty_response():
266266
@pytest.mark.requires_heavy_ram
267267
async def test_citation_requirement_threshold_boundary():
268268
"""Test citation requirement at exact threshold boundary."""
269-
backend = LocalHFBackend(model_id="meta-llama/Llama-3.2-1B-Instruct")
269+
backend = LocalHFBackend(model_id="ibm-granite/granite-4.0-micro")
270270

271271
# Create documents
272272
docs = [Document(doc_id="doc1", text="The sky is blue during the day.")]
@@ -293,6 +293,3 @@ async def test_citation_requirement_threshold_boundary():
293293
assert result.as_bool()
294294
else:
295295
assert not result.as_bool()
296-
297-
298-
# Made with Bob

0 commit comments

Comments
 (0)