ai 3.3.39 → 3.3.41

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # ai
2
2
 
3
+ ## 3.3.41
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [692e265]
8
+ - @ai-sdk/vue@0.0.50
9
+
10
+ ## 3.3.40
11
+
12
+ ### Patch Changes
13
+
14
+ - a91c308: feat (ai/core): add responseMessages to streamText
15
+
3
16
  ## 3.3.39
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ![hero illustration](./assets/hero.gif)
2
2
 
3
- # Vercel AI SDK
3
+ # AI SDK
4
4
 
5
- The [Vercel AI SDK](https://sdk.vercel.ai/docs) is a TypeScript toolkit designed to help you build AI-powered applications using popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.
5
+ The [AI SDK](https://sdk.vercel.ai/docs) is a TypeScript toolkit designed to help you build AI-powered applications using popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.
6
6
 
7
- To learn more about how to use the Vercel AI SDK, check out our [API Reference](https://sdk.vercel.ai/docs/reference) and [Documentation](https://sdk.vercel.ai/docs).
7
+ To learn more about how to use the AI SDK, check out our [API Reference](https://sdk.vercel.ai/docs/reference) and [Documentation](https://sdk.vercel.ai/docs).
8
8
 
9
9
  ## Installation
10
10
 
@@ -148,6 +148,13 @@ async function submitMessage() {
148
148
  ui: stream.value,
149
149
  };
150
150
  }
151
+ ```
152
+
153
+ ###### @/app/ai.ts (Next.js App Router)
154
+
155
+ ```tsx
156
+ import { createAI } from 'ai/rsc';
157
+ import { submitMessage } from '@/app/actions';
151
158
 
152
159
  export const AI = createAI({
153
160
  initialAIState: {},
@@ -162,7 +169,7 @@ export const AI = createAI({
162
169
 
163
170
  ```tsx
164
171
  import { ReactNode } from 'react';
165
- import { AI } from '@/app/actions';
172
+ import { AI } from '@/app/ai';
166
173
 
167
174
  export default function Layout({ children }: { children: ReactNode }) {
168
175
  <AI>{children}</AI>;
@@ -209,11 +216,11 @@ We've built [templates](https://vercel.com/templates?type=ai) that include AI SD
209
216
 
210
217
  ## Community
211
218
 
212
- The Vercel AI SDK community can be found on [GitHub Discussions](https://github.com/vercel/ai/discussions) where you can ask questions, voice ideas, and share your projects with other people.
219
+ The AI SDK community can be found on [GitHub Discussions](https://github.com/vercel/ai/discussions) where you can ask questions, voice ideas, and share your projects with other people.
213
220
 
214
221
  ## Contributing
215
222
 
216
- Contributions to the Vercel AI SDK are welcome and highly appreciated. However, before you jump right into it, we would like you to review our [Contribution Guidelines](https://github.com/vercel/ai/blob/main/CONTRIBUTING.md) to make sure you have smooth experience contributing to Vercel AI SDK.
223
+ Contributions to the AI SDK are welcome and highly appreciated. However, before you jump right into it, we would like you to review our [Contribution Guidelines](https://github.com/vercel/ai/blob/main/CONTRIBUTING.md) to make sure you have smooth experience contributing to AI SDK.
217
224
 
218
225
  ## Authors
219
226
 
package/dist/index.d.mts CHANGED
@@ -1394,11 +1394,12 @@ interface GenerateTextResult<TOOLS extends Record<string, CoreTool>> {
1394
1394
  */
1395
1395
  readonly warnings: CallWarning[] | undefined;
1396
1396
  /**
1397
- The response messages that were generated during the call. It consists of an assistant message,
1398
- potentially containing tool calls.
1399
- When there are tool results, there is an additional tool message with the tool results that are available.
1400
- If there are tools that do not have execute functions, they are not included in the tool results and
1401
- need to be added separately.
1397
+ The response messages that were generated during the call. It consists of an assistant message,
1398
+ potentially containing tool calls.
1399
+
1400
+ When there are tool results, there is an additional tool message with the tool results that are available.
1401
+ If there are tools that do not have execute functions, they are not included in the tool results and
1402
+ need to be added separately.
1402
1403
  */
1403
1404
  readonly responseMessages: Array<CoreAssistantMessage | CoreToolMessage>;
1404
1405
  /**
@@ -1614,6 +1615,17 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>> {
1614
1615
  headers?: Record<string, string>;
1615
1616
  };
1616
1617
  /**
1618
+ The response messages that were generated during the call. It consists of an assistant message,
1619
+ potentially containing tool calls.
1620
+
1621
+ When there are tool results, there is an additional tool message with the tool results that are available.
1622
+ If there are tools that do not have execute functions, they are not included in the tool results and
1623
+ need to be added separately.
1624
+
1625
+ Resolved when the response is finished.
1626
+ */
1627
+ readonly responseMessages: Promise<Array<CoreAssistantMessage | CoreToolMessage>>;
1628
+ /**
1617
1629
  Details for all steps.
1618
1630
  You can use this to get information about intermediate steps,
1619
1631
  such as the tool calls or the response headers.
@@ -1887,7 +1899,16 @@ The usage is the combined usage of all steps.
1887
1899
  /**
1888
1900
  Details for all steps.
1889
1901
  */
1890
- steps: StepResult<TOOLS>[];
1902
+ readonly steps: StepResult<TOOLS>[];
1903
+ /**
1904
+ The response messages that were generated during the call. It consists of an assistant message,
1905
+ potentially containing tool calls.
1906
+
1907
+ When there are tool results, there is an additional tool message with the tool results that are available.
1908
+ If there are tools that do not have execute functions, they are not included in the tool results and
1909
+ need to be added separately.
1910
+ */
1911
+ readonly responseMessages: Array<CoreAssistantMessage | CoreToolMessage>;
1891
1912
  }) => Promise<void> | void;
1892
1913
  /**
1893
1914
  Callback that is called when each step (LLM call) is finished, including intermediate steps.
package/dist/index.d.ts CHANGED
@@ -1394,11 +1394,12 @@ interface GenerateTextResult<TOOLS extends Record<string, CoreTool>> {
1394
1394
  */
1395
1395
  readonly warnings: CallWarning[] | undefined;
1396
1396
  /**
1397
- The response messages that were generated during the call. It consists of an assistant message,
1398
- potentially containing tool calls.
1399
- When there are tool results, there is an additional tool message with the tool results that are available.
1400
- If there are tools that do not have execute functions, they are not included in the tool results and
1401
- need to be added separately.
1397
+ The response messages that were generated during the call. It consists of an assistant message,
1398
+ potentially containing tool calls.
1399
+
1400
+ When there are tool results, there is an additional tool message with the tool results that are available.
1401
+ If there are tools that do not have execute functions, they are not included in the tool results and
1402
+ need to be added separately.
1402
1403
  */
1403
1404
  readonly responseMessages: Array<CoreAssistantMessage | CoreToolMessage>;
1404
1405
  /**
@@ -1614,6 +1615,17 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>> {
1614
1615
  headers?: Record<string, string>;
1615
1616
  };
1616
1617
  /**
1618
+ The response messages that were generated during the call. It consists of an assistant message,
1619
+ potentially containing tool calls.
1620
+
1621
+ When there are tool results, there is an additional tool message with the tool results that are available.
1622
+ If there are tools that do not have execute functions, they are not included in the tool results and
1623
+ need to be added separately.
1624
+
1625
+ Resolved when the response is finished.
1626
+ */
1627
+ readonly responseMessages: Promise<Array<CoreAssistantMessage | CoreToolMessage>>;
1628
+ /**
1617
1629
  Details for all steps.
1618
1630
  You can use this to get information about intermediate steps,
1619
1631
  such as the tool calls or the response headers.
@@ -1887,7 +1899,16 @@ The usage is the combined usage of all steps.
1887
1899
  /**
1888
1900
  Details for all steps.
1889
1901
  */
1890
- steps: StepResult<TOOLS>[];
1902
+ readonly steps: StepResult<TOOLS>[];
1903
+ /**
1904
+ The response messages that were generated during the call. It consists of an assistant message,
1905
+ potentially containing tool calls.
1906
+
1907
+ When there are tool results, there is an additional tool message with the tool results that are available.
1908
+ If there are tools that do not have execute functions, they are not included in the tool results and
1909
+ need to be added separately.
1910
+ */
1911
+ readonly responseMessages: Array<CoreAssistantMessage | CoreToolMessage>;
1891
1912
  }) => Promise<void> | void;
1892
1913
  /**
1893
1914
  Callback that is called when each step (LLM call) is finished, including intermediate steps.
package/dist/index.js CHANGED
@@ -3931,6 +3931,11 @@ var DefaultStreamTextResult = class {
3931
3931
  this.experimental_providerMetadata = providerMetadataPromise;
3932
3932
  const { resolve: resolveResponse, promise: responsePromise } = createResolvablePromise();
3933
3933
  this.response = responsePromise;
3934
+ const {
3935
+ resolve: resolveResponseMessages,
3936
+ promise: responseMessagesPromise
3937
+ } = createResolvablePromise();
3938
+ this.responseMessages = responseMessagesPromise;
3934
3939
  const {
3935
3940
  stream: stitchableStream,
3936
3941
  addStream,
@@ -4177,6 +4182,17 @@ var DefaultStreamTextResult = class {
4177
4182
  }
4178
4183
  })
4179
4184
  );
4185
+ const responseMessages = stepResults.reduce(
4186
+ (responseMessages2, step) => [
4187
+ ...responseMessages2,
4188
+ ...toResponseMessages({
4189
+ text: step.text,
4190
+ toolCalls: step.toolCalls,
4191
+ toolResults: step.toolResults
4192
+ })
4193
+ ],
4194
+ []
4195
+ );
4180
4196
  resolveUsage(combinedUsage);
4181
4197
  resolveFinishReason(stepFinishReason);
4182
4198
  resolveText(stepText);
@@ -4188,6 +4204,7 @@ var DefaultStreamTextResult = class {
4188
4204
  headers: rawResponse == null ? void 0 : rawResponse.headers
4189
4205
  });
4190
4206
  resolveSteps(stepResults);
4207
+ resolveResponseMessages(responseMessages);
4191
4208
  await (onFinish == null ? void 0 : onFinish({
4192
4209
  finishReason: stepFinishReason,
4193
4210
  logprobs: stepLogProbs,
@@ -4206,8 +4223,8 @@ var DefaultStreamTextResult = class {
4206
4223
  },
4207
4224
  warnings,
4208
4225
  experimental_providerMetadata: stepProviderMetadata,
4209
- steps: stepResults
4210
- // see tool results comment above
4226
+ steps: stepResults,
4227
+ responseMessages
4211
4228
  }));
4212
4229
  } catch (error) {
4213
4230
  controller.error(error);