From 44d1760c3afec7a4533e0ae41452a2ed08879167 Mon Sep 17 00:00:00 2001 From: Paco Cartones <253313177+pacocartones@users.noreply.github.com> Date: Thu, 17 Sep 2026 22:15:37 +0200 Subject: [PATCH] fix(nlpcloud): restore chatbot endpoint coverage (#13845) Co-authored-by: Paco Cartones --- .../config/providers/registry/nlpcloud/index.ts | 2 +- tests/snapshots/provider/translate-path.json | 4 ++-- tests/unit/executor-nlpcloud.test.ts | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/open-sse/config/providers/registry/nlpcloud/index.ts b/open-sse/config/providers/registry/nlpcloud/index.ts index ffa059dfd9..6a72d10b20 100644 --- a/open-sse/config/providers/registry/nlpcloud/index.ts +++ b/open-sse/config/providers/registry/nlpcloud/index.ts @@ -5,7 +5,7 @@ export const nlpcloudProvider: RegistryEntry = { alias: "nlpc", format: "openai", executor: "default", - baseUrl: "https://api.nlpcloud.io/v1/chat/completions", + baseUrl: "https://api.nlpcloud.io/v1/gpu", authType: "apikey", authHeader: "bearer", // Sweep 2026-06-19: NLP Cloud's branded chat models + larger Llama tiers. diff --git a/tests/snapshots/provider/translate-path.json b/tests/snapshots/provider/translate-path.json index a6709f1c62..4ea6a91560 100644 --- a/tests/snapshots/provider/translate-path.json +++ b/tests/snapshots/provider/translate-path.json @@ -4277,8 +4277,8 @@ } }, "url": { - "nonStream": "https://api.nlpcloud.io/v1/chat/completions", - "stream": "https://api.nlpcloud.io/v1/chat/completions" + "nonStream": "https://api.nlpcloud.io/v1/gpu", + "stream": "https://api.nlpcloud.io/v1/gpu" } }, "notion-web": { diff --git a/tests/unit/executor-nlpcloud.test.ts b/tests/unit/executor-nlpcloud.test.ts index c131bcdd8e..63d6011159 100644 --- a/tests/unit/executor-nlpcloud.test.ts +++ b/tests/unit/executor-nlpcloud.test.ts @@ -6,6 +6,16 @@ import { NlpCloudExecutor } from "../../open-sse/executors/nlpcloud.ts"; const encoder = new TextEncoder(); +type ChatCompletionPayload = { + object: string; + choices: Array<{ message: { role: string; content: string } }>; + model: string; +}; + +type ErrorPayload = { + error: { message: string }; +}; + function jsonResponse(body: unknown, status = 200) { return new Response(JSON.stringify(body), { status, @@ -35,7 +45,7 @@ test("NlpCloudExecutor is registered in the executor index", async () => { assert.ok((await getExecutor("nlpcloud")) instanceof NlpCloudExecutor); }); -test.skip("NlpCloudExecutor converts OpenAI messages into chatbot input/context/history and wraps JSON responses", async () => { +test("NlpCloudExecutor converts OpenAI messages into chatbot input/context/history and wraps JSON responses", async () => { const executor = new NlpCloudExecutor(); const originalFetch = globalThis.fetch; const calls: Array<{ @@ -84,7 +94,7 @@ test.skip("NlpCloudExecutor converts OpenAI messages into chatbot input/context/ assert.equal(calls[0].body.context, "You are concise."); assert.deepEqual(calls[0].body.history, [{ input: "Hello", response: "Hi there!" }]); - const body = (await result.response.json()) as any; + const body = (await result.response.json()) as ChatCompletionPayload; assert.equal(body.object, "chat.completion"); assert.equal(body.choices[0].message.role, "assistant"); assert.equal(body.choices[0].message.content, "Hi back from NLP Cloud."); @@ -141,7 +151,7 @@ test("NlpCloudExecutor maps upstream auth failures to OpenAI-style errors", asyn }); assert.equal(result.response.status, 403); - const body = (await result.response.json()) as any; + const body = (await result.response.json()) as ErrorPayload; assert.match(body.error.message, /status 403/i); } finally { globalThis.fetch = originalFetch;