fix(gemini): normalize nullable and literal tool schemas - #2
Open
jerry-airjelly wants to merge 2 commits into
Open
fix(gemini): normalize nullable and literal tool schemas#2jerry-airjelly wants to merge 2 commits into
jerry-airjelly wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
📝 变更描述 / Description
修复 OpenAI Chat Completions / Responses 转 Gemini
generateContent时,tool function parameters 中的 JSON Schema union 不符合 Gemini OpenAPI Schema 约束的问题。之前
string | null会被转换成一个本身没有type的anyOf,导致 Gemini / Vertex 在提交 function declaration 时返回schema didn't specify the schema type field。TypeBox literal union 里的const也会被 allowlist 静默丢弃,使枚举约束失效。现在共享 Gemini schema cleaner 会:
null的 union 折叠为明确type+nullable: true。type+enum。anyOf补充父层type,同时保留原有分支约束。const。修复位于
relaykit共享转换层,因此同时覆盖 Gemini 渠道、Vertex Gemini 模式和使用相同 converter 的 Advanced Custom 路由。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
📸 运行证明 / Proof of Work
cd relaykit && GOWORK=off go test ./...cd relaykit && GOWORK=off go build ./...cd relaykit && GOWORK=off go vet ./...mainpackage 外的 Go packages 测试通过;mainpackage 在本地因未生成web/distembed 产物而无法 setup,与本次 relaykit 改动无关。