pub struct ContentProcessor { /* private fields */ }Expand description
Orchestrates processContent evaluation over a batch of messages. See
the module docs for how this differs in scope from Python’s
ScopedContentProcessor.
Implementations§
Source§impl ContentProcessor
impl ContentProcessor
pub fn new(client: PurviewClient) -> Self
Sourcepub async fn evaluate(
&self,
messages: &[Message],
settings: &PurviewSettings,
provided_user_id: Option<&str>,
) -> Result<(bool, Option<String>)>
pub async fn evaluate( &self, messages: &[Message], settings: &PurviewSettings, provided_user_id: Option<&str>, ) -> Result<(bool, Option<String>)>
Evaluate messages for policy violations, resolving the user id per
resolve_user_id (provided_user_id lets a response-phase
evaluation reuse the id resolved during the prompt phase, matching
Python’s process_messages(..., user_id=resolved_user_id)).
Returns (should_block, resolved_user_id). One processContent call
is made per message, in order, stopping at (and including) the first
one that returns a block verdict — mirrors
ScopedContentProcessor.process_messages’s for req in pc_requests: ...; if should_block: break.
Fails (rather than silently allowing) when tenant_id or
purview_app_location aren’t set on settings, mirroring Python’s
_map_messages raising ValueError in the same situation — an
error a caller with ignore_exceptions = true treats as fail-open
(see crate::middleware), same as Python.