From 001f5f63a95c561eacd6cf5efcb4bd8a022466ea Mon Sep 17 00:00:00 2001 From: Jon-Becker Date: Mon, 9 Dec 2024 10:53:33 -0500 Subject: [PATCH] perf(decompile): harden llm postprocessing, will not hard error --- crates/decompile/src/core/out/source.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/decompile/src/core/out/source.rs b/crates/decompile/src/core/out/source.rs index b9a42beb..667bf655 100644 --- a/crates/decompile/src/core/out/source.rs +++ b/crates/decompile/src/core/out/source.rs @@ -122,7 +122,16 @@ pub async fn build_source( debug!("llm postprocessing 0x{} source", f.selector); let postprocessed_source = - annotate_function(&function_source.join("\n"), &openai_api_key).await?; + annotate_function(&function_source.join("\n"), &openai_api_key) + .await + .map_err(|e| { + debug!( + "llm postprocessing 0x{} source failed: {:?}", + f.selector, e + ); + e + }) + .ok(); debug!( "llm postprocessing 0x{} source took {:?}", @@ -131,8 +140,10 @@ pub async fn build_source( ); // replace the function source with the postprocessed source - function_source = - postprocessed_source.split('\n').map(|x| x.to_string()).collect(); + if let Some(postprocessed_source) = postprocessed_source { + function_source = + postprocessed_source.split('\n').map(|x| x.to_string()).collect(); + } } Ok::, eyre::Report>(function_source)