diff --git a/crates/tabby/src/main.rs b/crates/tabby/src/main.rs index f35054b3a22c..316b950435d5 100644 --- a/crates/tabby/src/main.rs +++ b/crates/tabby/src/main.rs @@ -206,7 +206,7 @@ fn init_logging(otlp_endpoint: Option) { if let Ok(tracer) = tracer { layers.push(tracing_opentelemetry::layer().with_tracer(tracer).boxed()); - axum_tracing_opentelemetry::init_propagator().unwrap(); + axum_tracing_opentelemetry::init_propagator().expect("Initializing telemetry"); }; } diff --git a/crates/tabby/src/services/chat.rs b/crates/tabby/src/services/chat.rs index c766d0ea7324..e6e376be9817 100644 --- a/crates/tabby/src/services/chat.rs +++ b/crates/tabby/src/services/chat.rs @@ -111,7 +111,9 @@ impl ChatService { if let Some(temperature) = temperature { builder.sampling_temperature(temperature); } - builder.build().unwrap() + builder + .build() + .expect("Failed to create text generation options") } pub async fn generate<'a>( diff --git a/crates/tabby/src/services/code.rs b/crates/tabby/src/services/code.rs index 7ca31888aa65..dc9bcbf15990 100644 --- a/crates/tabby/src/services/code.rs +++ b/crates/tabby/src/services/code.rs @@ -131,7 +131,7 @@ impl CodeSearch for CodeSearchImpl { fn get_field(doc: &Document, field: Field) -> String { doc.get_first(field) .and_then(|x| x.as_text()) - .unwrap() + .expect("Missing field") .to_owned() } diff --git a/crates/tabby/src/services/completion.rs b/crates/tabby/src/services/completion.rs index ea188309630e..507e6cef2e23 100644 --- a/crates/tabby/src/services/completion.rs +++ b/crates/tabby/src/services/completion.rs @@ -220,7 +220,9 @@ impl CompletionService { if let Some(temperature) = temperature { builder.sampling_temperature(temperature); } - builder.build().unwrap() + builder + .build() + .expect("Failed to create text generation options") } pub async fn generate( diff --git a/crates/tabby/src/services/completion/completion_prompt.rs b/crates/tabby/src/services/completion/completion_prompt.rs index 00948772cd9e..5ed3770b988d 100644 --- a/crates/tabby/src/services/completion/completion_prompt.rs +++ b/crates/tabby/src/services/completion/completion_prompt.rs @@ -52,16 +52,9 @@ impl PromptBuilder { } fn get_default_suffix(suffix: Option) -> String { - if suffix.is_none() { - return "\n".to_owned(); - } - - let suffix = suffix.unwrap(); - if suffix.is_empty() { - "\n".to_owned() - } else { - suffix - } + suffix + .filter(|s| !s.is_empty()) + .unwrap_or_else(|| "\n".to_string()) } fn rewrite_with_snippets(language: &str, segments: Segments, snippets: &[Snippet]) -> Segments { diff --git a/crates/tabby/src/services/model.rs b/crates/tabby/src/services/model.rs index 14dcafcadb9e..cd4d2ee1513e 100644 --- a/crates/tabby/src/services/model.rs +++ b/crates/tabby/src/services/model.rs @@ -83,7 +83,7 @@ fn create_ggml_engine(device: &Device, model_path: &str, parallelism: u8) -> imp .use_gpu(device.ggml_use_gpu()) .parallelism(parallelism) .build() - .unwrap(); + .expect("Failed to create llama text generation options"); make_text_generation(llama_cpp_bindings::LlamaTextGeneration::new(options)) } diff --git a/crates/tabby/tests/goldentests.rs b/crates/tabby/tests/goldentests.rs index 5af5afbda9ff..05192a66856e 100644 --- a/crates/tabby/tests/goldentests.rs +++ b/crates/tabby/tests/goldentests.rs @@ -20,8 +20,11 @@ fn workspace_dir() -> PathBuf { .output() .unwrap() .stdout; - let cargo_path = std::path::Path::new(std::str::from_utf8(&output).unwrap().trim()); - cargo_path.parent().unwrap().to_path_buf() + let cargo_path = std::path::Path::new(std::str::from_utf8(&output).expect("Valid path").trim()); + cargo_path + .parent() + .expect("Path must have a parent folder") + .to_path_buf() } fn tabby_path() -> PathBuf { @@ -46,7 +49,7 @@ fn initialize_server(gpu_device: Option<&str>) { .expect("Failed to start server") .wait() .await - .unwrap(); + .expect("Failed to start server"); }); }