fix: route runway video models through video branch
This commit is contained in:
parent
7e7685410f
commit
1eb23a015f
@ -7972,14 +7972,16 @@ export async function POST(request: Request) {
|
|||||||
// ========== Gemini 处理结束 ==========
|
// ========== Gemini 处理结束 ==========
|
||||||
|
|
||||||
// ========== 阿里云千问图片生成独立处理 ==========
|
// ========== 阿里云千问图片生成独立处理 ==========
|
||||||
const isAlibabaLikeImageProvider = [
|
const isAlibabaLikeImageProvider =
|
||||||
"alibaba-image",
|
isImageGenerationModel &&
|
||||||
"ruxa-image",
|
[
|
||||||
"fal-image",
|
"alibaba-image",
|
||||||
"openai-image",
|
"ruxa-image",
|
||||||
"midjourney",
|
"fal-image",
|
||||||
"runway",
|
"openai-image",
|
||||||
].includes((languageModel as any).provider);
|
"midjourney",
|
||||||
|
"runway",
|
||||||
|
].includes((languageModel as any).provider);
|
||||||
if (isAlibabaLikeImageProvider && typeof (languageModel as any).doGenerate === "function") {
|
if (isAlibabaLikeImageProvider && typeof (languageModel as any).doGenerate === "function") {
|
||||||
console.log("[Chat API] Using image generation provider:", (languageModel as any).provider);
|
console.log("[Chat API] Using image generation provider:", (languageModel as any).provider);
|
||||||
console.log("[Chat API] Image params:", effectiveImageParams);
|
console.log("[Chat API] Image params:", effectiveImageParams);
|
||||||
|
|||||||
@ -71,8 +71,9 @@ function joinEndpoint(baseURL: string, path: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildHeaders(apiKey: string) {
|
function buildHeaders(apiKey: string) {
|
||||||
|
const normalizedApiKey = normalizeRunwayCredentials(apiKey);
|
||||||
return {
|
return {
|
||||||
Authorization: `Bearer ${String(apiKey || "").trim()}`,
|
Authorization: `Bearer ${normalizedApiKey}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-Runway-Version": RUNWAY_VERSION,
|
"X-Runway-Version": RUNWAY_VERSION,
|
||||||
};
|
};
|
||||||
@ -82,6 +83,14 @@ function normalizeText(value: string) {
|
|||||||
return String(value || "").replace(/\u00a0/g, " ").trim().normalize("NFKC");
|
return String(value || "").replace(/\u00a0/g, " ").trim().normalize("NFKC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeRunwayCredentials(apiKey: string) {
|
||||||
|
const normalized = normalizeText(apiKey);
|
||||||
|
const stripped = normalized.replace(/^bearer\s+/i, "").replace(/^key\s+/i, "");
|
||||||
|
const kvMatch = stripped.match(/^(?:runway[_-]?api[_-]?key|api[_-]?key|token)\s*[::]\s*(.+)$/i);
|
||||||
|
const candidate = kvMatch?.[1] ? kvMatch[1] : stripped;
|
||||||
|
return candidate.trim().replace(/[^\x20-\x7E]/g, "");
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeImageSizeLabel(imageSize?: string): "1K" | "2K" | "4K" {
|
function normalizeImageSizeLabel(imageSize?: string): "1K" | "2K" | "4K" {
|
||||||
const normalized = String(imageSize || "").trim().toUpperCase();
|
const normalized = String(imageSize || "").trim().toUpperCase();
|
||||||
if (normalized === "1K" || normalized === "2K" || normalized === "4K") {
|
if (normalized === "1K" || normalized === "2K" || normalized === "4K") {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user