@neutrome/open-ai-router 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/router/execute.test.ts +67 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neutrome/open-ai-router",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"posthog-node": "^5.41.0",
|
|
18
18
|
"zod": "^4.2.1",
|
|
19
19
|
"@neutrome/lil-engine": "0.6.1",
|
|
20
|
-
"@neutrome/lilsdk": "0.6.
|
|
20
|
+
"@neutrome/lilsdk": "0.6.4"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^25.9.3",
|
|
@@ -570,6 +570,73 @@ describe("router execution", () => {
|
|
|
570
570
|
});
|
|
571
571
|
});
|
|
572
572
|
|
|
573
|
+
it("applies configured suffix transforms to nested executor invocations", async () => {
|
|
574
|
+
let transformApplied = false;
|
|
575
|
+
const runtime = createRouterRuntime({
|
|
576
|
+
config: {
|
|
577
|
+
modelSuffixes: ["trim-input"],
|
|
578
|
+
providers: {},
|
|
579
|
+
modelNamespaces: {
|
|
580
|
+
namespace: {
|
|
581
|
+
exports: ["*"],
|
|
582
|
+
models: {
|
|
583
|
+
root: { target: { executor: "root" } },
|
|
584
|
+
model: { target: { executor: "model" } },
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
});
|
|
590
|
+
const ctx: RequestContext = {
|
|
591
|
+
request: new Request("http://local/v1/chat/completions", {
|
|
592
|
+
method: "POST",
|
|
593
|
+
headers: { "content-type": "application/json" },
|
|
594
|
+
body: JSON.stringify({
|
|
595
|
+
model: "namespace/root",
|
|
596
|
+
messages: [{ role: "user", content: "hi" }],
|
|
597
|
+
}),
|
|
598
|
+
}),
|
|
599
|
+
incomingAuth: new Map(),
|
|
600
|
+
env: {},
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
const response = await handleChatCompletions({
|
|
604
|
+
runtime,
|
|
605
|
+
ctx,
|
|
606
|
+
transforms: {
|
|
607
|
+
"trim-input": {
|
|
608
|
+
name: "trim-input",
|
|
609
|
+
capabilities: [],
|
|
610
|
+
apply(request) {
|
|
611
|
+
transformApplied = true;
|
|
612
|
+
return request;
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
executorImplementations: {
|
|
617
|
+
root: {
|
|
618
|
+
async execute(request, executorContext) {
|
|
619
|
+
return executorContext.invoke(
|
|
620
|
+
"namespace/model+trim-input",
|
|
621
|
+
request,
|
|
622
|
+
);
|
|
623
|
+
},
|
|
624
|
+
async *stream() {},
|
|
625
|
+
},
|
|
626
|
+
model: {
|
|
627
|
+
async execute() {
|
|
628
|
+
expect(transformApplied).toBe(true);
|
|
629
|
+
return appendAssistantMessage(createProgram(), "done");
|
|
630
|
+
},
|
|
631
|
+
async *stream() {},
|
|
632
|
+
},
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
expect(response.status).toBe(200);
|
|
637
|
+
expect(transformApplied).toBe(true);
|
|
638
|
+
});
|
|
639
|
+
|
|
573
640
|
it("streams provider chunks as openai sse output", async () => {
|
|
574
641
|
const runtime = createRouterRuntime({
|
|
575
642
|
config: {
|