fix(models): 模型目录 - 保留人工能力并按声明发送视频分辨率

This commit is contained in:
ddCat committed 2026-08-17 12:56:51 +08:00
1 parent 050a95c1d5
commit c2352fd9b6
11 files changed
+218 -48

No files matched your search

+44
View File
@@ -127,6 +127,14 @@ describe("public channel model catalog", () => {
const createSource = await Bun.file(new URL("../src/pages/create/index.tsx", import.meta.url)).text();
expect(createSource).toContain('const videoResolutionSupported = props.mode === "video" && resolutions.length > 0;');
expect(createSource).toContain("...(videoResolutionSupported ? [videoResolutionLabel(props.videoQuality)] : [])");
let requestBody: Record<string, unknown> = {};
axios.post = (async (_url: string, body: Record<string, unknown>) => {
requestBody = body;
return { data: { id: "endpoint-video-task" } };
}) as typeof axios.post;
await createVideoGenerationTask(config, "synthetic prompt");
expect(requestBody).not.toHaveProperty("resolution");
});
test("preserves a manually configured capability profile when a catalog only returns an ID", () => {
@@ -180,6 +188,42 @@ describe("public channel model catalog", () => {
expect(costs[0]).toEqual({ ...existing, displayName: "Catalog Video" });
});
test("uses modelType only for capability and preserves an existing manual protocol and profile", () => {
const channel = createModelChannel({
id: "manual-partial",
name: "Manual Partial",
baseUrl: "https://manual.example",
apiKey: "synthetic-test-key",
apiFormat: "openai",
interfaceType: "chat-completion",
models: ["video-x"],
});
const capabilityConfig = defaultModelCapabilityConfig("gemini-veo", "video-x");
capabilityConfig.video!.resolutions = ["1440p"];
capabilityConfig.video!.defaultResolution = "1440p";
channel.modelCosts = [{ model: "video-x", capability: "video", protocol: "gemini-veo", billingMode: "per_second", unitPriceMicrocredits: 7654, capabilityConfig }];
const costs = mergeFetchedChannelModelCosts(channel, [{ id: "video-x", modelType: "video" }]);
expect(costs).toEqual(channel.modelCosts);
});
test("requires the declared minimum image count and selects image-to-video", async () => {
const catalog: ChannelModelCatalogItem = {
id: "image-required-video",
modelType: "video",
minImages: 1,
maxImages: 2,
};
const config = configForCatalog([catalog]);
const profile = config.channels[0]!.modelCosts![0]!.capabilityConfig!.video!;
expect(profile.references).toMatchObject({ minImages: 1, maxImages: 2 });
expect(profile.operations).toEqual(["image_to_video"]);
expect(profile.defaultOperation).toBe("image_to_video");
expect(createVideoGenerationTask(config, "synthetic prompt")).rejects.toThrow("至少需要 1 张参考图");
});
test("preserves an ID-only manual video model cost when both protocol sources are missing", () => {
const channel = createModelChannel({
id: "manual-no-protocol",