Skip to content

fix(live): forward groundingMetadata, thought/code parts, goAway, usageMetadata, and waitingForInput #362

Backlog

Description

@lawrancehoy-cyber

发生了什么 / What happened

改动 / Changes

  • internal/aistudio/bidi.go:
    • Decode serverContent field 4 (index 3, groundingMetadata) via decodeGroundingMetadata into BidiEventGrounding instead of falling through to raw provider (verified live on gemini-4-live with googleSearch enabled).
    • Decode serverContent field 8 (index 7, waitingForInput, verified in YUh4Se.js Xsi) into BidiEventWaitingForInput.
    • Decode message[5] (usageMetadata) via decodeUsage into BidiEvent.Usage and message[6] (goAway [Duration([seconds, nanos])]) into BidiEvent.GoAwayTimeLeft (preserving Raw).
  • internal/aistudio/build_bidi.go:
    • Decode serverContent.groundingMetadata (via decodeBuildGrounding), serverContent.waitingForInput, executableCode / codeExecutionResult parts, goAway.timeLeft, and usageMetadata (responseTokenCount / candidatesTokenCount + modality details).
  • internal/api/live.go:
    • Expose grounding on /v1/live server messages (BidiEventGrounding).
  • internal/api/live_gemini.go:
    • Forward BidiEventGrounding (serverContent.groundingMetadata), BidiEventWaitingForInput (serverContent.waitingForInput), BidiEventGoAway (goAway.timeLeft), BidiEventUsage (usageMetadata using Live API responseTokenCount / responseTokensDetails), and embedded EventReasoning / EventExecutableCode / EventCodeExecutionResult parts from BidiEventProvider (modelTurn.parts) on /ws/...BidiGenerateContent.
  • docs/protocol.md: sync Live server message lists.
  • internal/aistudio/bidi_events_test.go, internal/api/live_gemini_events_test.go: unit tests covering Playground protobuf-array and Build JSON decoding plus standard Gemini Live event formatting.

验证 / Verification

  • go test -mod=readonly -trimpath -count=1 ./internal/aistudio/... ./internal/api/... (internal/aistudio 0.056s, internal/api 0.096s) — passed.
  • go vet -mod=readonly ./internal/aistudio/... ./internal/api/... ./internal/i18n/... — passed.

  • 修改涉及的所有代码均在本地实际跑通过,没有只靠肉眼检查
  • 所有新增或修改的逻辑均有对应的测试覆盖
  • 已阅读并理解仓库的整体结构,没有破坏现有架构或引入重复实现

版本 / Version

v0.3.17 (5deae85)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions