fix(web): 模型目录 - 禁止端点元数据伪造视频分辨率
This commit is contained in:
1 parent
6d6ad67dae
commit
b24d3e897f
2 files changed
+26
-11
No files matched your search
@@ -80,9 +80,7 @@ export function mergeFetchedChannelModelCosts(channel: ModelChannel, catalog: Ch
|
|||||||
if (!protocol || !capability) continue;
|
if (!protocol || !capability) continue;
|
||||||
const protocolChanged = Boolean(existing && inferredProtocol && existing.protocol !== inferredProtocol);
|
const protocolChanged = Boolean(existing && inferredProtocol && existing.protocol !== inferredProtocol);
|
||||||
const replaceCapabilityConfig = !existing || catalogBackedCapability || protocolChanged;
|
const replaceCapabilityConfig = !existing || catalogBackedCapability || protocolChanged;
|
||||||
const capabilityConfig = replaceCapabilityConfig && (capability === "image" || capability === "video")
|
const capabilityConfig = replaceCapabilityConfig && (capability === "image" || capability === "video") ? (catalogBackedCapability ? catalogCapabilityConfig(item, protocol, capability) : defaultModelCapabilityConfig(protocol, item.id)) : undefined;
|
||||||
? (catalogBackedCapability ? catalogCapabilityConfig(item, protocol, capability) : defaultModelCapabilityConfig(protocol, item.id))
|
|
||||||
: undefined;
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
next.push({
|
next.push({
|
||||||
...existing,
|
...existing,
|
||||||
@@ -107,14 +105,7 @@ export function mergeFetchedChannelModelCosts(channel: ModelChannel, catalog: Ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hasCatalogCapabilityMetadata(item: ChannelModelCatalogItem) {
|
function hasCatalogCapabilityMetadata(item: ChannelModelCatalogItem) {
|
||||||
return Boolean(
|
return Boolean(item.modelType || item.supportedEndpointTypes?.length || item.defaultParameters || item.options || item.supportsImages !== undefined || item.minImages !== undefined || item.maxImages !== undefined);
|
||||||
item.modelType ||
|
|
||||||
item.defaultParameters ||
|
|
||||||
item.options ||
|
|
||||||
item.supportsImages !== undefined ||
|
|
||||||
item.minImages !== undefined ||
|
|
||||||
item.maxImages !== undefined,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function catalogCapabilityConfig(item: ChannelModelCatalogItem, protocol: ModelProtocol, capability: "image" | "video"): ModelCapabilityConfig {
|
function catalogCapabilityConfig(item: ChannelModelCatalogItem, protocol: ModelProtocol, capability: "image" | "video"): ModelCapabilityConfig {
|
||||||
|
|||||||
@@ -105,6 +105,30 @@ describe("public channel model catalog", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("treats endpoint-only video metadata as authoritative without inventing 720P", async () => {
|
||||||
|
const catalog: ChannelModelCatalogItem = {
|
||||||
|
id: "endpoint-video",
|
||||||
|
supportedEndpointTypes: ["openai-video"],
|
||||||
|
};
|
||||||
|
const config = configForCatalog([catalog], { videoSeconds: "6", size: "16:9", vquality: "720" });
|
||||||
|
const model = "flow::endpoint-video";
|
||||||
|
const cost = config.channels[0]!.modelCosts![0]!;
|
||||||
|
|
||||||
|
expect(cost.capability).toBe("video");
|
||||||
|
expect(cost.protocol).toBe("newapi-channel-2");
|
||||||
|
expect(cost.capabilityConfig?.video?.resolutions).toEqual([]);
|
||||||
|
expect(cost.capabilityConfig?.video?.defaultResolution).toBe("");
|
||||||
|
expect(selectableModelsByCapability(config, "video")).toEqual([model]);
|
||||||
|
expect(resolveModelRequestConfig(config, model).interfaceType).toBe("newapi-channel-2");
|
||||||
|
|
||||||
|
const canvasHtml = renderToStaticMarkup(React.createElement(CanvasVideoSettingsPopover, { config, onConfigChange: () => undefined }));
|
||||||
|
expect(canvasHtml).not.toContain("720P");
|
||||||
|
|
||||||
|
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)] : [])");
|
||||||
|
});
|
||||||
|
|
||||||
test("preserves a manually configured capability profile when a catalog only returns an ID", () => {
|
test("preserves a manually configured capability profile when a catalog only returns an ID", () => {
|
||||||
const channel = createModelChannel({
|
const channel = createModelChannel({
|
||||||
id: "manual",
|
id: "manual",
|
||||||
|
|||||||
Reference in new issue
Block a user