Default to MiniMax M3 and fix Hungarian quotes in analyses

MiniMax M3 rated top in a blind comparison at a sixth of the cost of the
other top models. Straight double-quote pairs in Hungarian answers become „…”.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-15 17:05:23 +00:00
co-authored by Claude Opus 5.5
parent 812b2d4f73
commit b30a6c8fb1
7 changed files with 63 additions and 7 deletions
+4 -1
View File
@@ -111,7 +111,10 @@ impl Analyzer {
pub async fn handle(&self, job: Job) {
let started = Instant::now();
let result = match self.prompt_for(&job).await {
Ok(prompt) => self.llm.complete(&job.model, &prompt).await,
Ok(prompt) => self.llm.complete(&job.model, &prompt).await.map(|mut c| {
prompt::polish(&job.language, &mut c.content);
c
}),
Err(e) => Err(e),
};
if let Err(e) = self.finish(&job, result, started.elapsed()).await {
+50
View File
@@ -199,6 +199,39 @@ pub fn validate(schema: &Value, value: &Value) -> Result<(), String> {
walk(schema, value, "$")
}
/// Fixes typography the models often get wrong. In Hungarian, pairs of
/// straight double quotes become „…” (only when they pair up evenly).
pub fn polish(language: &str, content: &mut Value) {
fn hungarian_quotes(text: &str) -> Option<String> {
if !text.contains('"') || !text.matches('"').count().is_multiple_of(2) {
return None;
}
let mut open = true;
Some(
text.chars()
.map(|c| match c {
'"' => {
let q = if open { '„' } else { '”' };
open = !open;
q
}
c => c,
})
.collect(),
)
}
match content {
Value::String(s) if language == "hu" => {
if let Some(fixed) = hungarian_quotes(s) {
*s = fixed;
}
}
Value::Array(items) => items.iter_mut().for_each(|v| polish(language, v)),
Value::Object(map) => map.values_mut().for_each(|v| polish(language, v)),
_ => {}
}
}
/// The analysis as Markdown (for reading and comparing outputs).
pub fn to_markdown(kind: Kind, language: &str, content: &Value) -> String {
let (strengths, challenges, advice) = if language == "hu" {
@@ -222,3 +255,20 @@ pub fn to_markdown(kind: Kind, language: &str, content: &Value) -> String {
md.push_str(&format!("## {advice}\n\n{}\n", content["advice"].as_str().unwrap_or("")));
md
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn polish_turns_straight_quotes_hungarian() {
let mut v = json!({"a": "a \"hazai pálya\" és a \"sorok\"", "b": ["egy \" pár nélkül"], "c": {"d": "nincs"}});
polish("hu", &mut v);
assert_eq!(v["a"], "a „hazai pálya” és a „sorok”");
assert_eq!(v["b"][0], "egy \" pár nélkül");
assert_eq!(v["c"]["d"], "nincs");
let mut en = json!({"a": "the \"home\" ground"});
polish("en", &mut en);
assert_eq!(en["a"], "the \"home\" ground");
}
}
+2 -1
View File
@@ -101,7 +101,8 @@ pub async fn main(args: Vec<String>) -> anyhow::Result<()> {
while let Some(joined) = tasks.join_next().await {
let (letter, model, result, secs) = joined?;
match result {
Ok(c) => {
Ok(mut c) => {
prompt::polish(&args.language, &mut c.content);
let md = prompt::to_markdown(prompt::Kind::Natal, &args.language, &c.content);
let words = md.split_whitespace().count();
std::fs::write(args.out.join(format!("{letter}.md")), &md)?;