MCPcopy Create free account
hub / github.com/AI45Lab/Code / build_repair_message

Function build_repair_message

core/src/llm/structured.rs:1117–1133  ·  view source on GitHub ↗
(raw_text: &str, errors: &[String])

Source from the content-addressed store, hash-verified

1115}
1116
1117fn build_repair_message(raw_text: &str, errors: &[String]) -> String {
1118 // Truncate raw output in repair message to avoid blowing context
1119 let truncated_raw = if raw_text.len() > 2000 {
1120 format!(
1121 "{}...[truncated, {} bytes total]",
1122 truncate_utf8(raw_text, 2000),
1123 raw_text.len()
1124 )
1125 } else {
1126 raw_text.to_string()
1127 };
1128 format!(
1129 "Your previous output failed schema validation:\n\n{}\n\nValidation errors:\n{}\n\nPlease return ONLY a corrected JSON object that fixes these errors. No explanation, no markdown.",
1130 truncated_raw,
1131 errors.iter().map(|e| format!("- {}", e)).collect::<Vec<_>>().join("\n")
1132 )
1133}
1134
1135fn accumulate_usage(total: &mut TokenUsage, delta: &TokenUsage) {
1136 total.prompt_tokens += delta.prompt_tokens;

Callers 1

generate_blockingFunction · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected