Skip to content

feat(model): support structured output schemas - #77

Open
wucm667 wants to merge 1 commit into
volcengine:mainfrom
wucm667:feat/structured-output-schema
Open

feat(model): support structured output schemas#77
wucm667 wants to merge 1 commit into
volcengine:mainfrom
wucm667:feat/structured-output-schema

Conversation

@wucm667

@wucm667 wucm667 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

背景

ADK 的 llmagent.Config.OutputSchema 会写入 GenerateContentConfig.ResponseSchema,但当前 VeADK-Go 的 OpenAI 与 ARK 适配器只发送 json_object,导致字段约束、required 和嵌套 schema 丢失。

改动

  • 支持将 ResponseSchema / ResponseJsonSchema 转换为 OpenAI-compatible response_format.type=json_schema
  • ARK SDK 路径使用 ResponseFormatJSONSchema,并与 Python 实现保持 strict: true
  • ResponseJsonSchema 优先于 legacy ResponseSchema;仅设置 application/json 时继续回退到原有 json_object
  • 补充 nested required、title、format、anyOf 与常用约束字段转换,并生成合法的 schema name。
  • 新增 OpenAI/ARK 请求转换测试与 examples/structured_output 示例。

测试

  • GOTOOLCHAIN=go1.25.0 go test -mod=readonly -v -race -count=1 -shuffle=on ./... 通过。
  • GOTOOLCHAIN=go1.25.0 go build -mod=readonly -v ./... 通过(包含 structured output 示例)。
  • GOTOOLCHAIN=go1.25.0 go mod tidy -diff 无变更。
  • golangci-lint run --timeout=10m --new-from-rev=upstream/main 通过(0 issues)。
  • 本地 golangci-lint v2 全仓检查仍报告 upstream/main 已有的 18 个问题,本 PR 未新增 lint 问题。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant