From 4a47f66da123ad7ee4e7691221086800f5fc57b0 Mon Sep 17 00:00:00 2001 From: drbh Date: Mon, 15 Jan 2024 18:09:31 -0500 Subject: [PATCH] fix: avoid program exit on repo fetch failures --- router/src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/router/src/main.rs b/router/src/main.rs index 6c6445bb..f5d44305 100644 --- a/router/src/main.rs +++ b/router/src/main.rs @@ -176,7 +176,13 @@ async fn main() -> Result<(), RouterError> { // Initialize API if needed let api = if use_api { tracing::info!("Using the Hugging Face API"); - Some(api_builder().build().unwrap()) + match api_builder().build() { + Ok(api) => Some(api), + Err(_) => { + tracing::warn!("Unable to build the Hugging Face API"); + None + } + } } else { None }; @@ -232,7 +238,10 @@ async fn main() -> Result<(), RouterError> { revision.unwrap_or_else(|| "main".to_string()), ))) .await - .unwrap() + .unwrap_or_else(|| { + tracing::warn!("Could not retrieve tokenizer config from the Hugging Face hub."); + HubTokenizerConfig::default() + }) } else { tracing::warn!("Could not find tokenizer config locally and no revision specified"); HubTokenizerConfig::default()