@@ -5,10 +5,10 @@ const { Agent, Runner, Tool, Guardrail } = require('../src/index');
55const inappropriateContentGuardrail = new Guardrail . Input ( {
66 name : "inappropriate_content_filter" ,
77 check : async ( context , agent , input ) => {
8+
89 // In a real implementation, you might use a content moderation API
910 // Here we're just doing a simple check for demonstration
10- const message = typeof input === 'string' ? input :
11- ( input [ 0 ] ?. content || '' ) ;
11+ const message = typeof input === 'string' ? input : ( input [ 0 ] ?. content || '' ) ;
1212
1313 const inappropriateWords = [ 'hate' , 'violence' , 'explicit' ] ;
1414 const containsInappropriate = inappropriateWords . some ( word =>
@@ -25,21 +25,6 @@ const minimumLengthGuardrail = new Guardrail.Output({
2525 check : async ( context , agent , output ) => {
2626 const minimumLength = 20 ; // characters
2727
28- // Safely handle null/undefined output
29- if ( ! output ) {
30- return {
31- output_info : {
32- checked_for : "minimum length" ,
33- required_length : minimumLength ,
34- actual_length : 0 ,
35- is_too_short : true ,
36- error : "Output is null or undefined"
37- } ,
38- tripwire_triggered : true
39- } ;
40- }
41-
42- // Convert output to string if it isn't already
4328 const outputStr = String ( output ) ;
4429 const isTooShort = outputStr . length < minimumLength ;
4530
0 commit comments