File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
nemoguardrails/library/autoguard Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 24
24
from nemoguardrails .actions .actions import ActionResult
25
25
from nemoguardrails .kb .kb import KnowledgeBase
26
26
from nemoguardrails .llm .taskmanager import LLMTaskManager
27
- from nemoguardrails .logging .verbose import Styles
28
27
29
28
log = logging .getLogger (__name__ )
30
29
@@ -226,13 +225,11 @@ async def autoguard_input_api(
226
225
)
227
226
if autoguard_response ["guardrails_triggered" ] and show_autoguard_message :
228
227
print (
229
- Styles .YELLOW ,
230
228
f"AutoGuard on Input: { autoguard_response ['combined_response' ]} " ,
231
229
)
232
230
else :
233
231
if autoguard_response ["pii_fast" ]["guarded" ] and show_autoguard_message :
234
232
print (
235
- Styles .YELLOW ,
236
233
f"AutoGuard on Input: { autoguard_response ['pii_fast' ]['response' ]} " ,
237
234
)
238
235
@@ -262,7 +259,6 @@ async def autoguard_output_api(
262
259
)
263
260
if autoguard_response ["guardrails_triggered" ] and show_autoguard_message :
264
261
print (
265
- Styles .YELLOW ,
266
262
f"AutoGuard on LLM Response: { autoguard_response ['combined_response' ]} " ,
267
263
)
268
264
Original file line number Diff line number Diff line change @@ -47,6 +47,19 @@ async def retrieve_relevant_chunks():
47
47
)
48
48
49
49
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
+
50
63
@pytest .mark .asyncio
51
64
async def test_fact_checking_correct (httpx_mock ):
52
65
config = RailsConfig .from_path (os .path .join (CONFIGS_FOLDER , "autoguard_factcheck" ))
You can’t perform that action at this time.
0 commit comments