ai 3.1.22 → 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/dist/index.d.mts +52 -8
- package/dist/index.d.ts +52 -8
- package/dist/index.js +53 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/react/dist/index.d.mts +31 -3
- package/react/dist/index.d.ts +31 -3
- package/react/dist/index.js +4 -3
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +4 -3
- package/react/dist/index.mjs.map +1 -1
- package/rsc/dist/index.d.ts +7 -2
- package/rsc/dist/rsc-server.d.mts +7 -2
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.d.mts +6 -1
- package/solid/dist/index.d.mts +24 -0
- package/solid/dist/index.d.ts +24 -0
- package/svelte/dist/index.d.mts +24 -0
- package/svelte/dist/index.d.ts +24 -0
- package/vue/dist/index.d.mts +24 -0
- package/vue/dist/index.d.ts +24 -0
package/package.json
CHANGED
package/react/dist/index.d.mts
CHANGED
@@ -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 = {
|
@@ -486,14 +510,18 @@ type StreamingReactResponseAction = (payload: {
|
|
486
510
|
messages: Message[];
|
487
511
|
data?: Record<string, string>;
|
488
512
|
}) => Promise<experimental_StreamingReactResponse>;
|
489
|
-
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, onToolCall, experimental_maxAutomaticRoundtrips, maxAutomaticRoundtrips, streamMode, onResponse, onFinish, onError, credentials, headers, body, generateId, }?: Omit<UseChatOptions, 'api'> & {
|
513
|
+
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, onToolCall, experimental_maxAutomaticRoundtrips, maxAutomaticRoundtrips, maxToolRoundtrips, streamMode, onResponse, onFinish, onError, credentials, headers, body, generateId, }?: Omit<UseChatOptions, 'api'> & {
|
490
514
|
api?: string | StreamingReactResponseAction;
|
491
515
|
key?: string;
|
492
516
|
/**
|
493
|
-
@deprecated Use `
|
517
|
+
@deprecated Use `maxToolRoundtrips` instead.
|
494
518
|
*/
|
495
519
|
experimental_maxAutomaticRoundtrips?: number;
|
496
520
|
/**
|
521
|
+
@deprecated Use `maxToolRoundtrips` instead.
|
522
|
+
*/
|
523
|
+
maxAutomaticRoundtrips?: number;
|
524
|
+
/**
|
497
525
|
Maximal number of automatic roundtrips for tool calls.
|
498
526
|
|
499
527
|
An automatic tool call roundtrip is a call to the server with the
|
@@ -505,7 +533,7 @@ declare function useChat({ api, id, initialMessages, initialInput, sendExtraMess
|
|
505
533
|
|
506
534
|
By default, it's set to 0, which will disable the feature.
|
507
535
|
*/
|
508
|
-
|
536
|
+
maxToolRoundtrips?: number;
|
509
537
|
}): UseChatHelpers & {
|
510
538
|
/**
|
511
539
|
* @deprecated Use `addToolResult` instead.
|
package/react/dist/index.d.ts
CHANGED
@@ -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 = {
|
@@ -486,14 +510,18 @@ type StreamingReactResponseAction = (payload: {
|
|
486
510
|
messages: Message[];
|
487
511
|
data?: Record<string, string>;
|
488
512
|
}) => Promise<experimental_StreamingReactResponse>;
|
489
|
-
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, onToolCall, experimental_maxAutomaticRoundtrips, maxAutomaticRoundtrips, streamMode, onResponse, onFinish, onError, credentials, headers, body, generateId, }?: Omit<UseChatOptions, 'api'> & {
|
513
|
+
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, onToolCall, experimental_maxAutomaticRoundtrips, maxAutomaticRoundtrips, maxToolRoundtrips, streamMode, onResponse, onFinish, onError, credentials, headers, body, generateId, }?: Omit<UseChatOptions, 'api'> & {
|
490
514
|
api?: string | StreamingReactResponseAction;
|
491
515
|
key?: string;
|
492
516
|
/**
|
493
|
-
@deprecated Use `
|
517
|
+
@deprecated Use `maxToolRoundtrips` instead.
|
494
518
|
*/
|
495
519
|
experimental_maxAutomaticRoundtrips?: number;
|
496
520
|
/**
|
521
|
+
@deprecated Use `maxToolRoundtrips` instead.
|
522
|
+
*/
|
523
|
+
maxAutomaticRoundtrips?: number;
|
524
|
+
/**
|
497
525
|
Maximal number of automatic roundtrips for tool calls.
|
498
526
|
|
499
527
|
An automatic tool call roundtrip is a call to the server with the
|
@@ -505,7 +533,7 @@ declare function useChat({ api, id, initialMessages, initialInput, sendExtraMess
|
|
505
533
|
|
506
534
|
By default, it's set to 0, which will disable the feature.
|
507
535
|
*/
|
508
|
-
|
536
|
+
maxToolRoundtrips?: number;
|
509
537
|
}): UseChatHelpers & {
|
510
538
|
/**
|
511
539
|
* @deprecated Use `addToolResult` instead.
|
package/react/dist/index.js
CHANGED
@@ -792,6 +792,7 @@ function useChat({
|
|
792
792
|
onToolCall,
|
793
793
|
experimental_maxAutomaticRoundtrips = 0,
|
794
794
|
maxAutomaticRoundtrips = experimental_maxAutomaticRoundtrips,
|
795
|
+
maxToolRoundtrips = maxAutomaticRoundtrips,
|
795
796
|
streamMode,
|
796
797
|
onResponse,
|
797
798
|
onFinish,
|
@@ -882,9 +883,9 @@ function useChat({
|
|
882
883
|
if (
|
883
884
|
// ensure there is a last message:
|
884
885
|
lastMessage != null && // check if the feature is enabled:
|
885
|
-
|
886
|
+
maxToolRoundtrips > 0 && // check that roundtrip is possible:
|
886
887
|
isAssistantMessageWithCompletedToolCalls(lastMessage) && // limit the number of automatic roundtrips:
|
887
|
-
countTrailingAssistantMessages(messages2) <=
|
888
|
+
countTrailingAssistantMessages(messages2) <= maxToolRoundtrips
|
888
889
|
) {
|
889
890
|
await triggerRequest({ messages: messages2 });
|
890
891
|
}
|
@@ -905,7 +906,7 @@ function useChat({
|
|
905
906
|
experimental_onFunctionCall,
|
906
907
|
experimental_onToolCall,
|
907
908
|
onToolCall,
|
908
|
-
|
909
|
+
maxToolRoundtrips,
|
909
910
|
messagesRef,
|
910
911
|
abortControllerRef,
|
911
912
|
generateId2
|