Skip to content

Commit 37c5977

Browse files
resolved issue with factcheck tests
1 parent fb59246 commit 37c5977

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

nemoguardrails/library/autoguard/actions.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from nemoguardrails.actions.actions import ActionResult
2525
from nemoguardrails.kb.kb import KnowledgeBase
2626
from nemoguardrails.llm.taskmanager import LLMTaskManager
27-
from nemoguardrails.logging.verbose import Styles
2827

2928
log = logging.getLogger(__name__)
3029

@@ -226,13 +225,11 @@ async def autoguard_input_api(
226225
)
227226
if autoguard_response["guardrails_triggered"] and show_autoguard_message:
228227
print(
229-
Styles.YELLOW,
230228
f"AutoGuard on Input: {autoguard_response['combined_response']}",
231229
)
232230
else:
233231
if autoguard_response["pii_fast"]["guarded"] and show_autoguard_message:
234232
print(
235-
Styles.YELLOW,
236233
f"AutoGuard on Input: {autoguard_response['pii_fast']['response']}",
237234
)
238235

@@ -262,7 +259,6 @@ async def autoguard_output_api(
262259
)
263260
if autoguard_response["guardrails_triggered"] and show_autoguard_message:
264261
print(
265-
Styles.YELLOW,
266262
f"AutoGuard on LLM Response: {autoguard_response['combined_response']}",
267263
)
268264

tests/test_autoguard_factcheck.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ async def retrieve_relevant_chunks():
4747
)
4848

4949

50+
@action(is_system_action=True)
51+
async def autoguard_retrieve_relevant_chunks_input():
52+
"""Retrieve relevant chunks from the knowledge base and add them to the context."""
53+
context_updates = {}
54+
relevant_chunks = "\n".join(build_kb())
55+
context_updates["relevant_chunks"] = relevant_chunks
56+
57+
return ActionResult(
58+
return_value=context_updates["relevant_chunks"],
59+
context_updates=context_updates,
60+
)
61+
62+
5063
@pytest.mark.asyncio
5164
async def test_fact_checking_correct(httpx_mock):
5265
config = RailsConfig.from_path(os.path.join(CONFIGS_FOLDER, "autoguard_factcheck"))

0 commit comments

Comments
 (0)