Skip to content

Commit

Permalink
✨ Pass along default threshold in detector params
Browse files Browse the repository at this point in the history
Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com>
  • Loading branch information
evaline-ju committed May 28, 2024
1 parent fb73c0e commit 513b25d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,13 @@ async fn detect(
.map(|(detector_id, detector_params)| {
let ctx = ctx.clone();
let detector_id = detector_id.clone();
// Use default threshold here (from ctx?/detector config?) if not present in detector_params
let detector_params = detector_params.clone();
let mut detector_params = detector_params.clone();
if let Some(default_threshold) = ctx.config.get_default_threshold(&detector_id) {
// Use a default threshold if threshold is not provided by the user
detector_params
.entry("threshold".into())
.or_insert(default_threshold.into());
}
let chunker_id =
ctx.config
.get_chunker_id(&detector_id)
Expand Down Expand Up @@ -326,6 +331,9 @@ async fn handle_detection_task(
let detector_id = detector_id.clone();
let detector_params = detector_params.clone();
async move {
// NOTE: The detector request is expected to change and not actually
// take parameters. However, any parameters will be ignored for now
// ref. https://github.com/foundation-model-stack/fms-guardrails-orchestrator/issues/37
let request = DetectorRequest::new(chunk.text.clone(), detector_params);
debug!(
%detector_id,
Expand Down

0 comments on commit 513b25d

Please sign in to comment.