为业务校验重试增加退避
校验失败重试复用请求错误的递增等待并记录日志
This commit is contained in:
@@ -64,6 +64,16 @@ where
|
||||
match validator(&value) {
|
||||
Ok(()) => return Ok(value),
|
||||
Err(error) if attempt < max_retries => {
|
||||
app_log!(
|
||||
"ui_editor.llm.retry validation_error attempt={} max_retries={} error={}",
|
||||
attempt + 1,
|
||||
max_retries,
|
||||
error
|
||||
);
|
||||
tokio::time::sleep(std::time::Duration::from_millis(
|
||||
200 * (attempt as u64 + 1),
|
||||
))
|
||||
.await;
|
||||
let serialized = serde_json::to_string(&value)
|
||||
.map_err(|serialize_error| format!("序列化修复反馈失败:{serialize_error}"))?;
|
||||
history.push(LlmMessage::system(format!(
|
||||
|
||||
Reference in New Issue
Block a user