mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 02:52:15 +00:00
fix(microsoft-foundry): allow MAI image deployment prefixes
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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}".`,
|
||||
|
||||
Reference in New Issue
Block a user