修正 UI 编辑器校验器命名
将 run_with_repair_history 的 Validater/validater 更正为 Validator/validator。 不改变重试流程和运行时行为。
This commit is contained in:
@@ -28,17 +28,17 @@ pub(crate) async fn request_ui_editor_llm(
|
||||
}
|
||||
|
||||
/// 按 append-only history 重试结构化 LLM 请求;仅业务校验失败会追加反馈消息。
|
||||
pub(crate) async fn run_with_repair_history<T, Requester, Fut, Validater>(
|
||||
pub(crate) async fn run_with_repair_history<T, Requester, Fut, Validator>(
|
||||
max_retries: usize,
|
||||
initial_history: Vec<LlmMessage>,
|
||||
requester: Requester,
|
||||
validater: Validater,
|
||||
validator: Validator,
|
||||
) -> Result<T, String>
|
||||
where
|
||||
T: Serialize,
|
||||
Requester: Fn(Vec<LlmMessage>) -> Fut,
|
||||
Fut: Future<Output = Result<T, String>>,
|
||||
Validater: Fn(&T) -> Result<(), String>,
|
||||
Validator: Fn(&T) -> Result<(), String>,
|
||||
{
|
||||
let mut history = initial_history;
|
||||
for attempt in 0..=max_retries {
|
||||
@@ -47,7 +47,7 @@ where
|
||||
Err(_error) if attempt < max_retries => continue,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
match validater(&value) {
|
||||
match validator(&value) {
|
||||
Ok(()) => return Ok(value),
|
||||
Err(error) if attempt < max_retries => {
|
||||
let serialized = serde_json::to_string(&value)
|
||||
|
||||
Reference in New Issue
Block a user