-
Notifications
You must be signed in to change notification settings - Fork 30
Guardrails request config validation #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guardrails request config validation #371
Conversation
3f34002
to
b417ca2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mdevino. I left some nit comments inline but otherwise looks good.
src/utils.rs
Outdated
@@ -15,3 +25,43 @@ impl AsUriExt for Url { | |||
Uri::try_from(self.to_string()).unwrap() | |||
} | |||
} | |||
|
|||
/// Validates guardrails on request. | |||
pub fn validate_guardrails( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, let's just name this validate_detectors
since it aligns better with what it does. Can you move it to orchestrator/common/utils.rs
?
src/utils.rs
Outdated
pub fn validate_guardrails( | ||
request_detectors: &HashMap<String, DetectorParams>, | ||
orchestrator_detectors: &HashMap<String, DetectorConfig>, | ||
allowed_detector_types: Vec<DetectorType>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: allowed_detector_types
should be a slice instead of a Vec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I knew Vec
seemed unnecessarly, but couldn't figure out a better way of doing it.
src/utils.rs
Outdated
) -> Result<(), Error> { | ||
let whole_doc_chunker_id = DEFAULT_CHUNKER_ID; | ||
let detector_ids = request_detectors.keys(); | ||
for detector_id in detector_ids { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just iterate over request_detectors.keys()
directly instead of assigning to a variable. I would also rename request_detectors
to simply detectors
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One additional nit that I forgot to comment earlier, otherwise looks good
The if !detectors.is_empty()
conditionals aren't needed; if empty, validate_detectors()
just returns Ok(())
572bdfe
to
13dbb4b
Compare
Nice catch! Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Hmm, does this need to be rebased? |
It doesn't seem so: I started working on this when you were halfway through #355, so I had to rebase at some point and resolve conflicts. That's when the extra commits showed up. |
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Co-authored-by: Dan Clark <[email protected]> Signed-off-by: Mateus Devino <[email protected]>
Co-authored-by: Dan Clark <[email protected]> Signed-off-by: Mateus Devino <[email protected]>
Co-authored-by: Dan Clark <[email protected]> Signed-off-by: Mateus Devino <[email protected]>
Co-authored-by: Dan Clark <[email protected]> Signed-off-by: Mateus Devino <[email protected]>
Co-authored-by: Dan Clark <[email protected]> Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
13dbb4b
to
863d033
Compare
// input detectors validation | ||
if let Err(error) = validate_detectors( | ||
&input_detectors, | ||
&ctx.config.detectors, | ||
&[DetectorType::TextContents], | ||
false, | ||
) { | ||
let _ = response_tx.send(Err(error)).await; | ||
return; | ||
} | ||
|
||
// output detectors validation | ||
if let Err(error) = validate_detectors( | ||
&output_detectors, | ||
&ctx.config.detectors, | ||
&[DetectorType::TextContents], | ||
false, | ||
) { | ||
let _ = response_tx.send(Err(error)).await; | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since a user issue led to triggering of an error here for the current version of the orchestrator - why are the whole doc chunkers deliberately disallowed here, especially for both input and output streaming? This would disallow a case of say using Granite Guardian as a content detector.
Closes #352, and also adds appropriate integration tests.