Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

fix(android): checking a custom AI service says the model thinks first even when the thinking used up its reply, instead of passing it

wqugurucf9e3bb324a6
diff --git a/android/cli/src/main/kotlin/cicada/cli/ProviderTests.kt b/android/cli/src/main/kotlin/cicada/cli/ProviderTests.kt
index b7bd684..b7da38e 100644
--- a/android/cli/src/main/kotlin/cicada/cli/ProviderTests.kt
+++ b/android/cli/src/main/kotlin/cicada/cli/ProviderTests.kt
@@ -194,6 +194,12 @@ object ProviderTests {
val t = ling.aiCheck.translate
check(t != null && t.thinks, "thinking found: ${ling.aiCheck.summary}")
check(ling.aiCheck.slow && ling.aiCheck.failure == null, "works, but slow")
+ // All 120 tokens spent thinking, no answer: still a thinking model, not a silent pass.
+ val noAnswer = Transport.Response(200, Json.write(mapOf("choices" to listOf(mapOf(
+ "message" to mapOf("content" to null, "reasoning" to "Okay, the user wants…"), "finish_reason" to "length"))), pretty = false))
+ val spent = client(Fake({ url, b -> if (url.endsWith("models")) Transport.Response(404, "") else if ("Translate the text" in b) noAnswer else reply("{\"ok\": true}") }), s, key = null)
+ spent.check()
+ check(spent.aiCheck.translate?.thinks == true && spent.aiCheck.slow, "thinking found without an answer: ${spent.aiCheck.summary}")
}
fun hearBase() {
diff --git a/android/core/src/main/kotlin/cicada/Ling.kt b/android/core/src/main/kotlin/cicada/Ling.kt
index fdce5e2..eea5bdc 100644
--- a/android/core/src/main/kotlin/cicada/Ling.kt
+++ b/android/core/src/main/kotlin/cicada/Ling.kt
@@ -361,8 +361,16 @@ class LingClient(
// A real sentence, the way a meeting translates: one token says nothing about a
// model that thinks for six seconds before every answer.
var thinks = false
- chat("Translate the text into Simplified Chinese. Reply with the translation only.\n\nWe will ship the new version on Friday after the design review.",
- "Translate.", Priority.Speak, maxTokens = 120, timeout = 30.0) { thinks = AIConfig.thought(it) }
+ var answered = false
+ try {
+ chat("Translate the text into Simplified Chinese. Reply with the translation only.\n\nWe will ship the new version on Friday after the design review.",
+ "Translate.", Priority.Speak, maxTokens = 120, timeout = 30.0) { answered = true; thinks = AIConfig.thought(it) }
+ } catch (e: LingException) {
+ // A model that thinks can spend all its tokens on thinking and answer nothing:
+ // it did answer, slowly, and that is what this step is here to say (the Mac
+ // reads only the reply's thinking, not its words).
+ if (!answered || (e.kind != LingException.Kind.Parse && e.kind != LingException.Kind.Hijacked)) throw e
+ }
val seconds = (System.nanoTime() - started) / 1e9
r = r.pass(AICheck.StepID.Text, seconds).copy(translate = AICheck.Speed(seconds, thinks))
} else {
diff --git a/site/changelog.json b/site/changelog.json
index cc60e22..cbf3c65 100644
--- a/site/changelog.json
+++ b/site/changelog.json
@@ -496,6 +496,14 @@
],
"title": "自建服务检查中途改设置,不再闪一下“连不上”。",
"text": ""
+ },
+ {
+ "kind": "fixed",
+ "platforms": [
+ "android"
+ ],
+ "title": "Android 检查自建服务时,模型想了半天没给出译文,也会说它先思考、翻一句要几秒,不再显示“能写纪要”就算通过。",
+ "text": ""
}
]
},