@vedmalex/ai-connect 0.2.0 → 0.2.1
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/README.md +2 -0
- package/dist/browser/index.js +23 -0
- package/dist/browser/index.js.map +2 -2
- package/dist/bun/index.js +23 -0
- package/dist/bun/index.js.map +2 -2
- package/dist/bun/local.js +23 -0
- package/dist/bun/local.js.map +2 -2
- package/dist/node/index.js +23 -0
- package/dist/node/index.js.map +2 -2
- package/dist/node/local.js +23 -0
- package/dist/node/local.js.map +2 -2
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/default-handlers.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +3 -2
package/dist/bun/index.js
CHANGED
|
@@ -2175,6 +2175,7 @@ function normalizeResult(route, output, attempts) {
|
|
|
2175
2175
|
attempts,
|
|
2176
2176
|
...output.toolCalls ? { toolCalls: output.toolCalls } : {},
|
|
2177
2177
|
...output.text !== void 0 ? { text: output.text } : {},
|
|
2178
|
+
...output.reasoning !== void 0 ? { reasoning: output.reasoning } : {},
|
|
2178
2179
|
...output.data !== void 0 ? { data: output.data } : {},
|
|
2179
2180
|
...output.usage !== void 0 ? { usage: output.usage } : {}
|
|
2180
2181
|
};
|
|
@@ -5551,6 +5552,9 @@ function extractText(value) {
|
|
|
5551
5552
|
return [part];
|
|
5552
5553
|
}
|
|
5553
5554
|
if (part && typeof part === "object") {
|
|
5555
|
+
if (part.thought === true) {
|
|
5556
|
+
return [];
|
|
5557
|
+
}
|
|
5554
5558
|
const candidate = part.text;
|
|
5555
5559
|
if (typeof candidate === "string") {
|
|
5556
5560
|
return [candidate];
|
|
@@ -5561,6 +5565,22 @@ function extractText(value) {
|
|
|
5561
5565
|
}
|
|
5562
5566
|
return "";
|
|
5563
5567
|
}
|
|
5568
|
+
function extractThoughts(value) {
|
|
5569
|
+
if (!Array.isArray(value)) {
|
|
5570
|
+
return void 0;
|
|
5571
|
+
}
|
|
5572
|
+
const thoughts = value.flatMap((part) => {
|
|
5573
|
+
if (part && typeof part === "object" && part.thought === true) {
|
|
5574
|
+
const candidate = part.text;
|
|
5575
|
+
if (typeof candidate === "string") {
|
|
5576
|
+
return [candidate];
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
return [];
|
|
5580
|
+
});
|
|
5581
|
+
const joined = thoughts.join("\n").trim();
|
|
5582
|
+
return joined.length > 0 ? joined : void 0;
|
|
5583
|
+
}
|
|
5564
5584
|
function imageAttachmentsFromPayload(payload, ...sources) {
|
|
5565
5585
|
return extractImagePayloads(payload, ...sources).map(
|
|
5566
5586
|
(item) => preparePortableFile(item)
|
|
@@ -6103,8 +6123,11 @@ async function runGemini(fetchImpl, context) {
|
|
|
6103
6123
|
throw classifyApiError(provider, response, payload);
|
|
6104
6124
|
}
|
|
6105
6125
|
const data = payload;
|
|
6126
|
+
const geminiThoughts = extractThoughts(data.candidates?.[0]?.content?.parts);
|
|
6106
6127
|
return {
|
|
6107
6128
|
text: extractText(data.candidates?.[0]?.content?.parts),
|
|
6129
|
+
// The model's `{ thought: true }` parts, separated from the answer (consumers route this to a thinking UI).
|
|
6130
|
+
...geminiThoughts ? { reasoning: geminiThoughts } : {},
|
|
6108
6131
|
data,
|
|
6109
6132
|
...geminiToolCallsFromPayload(data).length > 0 ? { toolCalls: geminiToolCallsFromPayload(data) } : {},
|
|
6110
6133
|
...(() => {
|