Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"cloud-dev": "npm run docker && kubectl delete pod -l app.kubernetes.io/name=livepeer-api-server --wait && sleep 1 && kubectl logs -f --pod-running-timeout=30s $(kubectl get pods -o name -l app.kubernetes.io/name=livepeer-api-server)",
"cloud-dev:server": "nodemon -w src -x node src/cli.js --port 3040 --kubeBroadcasterService broadcaster --kubeOrchestratorService orchestrator --kubeNamespace default --kubeBroadcasterTemplate 'https://{{nodeName}}.livepeer-staging.live' --kubeOrchestratorTemplate 'https://{{nodeName}}.livepeer-staging.live:8935'",
"docker:build": "docker build $(printf ' -t livepeerci/api:%s' ${DOCKER_TAGS:-master}) --build-arg GITHUB_SHA --build-arg VERSION -f Dockerfile ../..",
"postgres:start": "docker run --rm -d --name postgres -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 -v \"$(pwd)/data/postgres:/var/lib/postgresql/data\" postgres:14-alpine",
"postgres:start": "docker run --rm -d --name postgres -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 -v livepeer-studio-postgres-data:/var/lib/postgresql/data postgres:14-alpine",
"postgres:stop": "docker rm -f postgres",
"rabbitmq:start": "docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 -e RABBITMQ_DEFAULT_VHOST=livepeer rabbitmq@sha256:f0be9e47ec42081a36593dfc6604274a623caed074fc043e0a927fbd1533dc20",
"rabbitmq:stop": "docker rm -f rabbitmq",
Expand Down
36 changes: 32 additions & 4 deletions packages/api/src/controllers/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ describe("controllers/generate", () => {
"audio-to-text",
"text-to-image",
"image-to-image",
"image-to-text",
"image-to-video",
"upscale",
"segment-anything-2",
"text-to-speech",
"llm",
];
for (const api of apis) {
Expand Down Expand Up @@ -244,17 +246,43 @@ describe("controllers/generate", () => {
expect(aiGatewayCalls).toEqual({ "segment-anything-2": 1 });
});

it("should call the AI Gateway for generate API /llm", async () => {
const res = await client.fetch("/beta/generate/llm", {
it(`should call the AI Gateway for ${basePath}/llm`, async () => {
const res = await client.post(`${basePath}/llm`, {
messages: [{ role: "user", content: "foo" }],
});
expect(res.status).toBe(200);
expect(await res.json()).toEqual({
message: "success",
reqContentType: "application/json",
});
expect(aiGatewayCalls).toEqual({ llm: 1 });
});

it(`should call the AI Gateway for ${basePath}/image-to-text`, async () => {
const res = await client.fetch(`${basePath}/image-to-text`, {
method: "POST",
body: buildForm({ prompt: "foo" }),
body: buildMultipartBody({
model_id: "Salesforce/blip-image-captioning-large",
}),
});
expect(res.status).toBe(200);
expect(await res.json()).toEqual({
message: "success",
reqContentType: expect.stringMatching("^multipart/form-data"),
});
expect(aiGatewayCalls).toEqual({ llm: 1 });
expect(aiGatewayCalls).toEqual({ "image-to-text": 1 });
});

it(`should call the AI Gateway for ${basePath}/text-to-speech`, async () => {
const res = await client.post(`${basePath}/text-to-speech`, {
model_id: "parler-tts/parler-tts-mini-v1",
});
expect(res.status).toBe(200);
expect(await res.json()).toEqual({
message: "success",
reqContentType: "application/json",
});
expect(aiGatewayCalls).toEqual({ "text-to-speech": 1 });
});
});

Expand Down
Loading