ai 3.1.23 → 3.1.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "3.1.23",
3
+ "version": "3.1.24",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -227,15 +227,39 @@ type FunctionCallHandler = (chatMessages: Message[], functionCall: FunctionCall)
227
227
  */
228
228
  type ToolCallHandler = (chatMessages: Message[], toolCalls: ToolCall[]) => Promise<ChatRequest | void>;
229
229
  type RequestOptions = {
230
+ /**
231
+ An optional object of headers to be passed to the API endpoint.
232
+ */
230
233
  headers?: Record<string, string> | Headers;
234
+ /**
235
+ An optional object to be passed to the API endpoint.
236
+ */
231
237
  body?: object;
232
238
  };
233
239
  type ChatRequestOptions = {
240
+ /**
241
+ The options to be passed to the fetch call.
242
+ */
234
243
  options?: RequestOptions;
244
+ /**
245
+ @deprecated
246
+ */
235
247
  functions?: Array<Function>;
248
+ /**
249
+ @deprecated
250
+ */
236
251
  function_call?: FunctionCall;
252
+ /**
253
+ @deprecated
254
+ */
237
255
  tools?: Array<Tool>;
256
+ /**
257
+ @deprecated
258
+ */
238
259
  tool_choice?: ToolChoice;
260
+ /**
261
+ Additional data to be sent to the server.
262
+ */
239
263
  data?: Record<string, string>;
240
264
  };
