30 lines
965 B
TypeScript
30 lines
965 B
TypeScript
const ALIBABA_IMAGE_SYNC_PATH =
|
|
"/api/v1/services/aigc/multimodal-generation/generation";
|
|
const ALIBABA_IMAGE_ASYNC_PATH =
|
|
"/api/v1/services/aigc/image-generation/generation";
|
|
|
|
export function isAlibabaQwenImage3ModelId(modelId: string) {
|
|
return /^qwen-image-3(?:\.0)?(?:$|[-/])/i.test(String(modelId || "").trim());
|
|
}
|
|
|
|
export function resolveAlibabaImageAsyncEndpoint(baseURL: string) {
|
|
const parsed = new URL(baseURL);
|
|
parsed.pathname = parsed.pathname.includes(ALIBABA_IMAGE_SYNC_PATH)
|
|
? parsed.pathname.replace(ALIBABA_IMAGE_SYNC_PATH, ALIBABA_IMAGE_ASYNC_PATH)
|
|
: ALIBABA_IMAGE_ASYNC_PATH;
|
|
parsed.search = "";
|
|
parsed.hash = "";
|
|
return parsed.toString();
|
|
}
|
|
|
|
export function resolveAlibabaImageTaskEndpoint(
|
|
requestEndpoint: string,
|
|
taskId: string,
|
|
) {
|
|
const parsed = new URL(requestEndpoint);
|
|
parsed.pathname = `/api/v1/tasks/${encodeURIComponent(taskId)}`;
|
|
parsed.search = "";
|
|
parsed.hash = "";
|
|
return parsed.toString();
|
|
}
|