claudish 3.2.1 → 3.2.3
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 +34 -7
- package/package.json +1 -1
- package/recommended-models.json +1 -1
package/dist/index.js
CHANGED
|
@@ -61414,14 +61414,14 @@ class GeminiHandler {
|
|
|
61414
61414
|
}
|
|
61415
61415
|
});
|
|
61416
61416
|
} else if (block.type === "tool_result") {
|
|
61417
|
-
const
|
|
61418
|
-
if (!
|
|
61417
|
+
const toolInfo = this.toolCallMap.get(block.tool_use_id);
|
|
61418
|
+
if (!toolInfo) {
|
|
61419
61419
|
log(`[GeminiHandler:${this.modelName}] Warning: No function name found for tool_use_id ${block.tool_use_id}`);
|
|
61420
61420
|
continue;
|
|
61421
61421
|
}
|
|
61422
61422
|
parts.push({
|
|
61423
61423
|
functionResponse: {
|
|
61424
|
-
name:
|
|
61424
|
+
name: toolInfo.name,
|
|
61425
61425
|
response: {
|
|
61426
61426
|
content: typeof block.content === "string" ? block.content : JSON.stringify(block.content)
|
|
61427
61427
|
}
|
|
@@ -61441,13 +61441,22 @@ class GeminiHandler {
|
|
|
61441
61441
|
if (block.type === "text") {
|
|
61442
61442
|
parts.push({ text: block.text });
|
|
61443
61443
|
} else if (block.type === "tool_use") {
|
|
61444
|
-
this.toolCallMap.
|
|
61445
|
-
|
|
61444
|
+
const toolInfo = this.toolCallMap.get(block.id);
|
|
61445
|
+
let thoughtSignature = toolInfo?.thoughtSignature;
|
|
61446
|
+
if (!thoughtSignature) {
|
|
61447
|
+
thoughtSignature = "skip_thought_signature_validator";
|
|
61448
|
+
log(`[GeminiHandler:${this.modelName}] Using dummy thoughtSignature for tool ${block.name} (${block.id})`);
|
|
61449
|
+
}
|
|
61450
|
+
const functionCallPart = {
|
|
61446
61451
|
functionCall: {
|
|
61447
61452
|
name: block.name,
|
|
61448
61453
|
args: block.input
|
|
61449
61454
|
}
|
|
61450
|
-
}
|
|
61455
|
+
};
|
|
61456
|
+
if (thoughtSignature) {
|
|
61457
|
+
functionCallPart.thoughtSignature = thoughtSignature;
|
|
61458
|
+
}
|
|
61459
|
+
parts.push(functionCallPart);
|
|
61451
61460
|
}
|
|
61452
61461
|
}
|
|
61453
61462
|
} else if (typeof msg.content === "string") {
|
|
@@ -61570,6 +61579,8 @@ CRITICAL INSTRUCTION FOR OUTPUT FORMAT:
|
|
|
61570
61579
|
const adapter = this.adapterManager.getAdapter();
|
|
61571
61580
|
if (typeof adapter.reset === "function")
|
|
61572
61581
|
adapter.reset();
|
|
61582
|
+
const toolCallMap = this.toolCallMap;
|
|
61583
|
+
const modelName = this.modelName;
|
|
61573
61584
|
return c.body(new ReadableStream({
|
|
61574
61585
|
start: async (controller) => {
|
|
61575
61586
|
const send = (e, d) => {
|
|
@@ -61754,6 +61765,14 @@ data: ${JSON.stringify(d)}
|
|
|
61754
61765
|
arguments: JSON.stringify(part.functionCall.args || {})
|
|
61755
61766
|
};
|
|
61756
61767
|
tools.set(toolIdx, t);
|
|
61768
|
+
const thoughtSignature = part.thoughtSignature;
|
|
61769
|
+
if (thoughtSignature) {
|
|
61770
|
+
log(`[GeminiHandler:${modelName}] Captured thoughtSignature for tool ${t.name} (${t.id})`);
|
|
61771
|
+
}
|
|
61772
|
+
toolCallMap.set(t.id, {
|
|
61773
|
+
name: t.name,
|
|
61774
|
+
thoughtSignature
|
|
61775
|
+
});
|
|
61757
61776
|
send("content_block_start", {
|
|
61758
61777
|
type: "content_block_start",
|
|
61759
61778
|
index: t.blockIndex,
|
|
@@ -61971,15 +61990,23 @@ class OpenAIHandler {
|
|
|
61971
61990
|
const model = this.modelName.toLowerCase();
|
|
61972
61991
|
return model.includes("o1") || model.includes("o3");
|
|
61973
61992
|
}
|
|
61993
|
+
usesMaxCompletionTokens() {
|
|
61994
|
+
const model = this.modelName.toLowerCase();
|
|
61995
|
+
return model.includes("gpt-5") || model.includes("o1") || model.includes("o3") || model.includes("o4");
|
|
61996
|
+
}
|
|
61974
61997
|
buildOpenAIPayload(claudeRequest, messages, tools) {
|
|
61975
61998
|
const payload = {
|
|
61976
61999
|
model: this.modelName,
|
|
61977
62000
|
messages,
|
|
61978
62001
|
temperature: claudeRequest.temperature ?? 1,
|
|
61979
62002
|
stream: true,
|
|
61980
|
-
max_tokens: claudeRequest.max_tokens,
|
|
61981
62003
|
stream_options: { include_usage: true }
|
|
61982
62004
|
};
|
|
62005
|
+
if (this.usesMaxCompletionTokens()) {
|
|
62006
|
+
payload.max_completion_tokens = claudeRequest.max_tokens;
|
|
62007
|
+
} else {
|
|
62008
|
+
payload.max_tokens = claudeRequest.max_tokens;
|
|
62009
|
+
}
|
|
61983
62010
|
if (tools.length > 0) {
|
|
61984
62011
|
payload.tools = tools;
|
|
61985
62012
|
}
|
package/package.json
CHANGED