From b2023fc5d3ea6b7e224737984f64f17d79a711d7 Mon Sep 17 00:00:00 2001 From: Zaki Ali Date: Fri, 20 Dec 2024 14:19:59 -0800 Subject: [PATCH] Fixup error printing --- crates/goose/src/providers/openai.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/goose/src/providers/openai.rs b/crates/goose/src/providers/openai.rs index 8e035cc2d..309b44c34 100644 --- a/crates/goose/src/providers/openai.rs +++ b/crates/goose/src/providers/openai.rs @@ -135,7 +135,13 @@ impl Moderation for OpenAiProvider { let category_scores = response_json["results"][0]["category_scores"].clone(); return Ok(ModerationResult::new( flagged, - Some(categories.keys().cloned().collect()), + Some( + categories + .iter() + .filter(|(_, value)| value.as_bool().unwrap_or(false)) + .map(|(key, _)| key.to_string()) + .collect(), + ), Some(category_scores), )); } else {