edit prediction: Report early-rejected predictions and fix cancel bug (#43585)
Many prediction requests end up being rejected early without ever being set as the current prediction. Before this change, those cases weren’t reported as rejections because the `request_prediction_with_*` functions simply returned `Ok(None)`. With this update, whenever we get a successful response from the provider, we will return at least the `id`, allowing it to be properly reported. The request now also includes a “reject reason,” since the different variants carry distinct implications for prediction quality. All of these scenarios are now covered by tests. While adding them, I also found and fixed a bug where some cancelled predictions were incorrectly being set as the current one. Release Notes: - N/A --------- Co-authored-by: MrSubidubi <dev@bahn.sh>
This commit is contained in:
co-authored by
MrSubidubi
parent
61a414df77
commit
f89e5308e3
@@ -235,7 +235,10 @@ pub async fn perform_predict(
|
||||
let mut result = Arc::into_inner(result).unwrap().into_inner().unwrap();
|
||||
|
||||
result.diff = prediction
|
||||
.and_then(|prediction| prediction.edit_preview.as_unified_diff(&prediction.edits))
|
||||
.and_then(|prediction| {
|
||||
let prediction = prediction.prediction.ok()?;
|
||||
prediction.edit_preview.as_unified_diff(&prediction.edits)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
anyhow::Ok(result)
|
||||
|
||||
Reference in New Issue
Block a user