Skip to content

Commit cc4d93f

Browse files
authored
perf(decompile): harden llm postprocessing, will not hard error (#532)
1 parent e946141 commit cc4d93f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

crates/decompile/src/core/out/source.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,16 @@ pub async fn build_source(
122122
debug!("llm postprocessing 0x{} source", f.selector);
123123

124124
let postprocessed_source =
125-
annotate_function(&function_source.join("\n"), &openai_api_key).await?;
125+
annotate_function(&function_source.join("\n"), &openai_api_key)
126+
.await
127+
.map_err(|e| {
128+
debug!(
129+
"llm postprocessing 0x{} source failed: {:?}",
130+
f.selector, e
131+
);
132+
e
133+
})
134+
.ok();
126135

127136
debug!(
128137
"llm postprocessing 0x{} source took {:?}",
@@ -131,8 +140,10 @@ pub async fn build_source(
131140
);
132141

133142
// replace the function source with the postprocessed source
134-
function_source =
135-
postprocessed_source.split('\n').map(|x| x.to_string()).collect();
143+
if let Some(postprocessed_source) = postprocessed_source {
144+
function_source =
145+
postprocessed_source.split('\n').map(|x| x.to_string()).collect();
146+
}
136147
}
137148

138149
Ok::<Vec<String>, eyre::Report>(function_source)

0 commit comments

Comments
 (0)