@acosmi/sdk-ts 2.19.1 → 2.19.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/CHANGELOG.md +12 -0
- package/dist/browser/index.mjs +23 -8
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +23 -8
- package/dist/index.mjs.map +1 -1
- package/dist/node/adapters/anthropic.cjs +2 -0
- package/dist/node/adapters/anthropic.cjs.map +1 -1
- package/dist/node/adapters/anthropic.d.cts +1 -1
- package/dist/node/adapters/anthropic.d.ts +1 -1
- package/dist/node/adapters/anthropic.mjs +2 -0
- package/dist/node/adapters/anthropic.mjs.map +1 -1
- package/dist/node/adapters/openai.cjs +13 -5
- package/dist/node/adapters/openai.cjs.map +1 -1
- package/dist/node/adapters/openai.d.cts +2 -2
- package/dist/node/adapters/openai.d.ts +2 -2
- package/dist/node/adapters/openai.mjs +13 -5
- package/dist/node/adapters/openai.mjs.map +1 -1
- package/dist/node/{index-C2oh157O.d.cts → index-CqxPqbsl.d.cts} +2 -1
- package/dist/node/{index-C2oh157O.d.ts → index-CqxPqbsl.d.ts} +2 -1
- package/dist/node/index.cjs +22 -7
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +10 -5
- package/dist/node/index.d.ts +10 -5
- package/dist/node/index.mjs +23 -8
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{openai-CMrvATF_.d.cts → openai-Ce85qh14.d.cts} +2 -2
- package/dist/node/{openai-BbCQOMNY.d.ts → openai-mkTSir6E.d.ts} +2 -2
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -134,12 +134,13 @@ function parseSettlement(ev) {
|
|
|
134
134
|
callRemaining: s.callRemaining ?? -1
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
|
-
exports.BucketClassCommercial = void 0; exports.BucketClassGeneric = void 0; exports.ThinkingOff = void 0; exports.ThinkingHigh = void 0; exports.ThinkingMax = void 0; exports.ThinkingHighMinMaxTokens = void 0; exports.ThinkingMaxFallbackMaxTokens = void 0; exports.ServerToolTypeWebSearch = void 0;
|
|
137
|
+
exports.BucketClassCommercial = void 0; exports.BucketClassGeneric = void 0; exports.ThinkingOff = void 0; exports.ThinkingLow = void 0; exports.ThinkingHigh = void 0; exports.ThinkingMax = void 0; exports.ThinkingHighMinMaxTokens = void 0; exports.ThinkingMaxFallbackMaxTokens = void 0; exports.ServerToolTypeWebSearch = void 0;
|
|
138
138
|
var init_types = __esm({
|
|
139
139
|
"src/models/types.ts"() {
|
|
140
140
|
exports.BucketClassCommercial = "COMMERCIAL";
|
|
141
141
|
exports.BucketClassGeneric = "GENERIC";
|
|
142
142
|
exports.ThinkingOff = "off";
|
|
143
|
+
exports.ThinkingLow = "low";
|
|
143
144
|
exports.ThinkingHigh = "high";
|
|
144
145
|
exports.ThinkingMax = "max";
|
|
145
146
|
exports.ThinkingHighMinMaxTokens = 32e3;
|
|
@@ -506,6 +507,8 @@ function resolveThinkingLevel(body, req, caps) {
|
|
|
506
507
|
}
|
|
507
508
|
if (caps.supports_effort) {
|
|
508
509
|
let effortLevel = "high";
|
|
510
|
+
if (level === "low") effortLevel = "low";
|
|
511
|
+
if (level === "medium" || level === "xhigh") effortLevel = level;
|
|
509
512
|
if (level === exports.ThinkingMax && caps.supports_max_effort) {
|
|
510
513
|
effortLevel = "max";
|
|
511
514
|
}
|
|
@@ -683,23 +686,28 @@ __export(openai_exports, {
|
|
|
683
686
|
resolveOpenAIReasoningEffort: () => resolveOpenAIReasoningEffort,
|
|
684
687
|
resolveOpenAIResponseFormat: () => resolveOpenAIResponseFormat
|
|
685
688
|
});
|
|
686
|
-
function resolveOpenAIReasoningEffort(req) {
|
|
689
|
+
function resolveOpenAIReasoningEffort(req, supportsMax = false) {
|
|
687
690
|
if (req.effort && req.effort.level !== "") {
|
|
688
691
|
switch (req.effort.level) {
|
|
689
692
|
case "low":
|
|
690
693
|
case "medium":
|
|
691
694
|
case "high":
|
|
695
|
+
case "xhigh":
|
|
692
696
|
return req.effort.level;
|
|
693
697
|
case "max":
|
|
694
|
-
return "high";
|
|
698
|
+
return supportsMax ? "max" : "high";
|
|
695
699
|
}
|
|
696
700
|
}
|
|
697
701
|
if (req.thinking) {
|
|
698
702
|
switch (req.thinking.level) {
|
|
703
|
+
case "low":
|
|
704
|
+
case "medium":
|
|
705
|
+
case "xhigh":
|
|
706
|
+
return req.thinking.level;
|
|
699
707
|
case exports.ThinkingHigh:
|
|
700
708
|
return "high";
|
|
701
709
|
case exports.ThinkingMax:
|
|
702
|
-
return "high";
|
|
710
|
+
return supportsMax ? "max" : "high";
|
|
703
711
|
case exports.ThinkingOff:
|
|
704
712
|
return "";
|
|
705
713
|
}
|
|
@@ -903,10 +911,13 @@ var init_openai = __esm({
|
|
|
903
911
|
if (req.tools != null) {
|
|
904
912
|
body["tools"] = req.tools;
|
|
905
913
|
}
|
|
906
|
-
const eff = resolveOpenAIReasoningEffort(req);
|
|
914
|
+
const eff = resolveOpenAIReasoningEffort(req, _caps.supports_max_effort);
|
|
907
915
|
if (eff !== "") {
|
|
908
916
|
body["reasoning_effort"] = eff;
|
|
909
917
|
}
|
|
918
|
+
if (_caps.supports_thinking && req.thinking?.level === exports.ThinkingOff) {
|
|
919
|
+
body["thinking"] = { type: "disabled" };
|
|
920
|
+
}
|
|
910
921
|
if (req.speed && req.speed !== "") {
|
|
911
922
|
body["speed"] = req.speed;
|
|
912
923
|
}
|
|
@@ -1075,7 +1086,7 @@ var init_openai = __esm({
|
|
|
1075
1086
|
throw new Error(`parse openai stream chunk: ${e instanceof Error ? e.message : String(e)}`);
|
|
1076
1087
|
}
|
|
1077
1088
|
const events = [];
|
|
1078
|
-
if (chunk.choices.length === 0) {
|
|
1089
|
+
if (!Array.isArray(chunk.choices) || chunk.choices.length === 0) {
|
|
1079
1090
|
return { events, done: false };
|
|
1080
1091
|
}
|
|
1081
1092
|
const choice = chunk.choices[0];
|
|
@@ -4346,13 +4357,17 @@ var Client = class _Client {
|
|
|
4346
4357
|
}
|
|
4347
4358
|
if (adapter.format() === 1 /* OpenAI */) {
|
|
4348
4359
|
const converter = newOpenAIStreamConverter();
|
|
4360
|
+
let currentEvent = "";
|
|
4349
4361
|
for await (const line of iterSSELines(resp.body)) {
|
|
4350
4362
|
notifyUpstreamActivity(onUpstreamActivity);
|
|
4351
4363
|
if (isSSECommentLine(line)) continue;
|
|
4352
4364
|
if (line.startsWith("event:")) {
|
|
4353
|
-
line.slice("event:".length).trim();
|
|
4365
|
+
currentEvent = line.slice("event:".length).trim();
|
|
4354
4366
|
} else if (line.startsWith("data:")) {
|
|
4355
4367
|
const data = line.slice("data:".length).trim();
|
|
4368
|
+
if (currentEvent === "failed" || currentEvent === "error") {
|
|
4369
|
+
throw parseStreamError(data);
|
|
4370
|
+
}
|
|
4356
4371
|
const { events, done } = converter.convert(data);
|
|
4357
4372
|
for (const ev of events) yield ev;
|
|
4358
4373
|
if (done) return;
|