241
265
  type UseChatOptions = {
@@ -227,15 +227,39 @@ type FunctionCallHandler = (chatMessages: Message[], functionCall: FunctionCall)
227
227
  */
228
228
  type ToolCallHandler = (chatMessages: Message[], toolCalls: ToolCall[]) => Promise<ChatRequest | void>;
229
229
  type RequestOptions = {
230
+ /**
231
+ An optional object of headers to be passed to the API endpoint.
232
+ */
230
233
  headers?: Record<string, string> | Headers;
234
+ /**
235
+ An optional object to be passed to the API endpoint.
236
+ */
231
237
  body?: object;
232
238
  };
233
239
  type ChatRequestOptions = {
240
+ /**
241
+ The options to be passed to the fetch call.
242
+ */
234
243
  options?: RequestOptions;
244
+ /**
245
+ @deprecated
246
+ */
235
247
  functions?: Array<Function>;
248
+ /**
249
+ @deprecated
250
+ */
236
251
  function_call?: FunctionCall;
252
+ /**
253
+ @deprecated
254
+ */
237
255
  tools?: Array<Tool>;
256
+ /**
257
+ @deprecated
258
+ */
238
259
  tool_choice?: ToolChoice;
260
+ /**
261
+ Additional data to be sent to the server.
262
+ */
239
263
  data?: Record<string, string>;
240
264
  };
241
265
  type UseChatOptions = {
@@ -28,11 +28,16 @@ type MutableAIState<AIState> = {
28
28
  update: (newState: ValueOrUpdater<AIState>) => void;
29
29
  done: ((newState: AIState) => void) | (() => void);
30
30
  };
31
+ declare const __internal_curr: unique symbol;
32
+ declare const __internal_error: unique symbol;
31
33
  /**
32
34
  * StreamableValue is a value that can be streamed over the network via AI Actions.
33
35
  * To read the streamed values, use the `readStreamableValue` or `useStreamableValue` APIs.
34
36
  */
35
- type StreamableValue<T = any, E = any> = {};
37
+ type StreamableValue<T = any, E = any> = {
38
+ [__internal_curr]?: T;
39
+ [__internal_error]?: E;
40
+ };
36
41
 
37
42
  /**
38
43
  * Get the current AI state.
@@ -26,11 +26,16 @@ type MutableAIState<AIState> = {
26
26
  update: (newState: ValueOrUpdater<AIState>) => void;
27
27
  done: ((newState: AIState) => void) | (() => void);
28
28
  };
29
+ declare const __internal_curr: unique symbol;
30
+ declare const __internal_error: unique symbol;
29
31
  /**
30
32
  * StreamableValue is a value that can be streamed over the network via AI Actions.
31
33
  * To read the streamed values, use the `readStreamableValue` or `useStreamableValue` APIs.
32
34
  */
33
- type StreamableValue<T = any, E = any> = {};
35
+ type StreamableValue<T = any, E = any> = {
36
+ [__internal_curr]?: T;
37
+ [__internal_error]?: E;
38
+ };
34
39
 
35
40
  /**
36
41
  * Get the current AI state.
@@ -22,11 +22,16 @@ type InferAIState<T, Fallback> = T extends AIProvider<infer AIState, any, any> ?
22
22
  type InferUIState<T, Fallback> = T extends AIProvider<any, infer UIState, any> ? UIState : Fallback;
23
23
  type InferActions<T, Fallback> = T extends AIProvider<any, any, infer Actions> ? Actions : Fallback;
24
24
  type ValueOrUpdater<T> = T | ((current: T) => T);
25
+ declare const __internal_curr: unique symbol;
26
+ declare const __internal_error: unique symbol;
25
27
  /**
26
28
  * StreamableValue is a value that can be streamed over the network via AI Actions.
27
29
  * To read the streamed values, use the `readStreamableValue` or `useStreamableValue` APIs.
28
30
  */
29
- type StreamableValue<T = any, E = any> = {};
31
+ type StreamableValue<T = any, E = any> = {
32
+ [__internal_curr]?: T;
33
+ [__internal_error]?: E;
34
+ };
30
35
 
31
36
  /**
32
37
  * `readStreamableValue` takes a streamable value created via the `createStreamableValue().value` API,
@@ -197,15 +197,39 @@ type FunctionCallHandler = (chatMessages: Message[], functionCall: FunctionCall)
197
197
  */
198
198
  type ToolCallHandler = (chatMessages: Message[], toolCalls: ToolCall[]) => Promise<ChatRequest | void>;
199
199
  type RequestOptions = {
200
+ /**
201
+ An optional object of headers to be passed to the API endpoint.
202
+ */
200
203
  headers?: Record<string, string> | Headers;
204
+ /**
205
+ An optional object to be passed to the API endpoint.
206
+ */
201
207
  body?: object;
202
208
  };
203
209
  type ChatRequestOptions = {
210
+ /**
211
+ The options to be passed to the fetch call.
212
+ */
204
213
  options?: RequestOptions;
214
+ /**
215
+ @deprecated
216
+ */
205
217
  functions?: Array<Function>;
218
+ /**
219
+ @deprecated
220
+ */
206
221
  function_call?: FunctionCall;
222
+ /**
223
+ @deprecated
224
+ */
207
225
  tools?: Array<Tool>;
226
+ /**
227
+ @deprecated
228
+ */
208
229
  tool_choice?: ToolChoice;
230
+ /**
231
+ Additional data to be sent to the server.
232
+ */
209
233
  data?: Record<string, string>;
210
234
  };
211
235
  type UseChatOptions = {
@@ -197,15 +197,39 @@ type FunctionCallHandler = (chatMessages: Message[], functionCall: FunctionCall)
197
197
  */
198
198
  type ToolCallHandler = (chatMessages: Message[], toolCalls: ToolCall[]) => Promise<ChatRequest | void>;
199
199
  type RequestOptions = {
200
+ /**
201
+ An optional object of headers to be passed to the API endpoint.
202
+ */
200
203
  headers?: Record<string, string> | Headers;
204
+ /**
205
+ An optional object to be passed to the API endpoint.
206
+ */
201
207
  body?: object;
202
208
  };
203
209
  type ChatRequestOptions = {
210
+ /**
211
+ The options to be passed to the fetch call.
212
+ */
204
213
  options?: RequestOptions;
214
+ /**
215
+ @deprecated
216
+ */
205
217
  functions?: Array<Function>;
218
+ /**
219
+ @deprecated
220
+ */
206
221
  function_call?: FunctionCall;
222
+ /**
223
+ @deprecated
224
+ */
207
225
  tools?: Array<Tool>;
226
+ /**
227
+ @deprecated
228
+ */
208
229
  tool_choice?: ToolChoice;
230
+ /**
231
+ Additional data to be sent to the server.
232
+ */
209
233
  data?: Record<string, string>;
210
234
  };
211
235
  type UseChatOptions = {
@@ -229,15 +229,39 @@ type FunctionCallHandler = (chatMessages: Message[], functionCall: FunctionCall)
229
229
  */
230
230
  type ToolCallHandler = (chatMessages: Message[], toolCalls: ToolCall[]) => Promise<ChatRequest | void>;
231
231
  type RequestOptions = {
232
+ /**
233
+ An optional object of headers to be passed to the API endpoint.
234
+ */
232
235
  headers?: Record<string, string> | Headers;
236
+ /**
237
+ An optional object to be passed to the API endpoint.
238
+ */
233
239
  body?: object;
234
240
  };
235
241
  type ChatRequestOptions = {
242
+ /**
243
+ The options to be passed to the fetch call.
244
+ */
236
245
  options?: RequestOptions;
246
+ /**
247
+ @deprecated
248
+ */
237
249
  functions?: Array<Function>;
250
+ /**
251
+ @deprecated
252
+ */
238
253
  function_call?: FunctionCall;
254
+ /**
255
+ @deprecated
256
+ */
239
257
  tools?: Array<Tool>;
258
+ /**
259
+ @deprecated
260
+ */
240
261
  tool_choice?: ToolChoice;
262
+ /**
263
+ Additional data to be sent to the server.
264
+ */
241
265
  data?: Record<string, string>;
242
266
  };
243
267
  type UseChatOptions = {
@@ -229,15 +229,39 @@ type FunctionCallHandler = (chatMessages: Message[], functionCall: FunctionCall)
229
229
  */
230
230
  type ToolCallHandler = (chatMessages: Message[], toolCalls: ToolCall[]) => Promise<ChatRequest | void>;
231
231
  type RequestOptions = {
232
+ /**
233
+ An optional object of headers to be passed to the API endpoint.
234
+ */
232
235
  headers?: Record<string, string> | Headers;
236
+ /**
237
+ An optional object to be passed to the API endpoint.
238
+ */
233
239
  body?: object;
234
240
  };
235
241
  type ChatRequestOptions = {
242
+ /**
243
+ The options to be passed to the fetch call.
244
+ */
236
245
  options?: RequestOptions;
246
+ /**
247
+ @deprecated
248
+ */
237
249
  functions?: Array<Function>;
250
+ /**
251
+ @deprecated
252
+ */
238
253
  function_call?: FunctionCall;
254
+ /**
255
+ @deprecated
256
+ */
239
257
  tools?: Array<Tool>;
258
+ /**
259
+ @deprecated
260
+ */
240
261
  tool_choice?: ToolChoice;
262
+ /**
263
+ Additional data to be sent to the server.
264
+ */
241
265
  data?: Record<string, string>;
242
266
  };
243
267
  type UseChatOptions = {
@@ -197,15 +197,39 @@ type FunctionCallHandler = (chatMessages: Message[], functionCall: FunctionCall)
197
197
  */
198
198
  type ToolCallHandler = (chatMessages: Message[], toolCalls: ToolCall[]) => Promise<ChatRequest | void>;
199
199
  type RequestOptions = {
200
+ /**
201
+ An optional object of headers to be passed to the API endpoint.
202
+ */
200
203
  headers?: Record<string, string> | Headers;
204
+ /**
205
+ An optional object to be passed to the API endpoint.
206
+ */
201
207
  body?: object;
202
208
  };
203
209
  type ChatRequestOptions = {
210
+ /**
211
+ The options to be passed to the fetch call.
212
+ */
204
213
  options?: RequestOptions;
214
+ /**
215
+ @deprecated
216
+ */
205
217
  functions?: Array<Function>;
218
+ /**
219
+ @deprecated
220
+ */
206
221
  function_call?: FunctionCall;
222
+ /**
223
+ @deprecated
224
+ */
207
225
  tools?: Array<Tool>;
226
+ /**
227
+ @deprecated
228
+ */
208
229
  tool_choice?: ToolChoice;
230
+ /**
231
+ Additional data to be sent to the server.
232
+ */
209
233
  data?: Record<string, string>;
210
234
  };
211
235
  type UseChatOptions = {
@@ -197,15 +197,39 @@ type FunctionCallHandler = (chatMessages: Message[], functionCall: FunctionCall)
197
197
  */
198
198
  type ToolCallHandler = (chatMessages: Message[], toolCalls: ToolCall[]) => Promise<ChatRequest | void>;
199
199
  type RequestOptions = {
200
+ /**
201
+ An optional object of headers to be passed to the API endpoint.
202
+ */
200
203
  headers?: Record<string, string> | Headers;
204
+ /**
205
+ An optional object to be passed to the API endpoint.
206
+ */
201
207
  body?: object;
202
208
  };
203
209
  type ChatRequestOptions = {
210
+ /**
211
+ The options to be passed to the fetch call.
212
+ */
204
213
  options?: RequestOptions;
214
+ /**
215
+ @deprecated
216
+ */
205
217
  functions?: Array<Function>;
218
+ /**
219
+ @deprecated
220
+ */
206
221
  function_call?: FunctionCall;
222
+ /**
223
+ @deprecated
224
+ */
207
225
  tools?: Array<Tool>;
226
+ /**
227
+ @deprecated
228
+ */
208
229
  tool_choice?: ToolChoice;
230
+ /**
231
+ Additional data to be sent to the server.
232
+ */
209
233
  data?: Record<string, string>;
210
234
  };
211
235
  type UseChatOptions = {