magpie icon indicating copy to clipboard operation
magpie copied to clipboard

System One: carry audio to Google's gemini-decision-1

Open et84121 opened this issue 1 week ago • 3 comments

What you want to do

Send audio to google/gemini-decision-1 through /v1/systemone, not only text and images. Video and PDF blocks would use the same shape later.

What you do today instead

Only images is carried. googleAsk builds the input from text and images, and there is no field for audio, so an audio-only classifier has to call Google directly and loses magpie's keys, routing and quota handling.

Google's Decisions API accepts an audio block, and I checked it directly: a 3.8 s WAV sent as {"type":"audio","data":"…","mime_type":"audio/wav"} came back with 242 input tokens (116 of them audio) and the answer at 0.95 confidence.

Suggested shape: an audio array next to images, with the same data-URL or URL strings, translated to audio blocks in googleAsk.

No client sends audio today: Pi's ClassifierContext has images only. This is forward-looking, so it can wait until a caller exists. It would keep the wire in one place and let Pi pass audio later without another change.

et84121 avatar Nov 26 '26 03:11 et84121

Fix branch: https://github.com/qq01-hub/magpie/tree/fix/systemone-google-audio (59c6198b4) Compare: https://github.com/yetone/magpie/compare/main...qq01-hub:magpie:fix/systemone-google-audio

Changes:

  • Extend googleAsk in internal/provider/decide_wire.go to translate a System One request's audio array (base64 data: URLs or URIs) into Google Decisions API {"type":"audio",...} content blocks via shared helper googleMediaBlock, stripping optional data-URL parameters (e.g. ;codecs=opus) for mime_type.
  • Support audio-only classification requests (omitted or empty-string state) without inserting an empty text block, support combining images and audio in the same request, and strip empty audio: [] arrays so no unknown top-level audio key reaches Google.
  • Keep non-Google wires (ViaSystemOne, ViaVercel, etc.) untouched; OpenAI /v1/decisions translation continues rejecting unsupported audio cleanly via systemOneAsDecisions.
  • Add unit coverage in TestGoogleDecideWire (internal/provider/decide_google_test.go) and end-to-end /v1/systemone coverage in TestGoogleSystemOneTakesAudio (internal/gateway/decide_google_test.go).

Verification (Windows 11 amd64, Go 1.26.8):

  • Before fix: TestGoogleDecideWire failed (top-level audio leaked untouched) and TestGoogleSystemOneTakesAudio failed with 400 on audio-only input.
  • After fix: go test -count=5 ./internal/provider -run 'TestGoogleDecide|TestDecide' (35/35) and go test -count=5 ./internal/gateway -run 'TestGoogleSystemOne|TestGoogleDecisions|TestSystemOne|TestDecide|TestDecisions' (145/145) passed; go vet passed on Windows, Linux (-tags nogui), and macOS (-tags nogui).

qq01-hub avatar Nov 26 '26 05:11 qq01-hub

Verified on 0.1.4839: a 3.8 s WAV in audio returns 200 with 242 input tokens, the same count as calling Google directly, noul 0.954.

et84121 avatar Nov 26 '26 08:11 et84121

@yetone 佬,这个 issue 的修复分支我这边修完推在 qq01-hub/magpie 上了(fix/systemone-google-audio),报告者 et84121 已在 0.1.4839 上验证通过,改动说明和跑过的测试都在上面的回复里,有空帮忙瞅一眼哈。

qq01-hub avatar Nov 27 '26 05:11 qq01-hub