@@ -17,13 +17,25 @@ use crate::plugin::{
1717 lookup_plugin, register_plugin,
1818} ;
1919
20+ #[ cfg( all( feature = "guardrails-remote" , not( target_arch = "wasm32" ) ) ) ]
2021#[ path = "remote.rs" ]
2122mod remote;
23+ #[ cfg( all( feature = "guardrails-remote" , not( target_arch = "wasm32" ) ) ) ]
2224use remote:: register_remote_backend;
2325
2426/// The plugin kind reserved for the planned first-party component.
2527pub const NEMO_GUARDRAILS_PLUGIN_KIND : & str = "nemo_guardrails" ;
2628
29+ #[ cfg( any( target_arch = "wasm32" , not( feature = "guardrails-remote" ) ) ) ]
30+ fn register_remote_backend (
31+ _config : NeMoGuardrailsConfig ,
32+ _ctx : & mut PluginRegistrationContext ,
33+ ) -> PluginResult < ( ) > {
34+ Err ( PluginError :: RegistrationFailed (
35+ "built-in NeMo Guardrails remote backend is unavailable in this build" . to_string ( ) ,
36+ ) )
37+ }
38+
2739/// Top-level NeMo Guardrails component wrapper.
2840#[ derive( Debug , Clone ) ]
2941pub struct ComponentSpec {
@@ -941,30 +953,27 @@ fn validate_request_defaults(
941953 "request_defaults.context" ,
942954 "request_defaults.context must be a JSON object" ,
943955 ) ;
944- if let Some ( thread_id) = & request_defaults. thread_id
945- && thread_id. trim ( ) . is_empty ( )
946- {
947- push_policy_diag (
948- diagnostics,
949- policy. unsupported_value ,
950- "nemo_guardrails.unsupported_value" ,
951- Some ( NEMO_GUARDRAILS_PLUGIN_KIND . to_string ( ) ) ,
952- Some ( "request_defaults.thread_id" . to_string ( ) ) ,
953- "request_defaults.thread_id must not be empty" . to_string ( ) ,
954- ) ;
955- }
956- if let Some ( thread_id) = & request_defaults. thread_id
957- && !thread_id. trim ( ) . is_empty ( )
958- && thread_id. len ( ) < 16
959- {
960- push_policy_diag (
961- diagnostics,
962- policy. unsupported_value ,
963- "nemo_guardrails.unsupported_value" ,
964- Some ( NEMO_GUARDRAILS_PLUGIN_KIND . to_string ( ) ) ,
965- Some ( "request_defaults.thread_id" . to_string ( ) ) ,
966- "request_defaults.thread_id must be at least 16 characters long" . to_string ( ) ,
967- ) ;
956+ if let Some ( thread_id) = & request_defaults. thread_id {
957+ let trimmed_thread_id = thread_id. trim ( ) ;
958+ if trimmed_thread_id. is_empty ( ) {
959+ push_policy_diag (
960+ diagnostics,
961+ policy. unsupported_value ,
962+ "nemo_guardrails.unsupported_value" ,
963+ Some ( NEMO_GUARDRAILS_PLUGIN_KIND . to_string ( ) ) ,
964+ Some ( "request_defaults.thread_id" . to_string ( ) ) ,
965+ "request_defaults.thread_id must not be empty" . to_string ( ) ,
966+ ) ;
967+ } else if trimmed_thread_id. len ( ) < 16 {
968+ push_policy_diag (
969+ diagnostics,
970+ policy. unsupported_value ,
971+ "nemo_guardrails.unsupported_value" ,
972+ Some ( NEMO_GUARDRAILS_PLUGIN_KIND . to_string ( ) ) ,
973+ Some ( "request_defaults.thread_id" . to_string ( ) ) ,
974+ "request_defaults.thread_id must be at least 16 characters long" . to_string ( ) ,
975+ ) ;
976+ }
968977 }
969978 validate_json_object_field (
970979 diagnostics,
0 commit comments