clawcompany 0.31.0 → 0.32.0
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.js +54 -33
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2149,7 +2149,7 @@ import { join } from "path";
|
|
|
2149
2149
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
2150
2150
|
function banner() {
|
|
2151
2151
|
console.log("");
|
|
2152
|
-
console.log(" \u{1F99E} ClawCompany v0.
|
|
2152
|
+
console.log(" \u{1F99E} ClawCompany v0.32.0");
|
|
2153
2153
|
console.log(" Build for OPC. Every human being is a chairman.");
|
|
2154
2154
|
console.log("");
|
|
2155
2155
|
}
|
|
@@ -2655,41 +2655,62 @@ var OpenAICompatibleProvider = class _OpenAICompatibleProvider {
|
|
|
2655
2655
|
let promptTokens = 0;
|
|
2656
2656
|
let completionTokens = 0;
|
|
2657
2657
|
const toolCallBuffers = /* @__PURE__ */ new Map();
|
|
2658
|
-
const
|
|
2659
|
-
const
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2658
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
2659
|
+
const isSSE = contentType.includes("text/event-stream");
|
|
2660
|
+
if (!isSSE) {
|
|
2661
|
+
const data = await response.json();
|
|
2662
|
+
content = data.choices?.[0]?.message?.content ?? "";
|
|
2663
|
+
model = data.model ?? params.model;
|
|
2664
|
+
finishReason = data.choices?.[0]?.finish_reason ?? "stop";
|
|
2665
|
+
promptTokens = data.usage?.prompt_tokens ?? 0;
|
|
2666
|
+
completionTokens = data.usage?.completion_tokens ?? 0;
|
|
2667
|
+
const tcList = data.choices?.[0]?.message?.tool_calls;
|
|
2668
|
+
if (tcList?.length) {
|
|
2669
|
+
for (const tc of tcList) {
|
|
2670
|
+
toolCallBuffers.set(toolCallBuffers.size, {
|
|
2671
|
+
id: tc.id,
|
|
2672
|
+
name: tc.function?.name ?? "",
|
|
2673
|
+
args: tc.function?.arguments ?? ""
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
} else {
|
|
2678
|
+
const reader = response.body.getReader();
|
|
2679
|
+
const decoder = new TextDecoder();
|
|
2680
|
+
let buffer = "";
|
|
2681
|
+
while (true) {
|
|
2682
|
+
const { done, value } = await reader.read();
|
|
2683
|
+
if (done) break;
|
|
2684
|
+
buffer += decoder.decode(value, { stream: true });
|
|
2685
|
+
const lines = buffer.split("\n");
|
|
2686
|
+
buffer = lines.pop() ?? "";
|
|
2687
|
+
for (const line of lines) {
|
|
2688
|
+
if (!line.startsWith("data: ") || line === "data: [DONE]") continue;
|
|
2689
|
+
try {
|
|
2690
|
+
const chunk = JSON.parse(line.slice(6));
|
|
2691
|
+
const delta = chunk.choices?.[0]?.delta;
|
|
2692
|
+
if (delta?.content) content += delta.content;
|
|
2693
|
+
if (chunk.model) model = chunk.model;
|
|
2694
|
+
const fr = chunk.choices?.[0]?.finish_reason;
|
|
2695
|
+
if (fr) finishReason = fr;
|
|
2696
|
+
if (delta?.tool_calls) {
|
|
2697
|
+
for (const tc of delta.tool_calls) {
|
|
2698
|
+
const idx = tc.index ?? 0;
|
|
2699
|
+
if (!toolCallBuffers.has(idx)) {
|
|
2700
|
+
toolCallBuffers.set(idx, { id: tc.id ?? `call_${idx}`, name: "", args: "" });
|
|
2701
|
+
}
|
|
2702
|
+
const buf = toolCallBuffers.get(idx);
|
|
2703
|
+
if (tc.id) buf.id = tc.id;
|
|
2704
|
+
if (tc.function?.name) buf.name = tc.function.name;
|
|
2705
|
+
if (tc.function?.arguments) buf.args += tc.function.arguments;
|
|
2681
2706
|
}
|
|
2682
|
-
const buf = toolCallBuffers.get(idx);
|
|
2683
|
-
if (tc.id) buf.id = tc.id;
|
|
2684
|
-
if (tc.function?.name) buf.name = tc.function.name;
|
|
2685
|
-
if (tc.function?.arguments) buf.args += tc.function.arguments;
|
|
2686
2707
|
}
|
|
2708
|
+
if (chunk.usage) {
|
|
2709
|
+
promptTokens = chunk.usage.prompt_tokens ?? 0;
|
|
2710
|
+
completionTokens = chunk.usage.completion_tokens ?? 0;
|
|
2711
|
+
}
|
|
2712
|
+
} catch {
|
|
2687
2713
|
}
|
|
2688
|
-
if (chunk.usage) {
|
|
2689
|
-
promptTokens = chunk.usage.prompt_tokens ?? 0;
|
|
2690
|
-
completionTokens = chunk.usage.completion_tokens ?? 0;
|
|
2691
|
-
}
|
|
2692
|
-
} catch {
|
|
2693
2714
|
}
|
|
2694
2715
|
}
|
|
2695
2716
|
}
|
package/package.json
CHANGED