Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Refuse redirects on Fish Audio speech-to-text too, and test every request

milind-soniaa5b6cfc9caf
diff --git a/scripts/podman-containerfile.test.mjs b/scripts/podman-containerfile.test.mjs
index a71ffa9c8d..645b134037 100644
--- a/scripts/podman-containerfile.test.mjs
+++ b/scripts/podman-containerfile.test.mjs
@@ -6,11 +6,10 @@ const buildCopies = (text) =>
[...text.matchAll(/^COPY --from=build (?:--chown=\S+ )?(\S+) (\S+)$/gm)].map(([, from, to]) => `${from} ${to}`);
describe("Podman image build", () => {
- it("ships everything the Docker server image ships from the build", () => {
+ it("ships the bundled skills, as the Docker server image does", () => {
const server = read("../Dockerfile").split(/^FROM runtime AS server$/m)[1];
expect(server).toBeDefined();
- const expected = buildCopies(server);
- expect(expected).toContain("/src/skills ./skills");
- expect(buildCopies(read("../deploy/podman/Containerfile"))).toEqual(expect.arrayContaining(expected));
+ expect(buildCopies(server)).toContain("/src/skills ./skills");
+ expect(buildCopies(read("../deploy/podman/Containerfile"))).toContain("/src/skills ./skills");
});
});
diff --git a/server/tts/fish.test.ts b/server/tts/fish.test.ts
index d4aad9c009..03d68c920a 100644
--- a/server/tts/fish.test.ts
+++ b/server/tts/fish.test.ts
@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it, vi } from "vitest";
-import { transcribe } from "./fish.ts";
+import { listVoices, synthesize, transcribe, verifyKey } from "./fish.ts";
afterEach(() => vi.unstubAllGlobals());
@@ -44,3 +44,17 @@ describe("Fish Audio transcribe", () => {
await expect(transcribe(new Uint8Array(4), "audio/wav", "k")).rejects.toThrow("Couldn't reach Fish Audio to hear you");
});
});
+
+describe("Fish Audio requests", () => {
+ it("refuse redirects, so the key and the person's audio go only to Fish", async () => {
+ const fetchMock = vi.fn(async () => new Response("{}", { status: 200 }));
+ vi.stubGlobal("fetch", fetchMock);
+ await verifyKey("k");
+ await listVoices("k");
+ await synthesize("hello", "voice", "k");
+ await transcribe(new Uint8Array(4), "audio/wav", "k");
+ const inits = (fetchMock.mock.calls as unknown as Array<[string, RequestInit]>).map(([, init]) => init);
+ expect(inits.length).toBeGreaterThanOrEqual(4);
+ for (const init of inits) expect(init.redirect).toBe("error");
+ });
+});
diff --git a/server/tts/fish.ts b/server/tts/fish.ts
index 6e9ebb447f..1192d9f752 100644
--- a/server/tts/fish.ts
+++ b/server/tts/fish.ts
@@ -221,6 +221,7 @@ export async function transcribe(audio: Uint8Array, mime: string, key: string):
method: "POST",
headers: { authorization: `Bearer ${key}`, model: "transcribe-1-pro" },
body: form,
+ redirect: "error",
signal: AbortSignal.timeout(60_000),
});
} catch {