Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit 77b08b3

Browse files
committed
Sanitize summary with newline
This fixes bad LLM generation that puts a newline between `[^summary]:` and the actual summary.
1 parent 0b357fd commit 77b08b3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

server/bleep/src/agent/transcoder.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ fn sanitize(article: &str) -> String {
200200
let sanitized = xml_for_each(article, |code| Some(fixup_xml_code(code).into_owned()));
201201
regex!("<!--.*?-->")
202202
.replace_all(&sanitized, "")
203-
.into_owned()
203+
.replace("\n\n[^summary]:\n", "\n\n[^summary]: ")
204204
}
205205

206206
fn fixup_xml_code(xml: &str) -> Cow<str> {
@@ -1257,4 +1257,23 @@ func sendSlackMessage(org string) error {
12571257
assert_eq!(expected_body, body);
12581258
assert_eq!(expected_conclusion, conclusion.unwrap());
12591259
}
1260+
1261+
#[test]
1262+
fn test_malformed_summary() {
1263+
let input = "Foo bar.
1264+
1265+
[^summary]:
1266+
Baz quux.";
1267+
1268+
let (body, conclusion) = decode(input);
1269+
1270+
let arena = comrak::Arena::new();
1271+
let mut options = comrak::ComrakOptions::default();
1272+
options.extension.footnotes = true;
1273+
1274+
dbg!(comrak::parse_document(&arena, input, &options));
1275+
1276+
assert_eq!("Foo bar.", body);
1277+
assert_eq!("Baz quux.", conclusion.unwrap());
1278+
}
12601279
}

0 commit comments

Comments
 (0)