bridgerapi 1.9.0 → 1.9.2
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/dist/cli.js +29 -22
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -131,7 +131,7 @@ function extractModelIds(text) {
|
|
|
131
131
|
const seen = /* @__PURE__ */ new Set();
|
|
132
132
|
const re = /\b([a-z][a-z0-9]*(?:[.\-][a-z0-9]+)+)\b/g;
|
|
133
133
|
for (const [, id] of text.matchAll(re)) {
|
|
134
|
-
if (id.length >= 5 && !SKIP_TOKENS.has(id)) seen.add(id);
|
|
134
|
+
if (id.length >= 5 && /\d/.test(id) && !SKIP_TOKENS.has(id)) seen.add(id);
|
|
135
135
|
}
|
|
136
136
|
return [...seen];
|
|
137
137
|
}
|
|
@@ -481,7 +481,7 @@ var DroidBackend = class _DroidBackend {
|
|
|
481
481
|
try {
|
|
482
482
|
out = (0, import_child_process.execFileSync)(
|
|
483
483
|
which("droid") || this.bin,
|
|
484
|
-
["exec", "--output-format", "text", "--model", model2
|
|
484
|
+
["exec", "--output-format", "text", "--model", model2],
|
|
485
485
|
{ input: prompt, encoding: "utf8", timeout: 3e5 }
|
|
486
486
|
);
|
|
487
487
|
} catch (e) {
|
|
@@ -492,7 +492,7 @@ var DroidBackend = class _DroidBackend {
|
|
|
492
492
|
async *stream(prompt, model2) {
|
|
493
493
|
yield* spawnStream(
|
|
494
494
|
which("droid") || this.bin,
|
|
495
|
-
["exec", "--output-format", "text", "--model", model2
|
|
495
|
+
["exec", "--output-format", "text", "--model", model2],
|
|
496
496
|
prompt
|
|
497
497
|
);
|
|
498
498
|
}
|
|
@@ -653,26 +653,33 @@ async function handleChat(req, res) {
|
|
|
653
653
|
}
|
|
654
654
|
function createBridgeServer(port2) {
|
|
655
655
|
const server = (0, import_http.createServer)(async (req, res) => {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
656
|
+
try {
|
|
657
|
+
const path = (req.url ?? "/").split("?")[0];
|
|
658
|
+
const method = req.method ?? "GET";
|
|
659
|
+
if (method === "OPTIONS") {
|
|
660
|
+
cors(res, 200);
|
|
661
|
+
res.end();
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (method === "GET" && (path === "/v1/models" || path === "/models")) {
|
|
665
|
+
await handleModels(res);
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
if (method === "GET" && path === "/health") {
|
|
669
|
+
handleHealth(res, port2);
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
if (method === "POST" && (path === "/v1/chat/completions" || path === "/chat/completions")) {
|
|
673
|
+
await handleChat(req, res);
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
sendJson(res, 404, { error: { message: "not found", type: "not_found_error" } });
|
|
677
|
+
} catch (err) {
|
|
678
|
+
console.error(" unhandled server error:", err.message);
|
|
679
|
+
if (!res.headersSent) {
|
|
680
|
+
sendJson(res, 500, { error: { message: "internal server error", type: "server_error" } });
|
|
681
|
+
}
|
|
674
682
|
}
|
|
675
|
-
sendJson(res, 404, { error: { message: "not found", type: "not_found_error" } });
|
|
676
683
|
});
|
|
677
684
|
return server;
|
|
678
685
|
}
|