fix(wp7-02): restore native Gemini image routing
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 1m45s

This commit is contained in:
suyx
2026-08-04 17:58:33 +08:00
parent 534c82678a
commit 75a589dad8
2 changed files with 11 additions and 11 deletions
+7 -7
View File
@@ -1,25 +1,25 @@
{ {
"config_set_version": 3, "config_set_version": 4,
"gateway_account_ref": "oneapi-intelligrow-test", "gateway_account_ref": "oneapi-intelligrow-test",
"models": [ "models": [
{ {
"config_version": 2, "config_version": 3,
"gateway_account_ref": "oneapi-intelligrow-test", "gateway_account_ref": "oneapi-intelligrow-test",
"model_id": "gemini-3.1-flash-image-preview", "model_id": "gemini-3.1-flash-image-preview",
"route_profile": { "route_profile": {
"endpoint": "https://oneapi.intelligrow.cn/v1/models/gemini-3.1-flash-image-preview:generateContent", "endpoint": "https://oneapi.intelligrow.cn/v1beta/models/gemini-3.1-flash-image-preview:generateContent",
"mode": "sync", "mode": "sync",
"protocol_version": "gemini-native-v1" "protocol_version": "gemini-native-v1beta"
} }
}, },
{ {
"config_version": 2, "config_version": 3,
"gateway_account_ref": "oneapi-intelligrow-test", "gateway_account_ref": "oneapi-intelligrow-test",
"model_id": "gemini-3-pro-image-preview", "model_id": "gemini-3-pro-image-preview",
"route_profile": { "route_profile": {
"endpoint": "https://oneapi.intelligrow.cn/v1/models/gemini-3-pro-image-preview:generateContent", "endpoint": "https://oneapi.intelligrow.cn/v1beta/models/gemini-3-pro-image-preview:generateContent",
"mode": "sync", "mode": "sync",
"protocol_version": "gemini-native-v1" "protocol_version": "gemini-native-v1beta"
} }
}, },
{ {
+4 -4
View File
@@ -26,7 +26,7 @@ function assertModelConfig(modelConfig) {
const profile = modelConfig.route_profile; const profile = modelConfig.route_profile;
if (!profile || typeof profile !== "object" || typeof profile.endpoint !== "string" if (!profile || typeof profile !== "object" || typeof profile.endpoint !== "string"
|| !profile.endpoint.startsWith("https://oneapi.intelligrow.cn/") || !profile.endpoint.startsWith("https://oneapi.intelligrow.cn/")
|| !["gemini-native-v1", "openai-images-v1"].includes(profile.protocol_version)) { || !["gemini-native-v1beta", "openai-images-v1"].includes(profile.protocol_version)) {
throw new Error("WP7_02_ROUTE_PROFILE_INVALID"); throw new Error("WP7_02_ROUTE_PROFILE_INVALID");
} }
if (profile.protocol_version === "openai-images-v1" if (profile.protocol_version === "openai-images-v1"
@@ -69,14 +69,14 @@ export function buildProviderRequest({ modelConfig, prompt, ratio, reference })
throw new Error("WP7_02_REFERENCE_FIXTURE_INVALID"); throw new Error("WP7_02_REFERENCE_FIXTURE_INVALID");
} }
const headers = { "content-type": "application/json" }; const headers = { "content-type": "application/json" };
if (config.route_profile.protocol_version === "gemini-native-v1") { if (config.route_profile.protocol_version === "gemini-native-v1beta") {
const parts = [{ text: prompt }]; const parts = [{ text: prompt }];
if (reference) parts.push({ inlineData: { data: reference.bytes.toString("base64"), mimeType: reference.mime_type } }); if (reference) parts.push({ inlineData: { data: reference.bytes.toString("base64"), mimeType: reference.mime_type } });
return { return {
body: { body: {
contents: [{ parts, role: "user" }], contents: [{ parts, role: "user" }],
generationConfig: { generationConfig: {
responseFormat: { image: { aspectRatio: ratio, imageSize: "1K" } }, imageConfig: { aspectRatio: ratio, imageSize: "1K" },
responseModalities: ["IMAGE"], responseModalities: ["IMAGE"],
}, },
}, },
@@ -180,7 +180,7 @@ export function normalizeProviderResponse(modelConfig, response) {
let bytes; let bytes;
let mime; let mime;
let usageSummary; let usageSummary;
if (config.route_profile.protocol_version === "gemini-native-v1") { if (config.route_profile.protocol_version === "gemini-native-v1beta") {
const parts = response?.candidates?.flatMap((candidate) => candidate?.content?.parts ?? []) ?? []; const parts = response?.candidates?.flatMap((candidate) => candidate?.content?.parts ?? []) ?? [];
const images = parts.map((part) => part?.inlineData ?? part?.inline_data).filter((entry) => entry?.data); const images = parts.map((part) => part?.inlineData ?? part?.inline_data).filter((entry) => entry?.data);
if (images.length !== 1) throw new Error("WP7_02_RESPONSE_SINGLE_IMAGE_REQUIRED"); if (images.length !== 1) throw new Error("WP7_02_RESPONSE_SINGLE_IMAGE_REQUIRED");