mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-19 03:03:27 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
152
openclaw/extensions/minimax/music-generation-provider.test.ts
Normal file
152
openclaw/extensions/minimax/music-generation-provider.test.ts
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { expectExplicitMusicGenerationCapabilities } from "../../test/helpers/media-generation/provider-capability-assertions.js";
|
||||
import {
|
||||
getMinimaxProviderHttpMocks,
|
||||
installMinimaxProviderHttpMockCleanup,
|
||||
loadMinimaxMusicGenerationProviderModule,
|
||||
} from "./provider-http.test-helpers.js";
|
||||
|
||||
const { postJsonRequestMock, fetchWithTimeoutMock } = getMinimaxProviderHttpMocks();
|
||||
|
||||
let buildMinimaxMusicGenerationProvider: Awaited<
|
||||
ReturnType<typeof loadMinimaxMusicGenerationProviderModule>
|
||||
>["buildMinimaxMusicGenerationProvider"];
|
||||
|
||||
beforeAll(async () => {
|
||||
({ buildMinimaxMusicGenerationProvider } = await loadMinimaxMusicGenerationProviderModule());
|
||||
});
|
||||
|
||||
installMinimaxProviderHttpMockCleanup();
|
||||
|
||||
function mockMusicGenerationResponse(json: Record<string, unknown>): void {
|
||||
postJsonRequestMock.mockResolvedValue({
|
||||
response: {
|
||||
json: async () => json,
|
||||
},
|
||||
release: vi.fn(async () => {}),
|
||||
});
|
||||
fetchWithTimeoutMock.mockResolvedValue({
|
||||
headers: new Headers({ "content-type": "audio/mpeg" }),
|
||||
arrayBuffer: async () => Buffer.from("mp3-bytes"),
|
||||
});
|
||||
}
|
||||
|
||||
describe("minimax music generation provider", () => {
|
||||
it("declares explicit mode capabilities", () => {
|
||||
expectExplicitMusicGenerationCapabilities(buildMinimaxMusicGenerationProvider());
|
||||
});
|
||||
|
||||
it("creates music and downloads the generated track", async () => {
|
||||
mockMusicGenerationResponse({
|
||||
task_id: "task-123",
|
||||
audio_url: "https://example.com/out.mp3",
|
||||
lyrics: "our city wakes",
|
||||
base_resp: { status_code: 0 },
|
||||
});
|
||||
|
||||
const provider = buildMinimaxMusicGenerationProvider();
|
||||
const result = await provider.generateMusic({
|
||||
provider: "minimax",
|
||||
model: "music-2.5+",
|
||||
prompt: "upbeat dance-pop with female vocals",
|
||||
cfg: {},
|
||||
lyrics: "our city wakes",
|
||||
durationSeconds: 45,
|
||||
});
|
||||
|
||||
expect(postJsonRequestMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
url: "https://api.minimax.io/v1/music_generation",
|
||||
headers: expect.objectContaining({
|
||||
get: expect.any(Function),
|
||||
}),
|
||||
body: expect.objectContaining({
|
||||
model: "music-2.5+",
|
||||
lyrics: "our city wakes",
|
||||
output_format: "url",
|
||||
audio_setting: {
|
||||
sample_rate: 44100,
|
||||
bitrate: 256000,
|
||||
format: "mp3",
|
||||
},
|
||||
}),
|
||||
}),
|
||||
);
|
||||
const headers = postJsonRequestMock.mock.calls[0]?.[0]?.headers as Headers | undefined;
|
||||
expect(headers?.get("content-type")).toBe("application/json");
|
||||
expect(result.tracks).toHaveLength(1);
|
||||
expect(result.lyrics).toEqual(["our city wakes"]);
|
||||
expect(result.metadata).toEqual(
|
||||
expect.objectContaining({
|
||||
taskId: "task-123",
|
||||
audioUrl: "https://example.com/out.mp3",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("downloads tracks when url output is returned in data.audio", async () => {
|
||||
mockMusicGenerationResponse({
|
||||
data: {
|
||||
audio: "https://example.com/url-audio.mp3",
|
||||
},
|
||||
base_resp: { status_code: 0 },
|
||||
});
|
||||
|
||||
const provider = buildMinimaxMusicGenerationProvider();
|
||||
const result = await provider.generateMusic({
|
||||
provider: "minimax",
|
||||
model: "music-2.5+",
|
||||
prompt: "upbeat dance-pop with female vocals",
|
||||
cfg: {},
|
||||
lyrics: "our city wakes",
|
||||
});
|
||||
|
||||
expect(fetchWithTimeoutMock).toHaveBeenCalledWith(
|
||||
"https://example.com/url-audio.mp3",
|
||||
{ method: "GET" },
|
||||
120000,
|
||||
fetch,
|
||||
);
|
||||
expect(result.tracks[0]?.buffer.byteLength).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("rejects instrumental requests that also include lyrics", async () => {
|
||||
const provider = buildMinimaxMusicGenerationProvider();
|
||||
|
||||
await expect(
|
||||
provider.generateMusic({
|
||||
provider: "minimax",
|
||||
model: "music-2.5+",
|
||||
prompt: "driving techno",
|
||||
cfg: {},
|
||||
instrumental: true,
|
||||
lyrics: "do not sing this",
|
||||
}),
|
||||
).rejects.toThrow("cannot use lyrics when instrumental=true");
|
||||
});
|
||||
|
||||
it("uses lyrics optimizer when lyrics are omitted", async () => {
|
||||
mockMusicGenerationResponse({
|
||||
task_id: "task-456",
|
||||
audio_url: "https://example.com/out.mp3",
|
||||
base_resp: { status_code: 0 },
|
||||
});
|
||||
|
||||
const provider = buildMinimaxMusicGenerationProvider();
|
||||
await provider.generateMusic({
|
||||
provider: "minimax",
|
||||
model: "music-2.5+",
|
||||
prompt: "upbeat dance-pop",
|
||||
cfg: {},
|
||||
});
|
||||
|
||||
expect(postJsonRequestMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
body: expect.objectContaining({
|
||||
model: "music-2.5+",
|
||||
lyrics_optimizer: true,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue