mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-17 08:33: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
103
openclaw/extensions/google/music-generation-provider.test.ts
Normal file
103
openclaw/extensions/google/music-generation-provider.test.ts
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { GoogleGenAIMock, generateContentMock } = vi.hoisted(() => {
|
||||
const generateContentMock = vi.fn();
|
||||
const GoogleGenAIMock = vi.fn(function GoogleGenAI() {
|
||||
return {
|
||||
models: {
|
||||
generateContent: generateContentMock,
|
||||
},
|
||||
};
|
||||
});
|
||||
return { GoogleGenAIMock, generateContentMock };
|
||||
});
|
||||
|
||||
vi.mock("@google/genai", () => ({
|
||||
GoogleGenAI: GoogleGenAIMock,
|
||||
}));
|
||||
|
||||
import * as providerAuthRuntime from "openclaw/plugin-sdk/provider-auth-runtime";
|
||||
import { expectExplicitMusicGenerationCapabilities } from "../../test/helpers/media-generation/provider-capability-assertions.js";
|
||||
import { buildGoogleMusicGenerationProvider } from "./music-generation-provider.js";
|
||||
|
||||
describe("google music generation provider", () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
generateContentMock.mockReset();
|
||||
GoogleGenAIMock.mockClear();
|
||||
});
|
||||
|
||||
it("declares explicit mode capabilities", () => {
|
||||
expectExplicitMusicGenerationCapabilities(buildGoogleMusicGenerationProvider());
|
||||
});
|
||||
|
||||
it("submits generation and returns inline audio bytes plus lyrics", async () => {
|
||||
vi.spyOn(providerAuthRuntime, "resolveApiKeyForProvider").mockResolvedValue({
|
||||
apiKey: "google-key",
|
||||
source: "env",
|
||||
mode: "api-key",
|
||||
});
|
||||
generateContentMock.mockResolvedValue({
|
||||
candidates: [
|
||||
{
|
||||
content: {
|
||||
parts: [
|
||||
{ text: "wake the city up" },
|
||||
{
|
||||
inlineData: {
|
||||
data: Buffer.from("mp3-bytes").toString("base64"),
|
||||
mimeType: "audio/mpeg",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const provider = buildGoogleMusicGenerationProvider();
|
||||
const result = await provider.generateMusic({
|
||||
provider: "google",
|
||||
model: "lyria-3-clip-preview",
|
||||
prompt: "upbeat synthpop anthem",
|
||||
cfg: {},
|
||||
instrumental: true,
|
||||
});
|
||||
|
||||
expect(generateContentMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
model: "lyria-3-clip-preview",
|
||||
config: {
|
||||
responseModalities: ["AUDIO", "TEXT"],
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(result.tracks).toHaveLength(1);
|
||||
expect(result.tracks[0]?.mimeType).toBe("audio/mpeg");
|
||||
expect(result.lyrics).toEqual(["wake the city up"]);
|
||||
expect(GoogleGenAIMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
apiKey: "google-key",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects unsupported wav output on clip model", async () => {
|
||||
vi.spyOn(providerAuthRuntime, "resolveApiKeyForProvider").mockResolvedValue({
|
||||
apiKey: "google-key",
|
||||
source: "env",
|
||||
mode: "api-key",
|
||||
});
|
||||
const provider = buildGoogleMusicGenerationProvider();
|
||||
|
||||
await expect(
|
||||
provider.generateMusic({
|
||||
provider: "google",
|
||||
model: "lyria-3-clip-preview",
|
||||
prompt: "ambient ocean",
|
||||
cfg: {},
|
||||
format: "wav",
|
||||
}),
|
||||
).rejects.toThrow("supports mp3 output");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue