@blockrun/clawrouter 0.5.2 → 0.5.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/dist/index.d.ts +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -570,7 +570,7 @@ type BlockRunModel = {
|
|
|
570
570
|
};
|
|
571
571
|
declare const BLOCKRUN_MODELS: BlockRunModel[];
|
|
572
572
|
/**
|
|
573
|
-
* All BlockRun models in OpenClaw format.
|
|
573
|
+
* All BlockRun models in OpenClaw format (including aliases).
|
|
574
574
|
*/
|
|
575
575
|
declare const OPENCLAW_MODELS: ModelDefinitionConfig[];
|
|
576
576
|
/**
|
package/dist/index.js
CHANGED
|
@@ -393,7 +393,15 @@ function toOpenClawModel(m) {
|
|
|
393
393
|
maxTokens: m.maxOutput
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
|
-
var
|
|
396
|
+
var ALIAS_MODELS = Object.entries(MODEL_ALIASES).map(([alias, targetId]) => {
|
|
397
|
+
const target = BLOCKRUN_MODELS.find((m) => m.id === targetId);
|
|
398
|
+
if (!target) return null;
|
|
399
|
+
return toOpenClawModel({ ...target, id: alias, name: `${alias} \u2192 ${target.name}` });
|
|
400
|
+
}).filter((m) => m !== null);
|
|
401
|
+
var OPENCLAW_MODELS = [
|
|
402
|
+
...BLOCKRUN_MODELS.map(toOpenClawModel),
|
|
403
|
+
...ALIAS_MODELS
|
|
404
|
+
];
|
|
397
405
|
function buildProviderModels(baseUrl) {
|
|
398
406
|
return {
|
|
399
407
|
baseUrl: `${baseUrl}/v1`,
|
|
@@ -2988,7 +2996,8 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
2988
2996
|
id: rsp.id ?? `chatcmpl-${Date.now()}`,
|
|
2989
2997
|
object: "chat.completion.chunk",
|
|
2990
2998
|
created: rsp.created ?? Math.floor(Date.now() / 1e3),
|
|
2991
|
-
model: rsp.model ?? "unknown"
|
|
2999
|
+
model: rsp.model ?? "unknown",
|
|
3000
|
+
system_fingerprint: null
|
|
2992
3001
|
};
|
|
2993
3002
|
if (rsp.choices && Array.isArray(rsp.choices)) {
|
|
2994
3003
|
for (const choice of rsp.choices) {
|
|
@@ -2998,7 +3007,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
2998
3007
|
const index = choice.index ?? 0;
|
|
2999
3008
|
const roleChunk = {
|
|
3000
3009
|
...baseChunk,
|
|
3001
|
-
choices: [{ index, delta: { role }, finish_reason: null }]
|
|
3010
|
+
choices: [{ index, delta: { role }, logprobs: null, finish_reason: null }]
|
|
3002
3011
|
};
|
|
3003
3012
|
const roleData = `data: ${JSON.stringify(roleChunk)}
|
|
3004
3013
|
|
|
@@ -3008,7 +3017,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
3008
3017
|
if (content) {
|
|
3009
3018
|
const contentChunk = {
|
|
3010
3019
|
...baseChunk,
|
|
3011
|
-
choices: [{ index, delta: { content }, finish_reason: null }]
|
|
3020
|
+
choices: [{ index, delta: { content }, logprobs: null, finish_reason: null }]
|
|
3012
3021
|
};
|
|
3013
3022
|
const contentData = `data: ${JSON.stringify(contentChunk)}
|
|
3014
3023
|
|
|
@@ -3020,7 +3029,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
3020
3029
|
if (toolCalls && toolCalls.length > 0) {
|
|
3021
3030
|
const toolCallChunk = {
|
|
3022
3031
|
...baseChunk,
|
|
3023
|
-
choices: [{ index, delta: { tool_calls: toolCalls }, finish_reason: null }]
|
|
3032
|
+
choices: [{ index, delta: { tool_calls: toolCalls }, logprobs: null, finish_reason: null }]
|
|
3024
3033
|
};
|
|
3025
3034
|
const toolCallData = `data: ${JSON.stringify(toolCallChunk)}
|
|
3026
3035
|
|
|
@@ -3030,7 +3039,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
3030
3039
|
}
|
|
3031
3040
|
const finishChunk = {
|
|
3032
3041
|
...baseChunk,
|
|
3033
|
-
choices: [{ index, delta: {}, finish_reason: choice.finish_reason ?? "stop" }]
|
|
3042
|
+
choices: [{ index, delta: {}, logprobs: null, finish_reason: choice.finish_reason ?? "stop" }]
|
|
3034
3043
|
};
|
|
3035
3044
|
const finishData = `data: ${JSON.stringify(finishChunk)}
|
|
3036
3045
|
|