mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 10:56:10 +00:00
Ask Google for the lowest rung it has rather than for none
Google's compatibility layer has no word for off. Sending reasoning_effort "none" is refused outright, so choosing Thinking → Off made every cleanup fail and paste the raw transcript instead: HTTP 400: Request contains an invalid argument. (INVALID_ARGUMENT) Measured against gemini-3.5-flash-lite, asking it to reply "ok": nothing sent 50.59s reasoning_effort "none" 400 reasoning_effort "minimal" 15.40s reasoning_effort "low" 53.35s reasoning_effort "high" 63.83s So "none" lands on "minimal", which is both accepted and the quickest of them, and quickest is what cleanup wants. The thinking_config route the documentation offers is an SDK wrapper and is not a field this endpoint knows: sending it is "Unknown name \"google\"". Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
+11
-9
@@ -469,11 +469,13 @@ def transcribe_segments(target, audio_path, language="", prompt="", timeout=300,
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
# The settings window offers OpenRouter's ladder, whose top two rungs Google
|
# The settings window offers OpenRouter's ladder, and Google has neither end of
|
||||||
# has never heard of. Sent as they are the request is refused, which costs the
|
# it: "none" is refused outright with a 400, and there is nothing above "high".
|
||||||
# cleanup rather than the dictation, so they land on the nearest rung that
|
# Both ends land on the nearest rung that does exist, which costs the cleanup
|
||||||
# exists instead.
|
# rather than the dictation when it is wrong. "minimal" is where "off" goes, and
|
||||||
GEMINI_EFFORT = {"xhigh": "high", "max": "high"}
|
# it is the quickest of them by a wide margin, which is what cleanup wants
|
||||||
|
# anyway.
|
||||||
|
GEMINI_EFFORT = {"none": "minimal", "xhigh": "high", "max": "high"}
|
||||||
|
|
||||||
|
|
||||||
def _thinking(payload, provider, reasoning):
|
def _thinking(payload, provider, reasoning):
|
||||||
@@ -494,10 +496,10 @@ def _thinking(payload, provider, reasoning):
|
|||||||
payload["chat_template_kwargs"] = {"enable_thinking": reasoning != "none"}
|
payload["chat_template_kwargs"] = {"enable_thinking": reasoning != "none"}
|
||||||
elif provider == "gemini":
|
elif provider == "gemini":
|
||||||
# Google's compatibility layer takes OpenAI's flat field rather than
|
# Google's compatibility layer takes OpenAI's flat field rather than
|
||||||
# OpenRouter's object, and "none" is how thinking is turned off there,
|
# OpenRouter's object, and it has no word for off, so "none" is asked
|
||||||
# so it is the one level worth sending rather than skipping: a Flash
|
# for as the lowest rung it has rather than skipped: a Flash model left
|
||||||
# model left to think spends exactly the second this provider was
|
# to decide for itself thinks, and thinking about a comma is the second
|
||||||
# chosen to save.
|
# this provider was chosen to save.
|
||||||
payload["reasoning_effort"] = GEMINI_EFFORT.get(reasoning, reasoning)
|
payload["reasoning_effort"] = GEMINI_EFFORT.get(reasoning, reasoning)
|
||||||
elif reasoning != "none":
|
elif reasoning != "none":
|
||||||
# The thinking itself is never shown, so ask for it to be left out.
|
# The thinking itself is never shown, so ask for it to be left out.
|
||||||
|
|||||||
+3
-3
@@ -404,11 +404,11 @@ class Cleanup(DikteTest):
|
|||||||
self.assertEqual(payload["reasoning_effort"], "low")
|
self.assertEqual(payload["reasoning_effort"], "low")
|
||||||
self.assertNotIn("reasoning", payload)
|
self.assertNotIn("reasoning", payload)
|
||||||
|
|
||||||
def test_gemini_is_told_to_stop_thinking_rather_than_left_alone(self):
|
def test_off_is_asked_for_as_the_lowest_rung_google_actually_has(self):
|
||||||
""""none" is the one level worth sending: Flash thinks by default."""
|
"""Sending "none" is a 400, and Flash left alone thinks."""
|
||||||
_, calls = self.call(chat_reply("Hello."), reasoning="none",
|
_, calls = self.call(chat_reply("Hello."), reasoning="none",
|
||||||
provider="gemini", service="Google AI Studio")
|
provider="gemini", service="Google AI Studio")
|
||||||
self.assertEqual(sent_json(calls[0])["reasoning_effort"], "none")
|
self.assertEqual(sent_json(calls[0])["reasoning_effort"], "minimal")
|
||||||
|
|
||||||
def test_a_rung_google_does_not_have_lands_on_the_nearest_one(self):
|
def test_a_rung_google_does_not_have_lands_on_the_nearest_one(self):
|
||||||
for asked in ("xhigh", "max"):
|
for asked in ("xhigh", "max"):
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class GoogleAiStudio(DikteTest):
|
|||||||
"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions")
|
"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions")
|
||||||
payload = sent_json(calls[0])
|
payload = sent_json(calls[0])
|
||||||
self.assertEqual(payload["model"], "gemini-3.5-flash-lite")
|
self.assertEqual(payload["model"], "gemini-3.5-flash-lite")
|
||||||
self.assertEqual(payload["reasoning_effort"], "none")
|
self.assertEqual(payload["reasoning_effort"], "minimal")
|
||||||
self.assertIn("uh, done", payload["messages"][1]["content"])
|
self.assertIn("uh, done", payload["messages"][1]["content"])
|
||||||
|
|
||||||
def test_the_key_travels_as_a_bearer_token(self):
|
def test_the_key_travels_as_a_bearer_token(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user