fix: prefer defaults, only overwrite if set and print log of feature

This commit is contained in:
drbh 2024-01-26 12:39:53 -05:00
parent 7abb5ae4fa
commit 7513c057db

View File

@ -1041,6 +1041,7 @@ pub async fn run(
.route("/generate", post(generate)) .route("/generate", post(generate))
.route("/generate_stream", post(generate_stream)) .route("/generate_stream", post(generate_stream))
.route("/v1/chat/completions", post(chat_completions)) .route("/v1/chat/completions", post(chat_completions))
.route("/vertex", post(vertex_compatibility))
.route("/tokenize", post(tokenize)) .route("/tokenize", post(tokenize))
.route("/health", get(health)) .route("/health", get(health))
.route("/ping", get(health)) .route("/ping", get(health))
@ -1063,14 +1064,14 @@ pub async fn run(
.merge(aws_sagemaker_route); .merge(aws_sagemaker_route);
if cfg!(feature = "google") { if cfg!(feature = "google") {
// in the google feature case throw and error if any of the env vars are not set tracing::info!("Built with `google` feature");
let env_predict_route = std::env::var("AIP_PREDICT_ROUTE") tracing::info!("Enviorment variables `AIP_PREDICT_ROUTE` and `AIP_HEALTH_ROUTE` will be respected.");
.expect("AIP_PREDICT_ROUTE must be set when building with `google` feature"); if let Ok(env_predict_route) = std::env::var("AIP_PREDICT_ROUTE") {
app = app.route(&env_predict_route, post(vertex_compatibility)); app = app.route(&env_predict_route, post(compat_generate));
}
let env_health_route = std::env::var("AIP_HEALTH_ROUTE") if let Ok(env_health_route) = std::env::var("AIP_HEALTH_ROUTE") {
.expect("AIP_HEALTH_ROUTE must be set when building with `google` feature"); app = app.route(&env_health_route, get(health));
app = app.route(&env_health_route, get(health)); }
} }
// add layers after routes // add layers after routes