fix(ai): update vip98k image task contract

This commit is contained in:
134 2026-08-25 12:59:53 +08:00 committed by root
parent dfb50c83fa
commit bcb21344ba
2 changed files with 1 additions and 41 deletions

View File

@ -2,7 +2,6 @@ import "server-only";
import { createOpenAI } from "@ai-sdk/openai";
import sharp from "sharp";
import { createOpenAIImage } from "@/lib/ai/providers/openai-image";
import {
resolveVip98kTaskInvocation,
type Vip98kTaskInvocation,
@ -134,25 +133,6 @@ function inferKind(modelId: string, config: Vip98kModelRuntimeConfig) {
return "chat";
}
const VIP98K_OPENAI_IMAGE_ALIASES = new Set([
"nano-banana-2",
"nano-banana-pro",
"gpt-image-2-vip",
]);
function resolveVip98kReferenceModelId(modelId: string) {
switch (modelId.trim().toLowerCase()) {
case "nano-banana-2":
return "google/nano-banana-2/reference-to-image";
case "nano-banana-pro":
return "google/nano-banana-pro/edit";
case "gpt-image-2-vip":
return "openai/gpt-image-2/edit";
default:
return modelId;
}
}
function delay(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
@ -838,11 +818,6 @@ export function createVip98k({ apiKey, baseURL }: Vip98kConfig) {
apiKey,
baseURL: openAIBaseURL,
});
const openAIImageProvider = createOpenAIImage({
apiKey,
baseURL: openAIBaseURL,
});
return {
provider: "vip98k",
chat: (modelId: string, defaultModelConfig?: unknown): any => {
@ -873,25 +848,14 @@ export function createVip98k({ apiKey, baseURL }: Vip98kConfig) {
if (!activeModelId) throw new Error("VIP98K model ID is not configured");
const activeKind = inferKind(activeModelId, runtimeConfig);
const { prompt, imageUrls, videoUrls } = extractPromptAndMedia(options.messages);
if (
activeKind === "image" &&
imageUrls.length === 0 &&
VIP98K_OPENAI_IMAGE_ALIASES.has(activeModelId.toLowerCase())
) {
return openAIImageProvider.chat(activeModelId).doGenerate(options as any);
}
const [publicImageUrls, publicVideoUrls] = await Promise.all([
Promise.all(imageUrls.map(ensurePublicMediaUrl)),
Promise.all(videoUrls.map(ensurePublicMediaUrl)),
]);
const taskModelId =
activeKind === "image" && publicImageUrls.length > 0
? resolveVip98kReferenceModelId(activeModelId)
: activeModelId;
const text = await runTask({
apiKey,
baseURL: rootBaseURL,
modelId: taskModelId,
modelId: activeModelId,
kind: activeKind,
prompt,
imageUrls: publicImageUrls,

View File

@ -1014,10 +1014,6 @@ export async function fetchVip98kCatalog(params: {
if (authorizedModels.length === 0) {
throw new Error("VIP98K model catalog is empty or has an unsupported response shape");
}
if (publicModels.length === 0) {
throw new Error("VIP98K public invocation catalog is empty");
}
const publicById = new Map(
publicModels.map((model) => [getModelId(model).toLowerCase(), model]),
);