fix(*): 模型与数据同步 - 完善鉴权、供应商模型和本地持久化能力
This commit is contained in:
@@ -31,6 +31,8 @@ export function generationErrorMessage(error: unknown) {
|
||||
const providerMessage = extractStructuredProviderMessage(raw) || extractWrappedProviderMessage(raw);
|
||||
const displayMessage = providerMessage || raw;
|
||||
if (isContentModerationError(displayMessage)) return CONTENT_MODERATION_MESSAGE;
|
||||
const resourceStorageMessage = resourceStorageFailureMessage(raw) || resourceStorageFailureMessage(displayMessage);
|
||||
if (resourceStorageMessage) return resourceStorageMessage;
|
||||
if (isNetworkFailure(displayMessage)) return NETWORK_ERROR_MESSAGE;
|
||||
if (!providerMessage) {
|
||||
if (hasHttpStatus(raw, 429)) return "服务当前繁忙,请稍后重试。";
|
||||
@@ -133,3 +135,12 @@ function hasHttpStatus(value: string, ...statuses: number[]) {
|
||||
function containsInfrastructureDetails(value: string) {
|
||||
return /(?:接口请求失败|Request failed with status code|https?:\/\/|\b(?:GET|POST|PUT|PATCH|DELETE)\s+["']?|Bad Gateway|Service Unavailable|Gateway Timeout|upstream_error)/i.test(value);
|
||||
}
|
||||
|
||||
function resourceStorageFailureMessage(value: string) {
|
||||
if (!value) return "";
|
||||
if (/\bUserDisable\b/i.test(value)) return "对象存储账号已停用,请检查或更换对象存储配置。";
|
||||
if (/(?:参考(?:图片|媒体)上传失败|OSS 上传失败|对象存储|腾讯云 COS|七牛云)/i.test(value)) {
|
||||
return "参考素材上传到对象存储失败,请检查对象存储配置后重试。";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -301,6 +301,21 @@ export function defaultModelCapabilityConfig(protocol?: ModelProtocol, model = "
|
||||
video.resolutions = ["1080p"];
|
||||
video.defaultResolution = "1080p";
|
||||
}
|
||||
if (protocol === "minimax-video") {
|
||||
video.references.maxImages = 9;
|
||||
video.references.maxImageBytes = 30 * 1024 * 1024;
|
||||
video.references.maxVideos = 3;
|
||||
video.references.maxVideoBytes = 50 * 1024 * 1024;
|
||||
video.references.maxVideoDurationSeconds = 15;
|
||||
video.references.maxAudios = 3;
|
||||
video.references.maxAudioBytes = 15 * 1024 * 1024;
|
||||
video.references.maxAudioDurationSeconds = 15;
|
||||
video.duration = { selection: "enum", values: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], default: 5 };
|
||||
video.ratios = ["adaptive", "21:9", "16:9", "4:3", "1:1", "3:4", "9:16"];
|
||||
video.resolutions = ["768P", "2K"];
|
||||
video.defaultResolution = "768P";
|
||||
video.watermark = { supported: true, default: false };
|
||||
}
|
||||
return { version: 1, text, image: defaultImageCapabilityConfig(protocol, model), video };
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ export type ModelProtocol =
|
||||
| "volcengine-ark-video"
|
||||
| "volcengine-jimeng-video"
|
||||
| "gemini-veo"
|
||||
| "novita-video";
|
||||
| "novita-video"
|
||||
| "minimax-video";
|
||||
|
||||
export type ProtocolCapability = "text" | "image" | "video" | "audio";
|
||||
|
||||
@@ -63,6 +64,7 @@ export const MODEL_PROTOCOLS: ModelProtocolDefinition[] = [
|
||||
{ value: "volcengine-jimeng-video", label: "即梦官方视频", capability: "video", create: "POST CVSync2AsyncSubmitTask", poll: "POST CVSync2AsyncGetResult", contentType: "application/json + AK/SK 签名", media: "文本或一张首帧图,模型标识填写 req_key" },
|
||||
{ value: "gemini-veo", label: "Gemini Veo", capability: "video", create: "POST /v1beta/models/{model}:predictLongRunning", poll: "GET /v1beta/{operation_name}", contentType: "application/json", media: "文本与单张起始图" },
|
||||
{ value: "novita-video", label: "Novita 视频", capability: "video", create: "POST /v3/video/create", poll: "GET /v3/async/task-result?task_id={id}", contentType: "application/json", media: "文本或单张起始图" },
|
||||
{ value: "minimax-video", label: "MiniMax 视频", capability: "video", create: "POST /v2/video_generation", poll: "GET /v2/query/video_generation/{task_id}", contentType: "application/json", media: "文本、图片、视频、音频参考素材" },
|
||||
];
|
||||
|
||||
export const MODEL_PROTOCOL_OPTIONS = protocolGroups(MODEL_PROTOCOLS.filter((item) => !item.value.startsWith("volcengine-jimeng-")));
|
||||
|
||||
@@ -54,8 +54,10 @@ export async function applyUserSession(payload: AuthSessionPayload) {
|
||||
useConfigStore.getState().mergeSystemChannels(managedModelChannels(payload.logicalModels || []));
|
||||
}
|
||||
installRemoteUserDataAutoSync();
|
||||
if (payload.user?.id) await syncRemoteUserData(payload.user.id);
|
||||
else resetRemoteUserDataSync();
|
||||
if (payload.user?.id) {
|
||||
// 认证状态先完成,云端数据在后台合并;远端同步失败不能伪装成登录失败。
|
||||
void syncRemoteUserData(payload.user.id).catch((error) => console.warn("登录后云端数据同步失败,保留本地数据等待重试", error));
|
||||
} else resetRemoteUserDataSync();
|
||||
} finally {
|
||||
useUserStore.getState().setHydrated(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user