1use anyhow::Result;
2
3use crate::{PredictionProvider, example::Example};
4
5pub async fn run_distill(example: &mut Example) -> Result<()> {
6 let has_repair = example
7 .predictions
8 .iter()
9 .find(|p| p.provider == PredictionProvider::Repair);
10 let predictions = if let Some(has_repair) = has_repair {
11 vec![has_repair]
12 } else {
13 example.predictions.iter().collect()
14 };
15
16 let expected_patches = predictions
17 .into_iter()
18 .filter_map(|p| {
19 Some((
20 p.actual_patch.clone()?,
21 p.actual_cursor
22 .as_ref()
23 .and_then(|c| c.editable_region_offset),
24 ))
25 })
26 .collect();
27
28 example
29 .spec
30 .set_expected_patches_with_cursor_positions(expected_patches);
31 example.prompt = None;
32 example.predictions = Vec::new();
33 example.score = Vec::new();
34 example.qa = Vec::new();
35 Ok(())
36}