From 3a210d7b5b44ac861012bff31dad320ed76a57d7 Mon Sep 17 00:00:00 2001 From: henceiusegentoo Date: Fri, 11 Aug 2023 19:40:06 +0200 Subject: [PATCH] did a little refactoring --- src/lib.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e44ce55..4907828 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -231,23 +231,14 @@ impl ChatResponse { } fn model_is_compatible(endpoint: &Endpoints, model: &Models) -> bool { - if endpoint == &Endpoints::ChatCompletion { - if [Models::Gpt3, Models::Gpt4].contains(model) { - return true; - } else { - return false; - } - } - - else if endpoint == &Endpoints::Moderation { - if [Models::ModerationStable, Models::ModerationLatest].contains(model) { - return true; - } else { - return false; - } - } + let chat_models = [Models::Gpt3, Models::Gpt4]; + let moderation_models = [Models::ModerationStable, Models::ModerationLatest]; - false + match endpoint { + Endpoints::ChatCompletion => chat_models.contains(model), + Endpoints::Moderation => moderation_models.contains(model), + _ => false + } } fn key_is_valid(api_key: &str) -> bool {