A dictation that fails says so, in the instance's own words
CI / check (push) Canceled after 0s

The composer's dictation kept a refused or unreachable transcription to
itself: the field stayed as it was. It is now said as any failure is.

And /v1 refuses in OpenAI's shape (error.message), which the client did
not read: a refusal about speech was "The server answered 502." in the
chat, in Read aloud and in the assistant. Both shapes are read now.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Fable 5.2 committed 2026-11-18 09:16:55 +00:00
1 parent 8e84f0d53d
commit df20788d7f
5 files changed
+65 -11

No files matched your search

@@ -1,9 +1,11 @@
package eu.llembas.android
import eu.llembas.android.api.ApiClient
import eu.llembas.android.api.ApiException
import eu.llembas.android.api.Chat
import eu.llembas.android.api.MediaFor
import eu.llembas.android.api.ModelInfo
import eu.llembas.android.api.refusal
import eu.llembas.android.ui.chat.ChatState
import eu.llembas.android.ui.chat.Draft
import eu.llembas.android.ui.chat.MEDIA_DICTATION
@@ -18,6 +20,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Before
import org.junit.Test
@@ -111,6 +114,31 @@ class MediaForTest {
assertTrue(request.body.readUtf8().contains("\"chat_model\":\"shire/pippin\""))
}
@Test
fun aRefusedTranscriptionSaysTheServersSentence() = runTest {
// `/v1` refuses in OpenAI's shape, not `/api/v2`'s `detail`.
server.enqueue(
MockResponse().setResponseCode(502)
.setBody("""{"error":{"message":"The speech model did not answer.","type":"upstream_error","code":502}}"""),
)
try {
client().transcribe(ByteArray(64), media = MediaFor.of("c1", null))
fail("a 502 is a refusal")
} catch (e: ApiException) {
assertEquals(502, e.status)
assertEquals("The speech model did not answer.", e.message)
}
}
@Test
fun aRefusalIsReadInBothShapes() {
assertEquals("No.", refusal("""{"detail":"No."}"""))
assertEquals("Too long.", refusal("""{"error":{"message":"Too long.","code":413}}"""))
assertNull(refusal("""{"error":"plain"}"""))
assertNull(refusal("<html>Bad gateway</html>"))
assertNull(refusal(""))
}
@Test
fun aFallbackIsNamedOnlyWhenTheServerSaysBoth() {
assertEquals("Bree", ApiClient.fallbackSource("1", "Bree"))