ai 5.0.16 → 5.0.18
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 +14 -0
- package/dist/index.d.mts +15 -8
- package/dist/index.d.ts +15 -8
- package/dist/index.js +24 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
@@ -1678,8 +1678,8 @@ function prepareRetries({
|
|
1678
1678
|
};
|
1679
1679
|
}
|
1680
1680
|
|
1681
|
-
// src/generate-text/extract-content
|
1682
|
-
function
|
1681
|
+
// src/generate-text/extract-text-content.ts
|
1682
|
+
function extractTextContent(content) {
|
1683
1683
|
const parts = content.filter(
|
1684
1684
|
(content2) => content2.type === "text"
|
1685
1685
|
);
|
@@ -2189,7 +2189,7 @@ async function generateText({
|
|
2189
2189
|
attributes: {
|
2190
2190
|
"ai.response.finishReason": result.finishReason,
|
2191
2191
|
"ai.response.text": {
|
2192
|
-
output: () =>
|
2192
|
+
output: () => extractTextContent(result.content)
|
2193
2193
|
},
|
2194
2194
|
"ai.response.toolCalls": {
|
2195
2195
|
output: () => {
|
@@ -2318,7 +2318,7 @@ async function generateText({
|
|
2318
2318
|
attributes: {
|
2319
2319
|
"ai.response.finishReason": currentModelResponse.finishReason,
|
2320
2320
|
"ai.response.text": {
|
2321
|
-
output: () =>
|
2321
|
+
output: () => extractTextContent(currentModelResponse.content)
|
2322
2322
|
},
|
2323
2323
|
"ai.response.toolCalls": {
|
2324
2324
|
output: () => {
|
@@ -6038,6 +6038,14 @@ import {
|
|
6038
6038
|
createIdGenerator as createIdGenerator3
|
6039
6039
|
} from "@ai-sdk/provider-utils";
|
6040
6040
|
|
6041
|
+
// src/generate-text/extract-reasoning-content.ts
|
6042
|
+
function extractReasoningContent(content) {
|
6043
|
+
const parts = content.filter(
|
6044
|
+
(content2) => content2.type === "reasoning"
|
6045
|
+
);
|
6046
|
+
return parts.length === 0 ? void 0 : parts.map((content2) => content2.text).join("\n");
|
6047
|
+
}
|
6048
|
+
|
6041
6049
|
// src/generate-object/output-strategy.ts
|
6042
6050
|
import {
|
6043
6051
|
isJSONArray,
|
@@ -6562,6 +6570,7 @@ async function generateObject(options) {
|
|
6562
6570
|
let response;
|
6563
6571
|
let request;
|
6564
6572
|
let resultProviderMetadata;
|
6573
|
+
let reasoning;
|
6565
6574
|
const standardizedPrompt = await standardizePrompt({
|
6566
6575
|
system,
|
6567
6576
|
prompt,
|
@@ -6619,7 +6628,8 @@ async function generateObject(options) {
|
|
6619
6628
|
headers: (_g = result2.response) == null ? void 0 : _g.headers,
|
6620
6629
|
body: (_h = result2.response) == null ? void 0 : _h.body
|
6621
6630
|
};
|
6622
|
-
const text2 =
|
6631
|
+
const text2 = extractTextContent(result2.content);
|
6632
|
+
const reasoning2 = extractReasoningContent(result2.content);
|
6623
6633
|
if (text2 === void 0) {
|
6624
6634
|
throw new NoObjectGeneratedError({
|
6625
6635
|
message: "No object generated: the model did not return a response.",
|
@@ -6652,7 +6662,12 @@ async function generateObject(options) {
|
|
6652
6662
|
}
|
6653
6663
|
})
|
6654
6664
|
);
|
6655
|
-
return {
|
6665
|
+
return {
|
6666
|
+
...result2,
|
6667
|
+
objectText: text2,
|
6668
|
+
reasoning: reasoning2,
|
6669
|
+
responseData
|
6670
|
+
};
|
6656
6671
|
}
|
6657
6672
|
})
|
6658
6673
|
);
|
@@ -6663,6 +6678,7 @@ async function generateObject(options) {
|
|
6663
6678
|
resultProviderMetadata = generateResult.providerMetadata;
|
6664
6679
|
request = (_a17 = generateResult.request) != null ? _a17 : {};
|
6665
6680
|
response = generateResult.responseData;
|
6681
|
+
reasoning = generateResult.reasoning;
|
6666
6682
|
const object2 = await parseAndValidateObjectResultWithRepair(
|
6667
6683
|
result,
|
6668
6684
|
outputStrategy,
|
@@ -6692,6 +6708,7 @@ async function generateObject(options) {
|
|
6692
6708
|
);
|
6693
6709
|
return new DefaultGenerateObjectResult({
|
6694
6710
|
object: object2,
|
6711
|
+
reasoning,
|
6695
6712
|
finishReason,
|
6696
6713
|
usage,
|
6697
6714
|
warnings,
|
@@ -6714,6 +6731,7 @@ var DefaultGenerateObjectResult = class {
|
|
6714
6731
|
this.providerMetadata = options.providerMetadata;
|
6715
6732
|
this.response = options.response;
|
6716
6733
|
this.request = options.request;
|
6734
|
+
this.reasoning = options.reasoning;
|
6717
6735
|
}
|
6718
6736
|
toJsonResponse(init) {
|
6719
6737
|
var _a17;
|