fix(microsoft-foundry): allow MAI image deployment prefixes

This commit is contained in:
Vincent Koc
2026-06-09 14:11:52 +09:00
parent 34e76e6e6f
commit ea51c3ea50
2 changed files with 24 additions and 1 deletions

View File

@@ -375,6 +375,27 @@ describe("microsoft foundry image generation provider", () => {
});
});
it("allows custom mai-image deployment names for generation without model metadata", async () => {
postJsonRequestMock.mockResolvedValue(
releasedJson({
data: [{ b64_json: Buffer.from("png").toString("base64") }],
}),
);
const provider = buildMicrosoftFoundryImageGenerationProvider();
await provider.generateImage({
provider: PROVIDER_ID,
model: "mai-image-2-live",
prompt: "draw it",
cfg: buildConfig({ modelId: "mai-image-2-live", includeModel: false }),
});
expect(postJsonRequestMock).toHaveBeenCalledOnce();
expect(requirePostJsonRequest().body).toMatchObject({
model: "mai-image-2-live",
});
});
it("allows manual custom deployment names when configured name only repeats the id", async () => {
postJsonRequestMock.mockResolvedValue(
releasedJson({

View File

@@ -66,9 +66,11 @@ function ensureMaiImageModel(
model: string,
): { modelName: string; hasMetadata: boolean } {
const resolved = resolveConfiguredModelName(providerConfig, model);
const normalizedModel = normalizeOptionalLowercaseString(model);
if (
!isFoundryMaiImageModel(resolved.modelName) &&
(resolved.hasMetadata || normalizeOptionalLowercaseString(model)?.startsWith("mai-"))
(resolved.hasMetadata ||
(normalizedModel?.startsWith("mai-") && !normalizedModel.startsWith("mai-image-")))
) {
throw new Error(
`Microsoft Foundry image generation supports MAI image deployments only, got "${resolved.modelName}".`,