did a little refactoring

This commit is contained in:
henceiusegentoo 2023-08-11 19:40:06 +02:00
parent ccbaa4e247
commit 3a210d7b5b

View file

@ -231,23 +231,14 @@ impl ChatResponse {
} }
fn model_is_compatible(endpoint: &Endpoints, model: &Models) -> bool { fn model_is_compatible(endpoint: &Endpoints, model: &Models) -> bool {
if endpoint == &Endpoints::ChatCompletion { let chat_models = [Models::Gpt3, Models::Gpt4];
if [Models::Gpt3, Models::Gpt4].contains(model) { let moderation_models = [Models::ModerationStable, Models::ModerationLatest];
return true;
} else {
return false;
}
}
else if endpoint == &Endpoints::Moderation { match endpoint {
if [Models::ModerationStable, Models::ModerationLatest].contains(model) { Endpoints::ChatCompletion => chat_models.contains(model),
return true; Endpoints::Moderation => moderation_models.contains(model),
} else { _ => false
return false;
}
} }
false
} }
fn key_is_valid(api_key: &str) -> bool { fn key_is_valid(api_key: &str) -> bool {