test(qa-lab): use OpenAI plugin for mock image generation · openclaw/openclaw@dda2cf4
steipete
·
2026-05-03
·
via Recent Commits to openclaw:main
File tree
extensions/qa-lab/src/providers
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,16 +2,18 @@ import { describe, expect, it } from "vitest";
|
2 | 2 | import { buildQaImageGenerationConfigPatch } from "./image-generation.js"; |
3 | 3 | |
4 | 4 | describe("QA provider image generation config", () => { |
5 | | -it("uses the selected mock provider for mock-openai image generation", () => { |
| 5 | +it("uses the OpenAI image provider against the selected mock-openai endpoint", () => { |
6 | 6 | const patch = buildQaImageGenerationConfigPatch({ |
7 | 7 | providerMode: "mock-openai", |
8 | 8 | providerBaseUrl: "http://127.0.0.1:44080/v1", |
9 | 9 | requiredPluginIds: ["qa-channel"], |
10 | 10 | }); |
11 | 11 | |
12 | | -expect(patch.plugins.allow).toEqual(["acpx", "memory-core", "qa-channel"]); |
13 | | -expect(patch.agents.defaults.imageGenerationModel.primary).toBe("mock-openai/gpt-image-1"); |
| 12 | +expect(patch.plugins.allow).toEqual(["acpx", "memory-core", "openai", "qa-channel"]); |
| 13 | +expect(patch.plugins.entries?.openai).toEqual({ enabled: true }); |
| 14 | +expect(patch.agents.defaults.imageGenerationModel.primary).toBe("openai/gpt-image-1"); |
14 | 15 | expect(patch.models?.providers["mock-openai"]?.baseUrl).toBe("http://127.0.0.1:44080/v1"); |
| 16 | +expect(patch.models?.providers.openai?.baseUrl).toBe("http://127.0.0.1:44080/v1"); |
15 | 17 | }); |
16 | 18 | |
17 | 19 | it("preserves already-allowed plugins when configuring image generation", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -22,9 +22,12 @@ function uniqueNonEmpty(values: readonly (string | null | undefined)[]) {
|
22 | 22 | |
23 | 23 | export function buildQaImageGenerationConfigPatch(input: QaImageGenerationPatchInput) { |
24 | 24 | const provider = getQaProvider(input.providerMode); |
25 | | -const imageModelRef = provider.defaultImageGenerationModel({ |
26 | | -modelProviderIds: provider.defaultImageGenerationProviderIds, |
27 | | -}); |
| 25 | +const usesOpenAiMockImageProvider = input.providerMode === "mock-openai"; |
| 26 | +const imageModelRef = usesOpenAiMockImageProvider |
| 27 | + ? "openai/gpt-image-1" |
| 28 | + : provider.defaultImageGenerationModel({ |
| 29 | +modelProviderIds: provider.defaultImageGenerationProviderIds, |
| 30 | +}); |
28 | 31 | if (!imageModelRef) { |
29 | 32 | throw new Error( |
30 | 33 | `QA provider "${input.providerMode}" does not expose an image generation model`, |
@@ -42,7 +45,8 @@ export function buildQaImageGenerationConfigPatch(input: QaImageGenerationPatchI
|
42 | 45 | providerBaseUrl: input.providerBaseUrl, |
43 | 46 | }); |
44 | 47 | })(); |
45 | | -const providerPluginIds = provider.usesModelProviderPlugins ? [imageProviderId] : []; |
| 48 | +const providerPluginIds = |
| 49 | +provider.usesModelProviderPlugins || usesOpenAiMockImageProvider ? [imageProviderId] : []; |
46 | 50 | const enabledPluginIds = uniqueNonEmpty(providerPluginIds); |
47 | 51 | |
48 | 52 | return { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。