@mastra/react 0.4.1-alpha.0 → 0.4.1-alpha.10
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 +85 -0
- package/dist/agent/hooks.d.ts +7 -1
- package/dist/agent/hooks.d.ts.map +1 -1
- package/dist/index.cjs +119 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +119 -49
- package/dist/index.js.map +1 -1
- package/dist/lib/ai-sdk/utils/toUIMessage.d.ts.map +1 -1
- package/dist/mastra-react-provider.d.ts +1 -1
- package/package.json +9 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
# @mastra/react
|
|
2
2
|
|
|
3
|
+
## 0.4.1-alpha.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`d72dc4b`](https://github.com/mastra-ai/mastra/commit/d72dc4b12d832546c05c20255fa96fe4eb515900)]:
|
|
8
|
+
- @mastra/core@1.37.0-alpha.9
|
|
9
|
+
- @mastra/client-js@1.21.0-alpha.10
|
|
10
|
+
|
|
11
|
+
## 0.4.1-alpha.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`271d891`](https://github.com/mastra-ai/mastra/commit/271d8917e4323340f9fe549f3e8de55810dbbcbe)]:
|
|
16
|
+
- @mastra/client-js@1.21.0-alpha.9
|
|
17
|
+
|
|
18
|
+
## 0.4.1-alpha.8
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Fixed `clientTools` being silently dropped — and never executed — on thread-backed chats. When a chat had a `threadId`, the React `useChat` hook routed messages through the new agent signals path but did not pass the `clientTools` map into the signal startup flow, so client-side tools were unavailable when the model requested them. ([#16540](https://github.com/mastra-ai/mastra/pull/16540))
|
|
23
|
+
|
|
24
|
+
The signals path now carries `clientTools` and other per-send stream options on `sendSignal`. When the subscribed stream finishes with `tool-calls`, the client executes matching local tools with observability support, emits tool result chunks, and posts a continuation with the assistant tool-call messages plus tool-result messages so the run resumes on the same thread with the same per-send options.
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [[`c35b962`](https://github.com/mastra-ai/mastra/commit/c35b9625c7e854fcfdeee226a3338a750d0ff211), [`c35b962`](https://github.com/mastra-ai/mastra/commit/c35b9625c7e854fcfdeee226a3338a750d0ff211), [`9be1545`](https://github.com/mastra-ai/mastra/commit/9be1545475eb81a716169bb1281a37853cc739e0), [`4084113`](https://github.com/mastra-ai/mastra/commit/408411370fc48a822e8b616b3b63f9409774e0e9), [`bc01b1b`](https://github.com/mastra-ai/mastra/commit/bc01b1bfafe381d90af909f8bce7eeb4eee779f2), [`1120b4f`](https://github.com/mastra-ai/mastra/commit/1120b4fa928552c6ee1751efa5603d955841e766)]:
|
|
27
|
+
- @mastra/core@1.37.0-alpha.8
|
|
28
|
+
- @mastra/client-js@1.21.0-alpha.8
|
|
29
|
+
|
|
30
|
+
## 0.4.1-alpha.7
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Added support for reasoning-start and reasoning-end stream chunks so reasoning blocks are opened and closed with provider metadata preserved. ([#17061](https://github.com/mastra-ai/mastra/pull/17061))
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`168fa09`](https://github.com/mastra-ai/mastra/commit/168fa09d6b39114cb8c13bd06f1dccb9bc81c6cd), [`af2e1f8`](https://github.com/mastra-ai/mastra/commit/af2e1f8e2a2d2c4ba75167d5c93ca44395639eff)]:
|
|
37
|
+
- @mastra/core@1.37.0-alpha.7
|
|
38
|
+
- @mastra/client-js@1.21.0-alpha.7
|
|
39
|
+
|
|
40
|
+
## 0.4.1-alpha.6
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [[`0cbece9`](https://github.com/mastra-ai/mastra/commit/0cbece9d832cb134a74cdbf3682d390a058215a4), [`7dfe1bc`](https://github.com/mastra-ai/mastra/commit/7dfe1bcfe71d261a6fd6bbf29b1dec49d78fb98f), [`70cb714`](https://github.com/mastra-ai/mastra/commit/70cb7149c8f16f478e15b58498254a53181750a4), [`7f9da22`](https://github.com/mastra-ai/mastra/commit/7f9da22efd5aa595e138a31de55a5f0f2f28b33d)]:
|
|
45
|
+
- @mastra/core@1.37.0-alpha.6
|
|
46
|
+
- @mastra/client-js@1.21.0-alpha.6
|
|
47
|
+
|
|
48
|
+
## 0.4.1-alpha.5
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [[`6096445`](https://github.com/mastra-ai/mastra/commit/60964459733f0ab384584d95e19c36607ffdf7b0), [`91cf0e0`](https://github.com/mastra-ai/mastra/commit/91cf0e027e511b871481a8576b56b7af83b15afd)]:
|
|
53
|
+
- @mastra/core@1.37.0-alpha.5
|
|
54
|
+
- @mastra/client-js@1.21.0-alpha.5
|
|
55
|
+
|
|
56
|
+
## 0.4.1-alpha.4
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [[`b7286f4`](https://github.com/mastra-ai/mastra/commit/b7286f4308267f5fd70e6bfee10dba9472640906), [`a481027`](https://github.com/mastra-ai/mastra/commit/a481027b549ba1018414990c8f045eaee7b9f413), [`801baa0`](https://github.com/mastra-ai/mastra/commit/801baa07cccdbaec1d00942a92bdc831111744a2), [`b3c3b18`](https://github.com/mastra-ai/mastra/commit/b3c3b189121489a3a51a8fd8204b569be9a89fe5)]:
|
|
61
|
+
- @mastra/core@1.37.0-alpha.4
|
|
62
|
+
- @mastra/client-js@1.21.0-alpha.4
|
|
63
|
+
|
|
64
|
+
## 0.4.1-alpha.3
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- Updated dependencies [[`ac442a4`](https://github.com/mastra-ai/mastra/commit/ac442a42fda0354ac2bcea772bf6691cb3e9dbb3), [`1e5c067`](https://github.com/mastra-ai/mastra/commit/1e5c067d2e20a781af670578180d1ee249806d41), [`008baaf`](https://github.com/mastra-ai/mastra/commit/008baafd8d851f831407045aebead5a2e3342eff), [`8116436`](https://github.com/mastra-ai/mastra/commit/81164363eb225d774e41ff27da6a5ea611406688), [`c27c4b9`](https://github.com/mastra-ai/mastra/commit/c27c4b9f137df5414fca4e45896aceccff6b0ed5), [`08b3b59`](https://github.com/mastra-ai/mastra/commit/08b3b590dd960dee6c9a6e39272f8927d803db6e)]:
|
|
69
|
+
- @mastra/core@1.37.0-alpha.3
|
|
70
|
+
- @mastra/client-js@1.21.0-alpha.3
|
|
71
|
+
|
|
72
|
+
## 0.4.1-alpha.2
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies [[`df1947a`](https://github.com/mastra-ai/mastra/commit/df1947affa40f742067542251fac7ca759492ef4), [`ee59b74`](https://github.com/mastra-ai/mastra/commit/ee59b743ce73ad11784b4d9c6fbba8568edee1c8), [`a97b1a0`](https://github.com/mastra-ai/mastra/commit/a97b1a0abaed83946c3519d1e0f680d0815b8a67)]:
|
|
77
|
+
- @mastra/core@1.37.0-alpha.2
|
|
78
|
+
- @mastra/client-js@1.21.0-alpha.2
|
|
79
|
+
|
|
80
|
+
## 0.4.1-alpha.1
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- Updated dependencies [[`2f5f58a`](https://github.com/mastra-ai/mastra/commit/2f5f58a9a8bb13bcdc6789db221eef7c9bf1ff02), [`2f5f58a`](https://github.com/mastra-ai/mastra/commit/2f5f58a9a8bb13bcdc6789db221eef7c9bf1ff02)]:
|
|
85
|
+
- @mastra/client-js@1.21.0-alpha.1
|
|
86
|
+
- @mastra/core@1.37.0-alpha.1
|
|
87
|
+
|
|
3
88
|
## 0.4.1-alpha.0
|
|
4
89
|
|
|
5
90
|
### Patch Changes
|
package/dist/agent/hooks.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ export interface MastraChatProps {
|
|
|
13
13
|
initialMessages?: MastraUIMessage[];
|
|
14
14
|
/** Persistent request context used for tool approval/decline calls (e.g. agentVersionId). */
|
|
15
15
|
requestContext?: RequestContext;
|
|
16
|
+
/**
|
|
17
|
+
* Client-side tool definitions. Forwarded once to `subscribeToThread` so
|
|
18
|
+
* the client-js subscription drives the full client-tool execution loop
|
|
19
|
+
* (execute, emit tool-result, continuation) without any logic in React.
|
|
20
|
+
*/
|
|
21
|
+
clientTools?: Record<string, unknown>;
|
|
16
22
|
onSignalSent?: (signalId: string, preview: string) => void;
|
|
17
23
|
onSignalEcho?: (signalId: string) => void;
|
|
18
24
|
onThreadSignalsUnsupported?: () => void;
|
|
@@ -55,7 +61,7 @@ export type StreamArgs = SharedArgs & {
|
|
|
55
61
|
export type NetworkArgs = SharedArgs & {
|
|
56
62
|
onNetworkChunk?: (chunk: NetworkChunkType) => Promise<void>;
|
|
57
63
|
};
|
|
58
|
-
export declare const useChat: ({ agentId, resourceId, threadId, initialMessages, requestContext: propsRequestContext, onSignalSent, onSignalEcho, onThreadSignalsUnsupported, enableThreadSignals, }: MastraChatProps) => {
|
|
64
|
+
export declare const useChat: ({ agentId, resourceId, threadId, initialMessages, requestContext: propsRequestContext, clientTools: hookClientTools, onSignalSent, onSignalEcho, onThreadSignalsUnsupported, enableThreadSignals, }: MastraChatProps) => {
|
|
59
65
|
setMessages: import("react").Dispatch<import("react").SetStateAction<MastraUIMessage[]>>;
|
|
60
66
|
sendMessage: ({ mode, ...args }: SendMessageArgs) => Promise<void>;
|
|
61
67
|
isRunning: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/agent/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,O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AQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D,CAAC;AAYF,eAAO,MAAM,OAAO,GAAI,qMAWrB,eAAe;;qCAmuByC,eAAe;;;kCAnM7B,MAAM;kCAiCN,MAAM;0CAgCE,MAAM;0CAgCN,MAAM;;;;oBA9mBvB,UAAU,GAAG,UAAU;;;uCA8oBT,MAAM,UAAU,MAAM;uCAiCtB,MAAM,UAAU,MAAM;;;oBA5qBtC,UAAU,GAAG,UAAU;;;CAsvBxD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -69,39 +69,6 @@ var MastraReactProvider = ({
|
|
|
69
69
|
);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
// src/agent/extractRunIdFromMessages.ts
|
|
73
|
-
var extractRunIdFromMessages = (messages) => {
|
|
74
|
-
for (const message of messages) {
|
|
75
|
-
const metadataSources = [
|
|
76
|
-
message.metadata?.pendingToolApprovals,
|
|
77
|
-
message.metadata?.requireApprovalMetadata,
|
|
78
|
-
message.metadata?.suspendedTools
|
|
79
|
-
];
|
|
80
|
-
for (const source of metadataSources) {
|
|
81
|
-
if (!source || typeof source !== "object") continue;
|
|
82
|
-
for (const suspensionData of Object.values(source)) {
|
|
83
|
-
if (suspensionData && typeof suspensionData === "object" && typeof suspensionData.runId === "string" && suspensionData.runId.length > 0) {
|
|
84
|
-
return suspensionData.runId;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return void 0;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// src/agent/signal-data.ts
|
|
93
|
-
function convertSignalDataToBase64String(content) {
|
|
94
|
-
if (typeof content === "string") {
|
|
95
|
-
return content;
|
|
96
|
-
}
|
|
97
|
-
const bytes = content instanceof ArrayBuffer ? new Uint8Array(content) : content;
|
|
98
|
-
let binary = "";
|
|
99
|
-
for (const byte of bytes) {
|
|
100
|
-
binary += String.fromCharCode(byte);
|
|
101
|
-
}
|
|
102
|
-
return btoa(binary);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
72
|
// src/lib/ai-sdk/utils/formatCompletionFeedback.ts
|
|
106
73
|
var formatBaseCompletionFeedback = (result, maxIterationReached, formatScorerHeading, incompleteMessage) => {
|
|
107
74
|
const lines = [];
|
|
@@ -513,6 +480,39 @@ var toUIMessage = ({ chunk, conversation, metadata }) => {
|
|
|
513
480
|
}
|
|
514
481
|
];
|
|
515
482
|
}
|
|
483
|
+
case "reasoning-start": {
|
|
484
|
+
const lastMessage = result[result.length - 1];
|
|
485
|
+
if (!lastMessage || lastMessage.role !== "assistant") {
|
|
486
|
+
const newMessage = {
|
|
487
|
+
id: `reasoning-${chunk.runId + Date.now()}`,
|
|
488
|
+
role: "assistant",
|
|
489
|
+
parts: [
|
|
490
|
+
{
|
|
491
|
+
type: "reasoning",
|
|
492
|
+
text: "",
|
|
493
|
+
state: "streaming",
|
|
494
|
+
providerMetadata: chunk.payload.providerMetadata
|
|
495
|
+
}
|
|
496
|
+
],
|
|
497
|
+
metadata
|
|
498
|
+
};
|
|
499
|
+
return [...result, newMessage];
|
|
500
|
+
}
|
|
501
|
+
const parts = [...lastMessage.parts];
|
|
502
|
+
parts.push({
|
|
503
|
+
type: "reasoning",
|
|
504
|
+
text: "",
|
|
505
|
+
state: "streaming",
|
|
506
|
+
providerMetadata: chunk.payload.providerMetadata
|
|
507
|
+
});
|
|
508
|
+
return [
|
|
509
|
+
...result.slice(0, -1),
|
|
510
|
+
{
|
|
511
|
+
...lastMessage,
|
|
512
|
+
parts
|
|
513
|
+
}
|
|
514
|
+
];
|
|
515
|
+
}
|
|
516
516
|
case "reasoning-delta": {
|
|
517
517
|
const lastMessage = result[result.length - 1];
|
|
518
518
|
if (!lastMessage || lastMessage.role !== "assistant") {
|
|
@@ -556,6 +556,36 @@ var toUIMessage = ({ chunk, conversation, metadata }) => {
|
|
|
556
556
|
}
|
|
557
557
|
];
|
|
558
558
|
}
|
|
559
|
+
case "reasoning-end": {
|
|
560
|
+
const lastMessage = result[result.length - 1];
|
|
561
|
+
if (!lastMessage || lastMessage.role !== "assistant") return result;
|
|
562
|
+
const parts = [...lastMessage.parts];
|
|
563
|
+
const reasoningPartIndex = parts.findLastIndex(
|
|
564
|
+
(part) => part.type === "reasoning" && part.state === "streaming"
|
|
565
|
+
);
|
|
566
|
+
if (reasoningPartIndex === -1) return result;
|
|
567
|
+
const reasoningPart = parts[reasoningPartIndex];
|
|
568
|
+
if (reasoningPart.type !== "reasoning") return result;
|
|
569
|
+
const existingMetadata = reasoningPart.providerMetadata;
|
|
570
|
+
const endMetadata = chunk.payload.providerMetadata;
|
|
571
|
+
parts[reasoningPartIndex] = {
|
|
572
|
+
...reasoningPart,
|
|
573
|
+
state: "done",
|
|
574
|
+
...existingMetadata || endMetadata ? {
|
|
575
|
+
providerMetadata: {
|
|
576
|
+
...existingMetadata ?? {},
|
|
577
|
+
...endMetadata ?? {}
|
|
578
|
+
}
|
|
579
|
+
} : {}
|
|
580
|
+
};
|
|
581
|
+
return [
|
|
582
|
+
...result.slice(0, -1),
|
|
583
|
+
{
|
|
584
|
+
...lastMessage,
|
|
585
|
+
parts
|
|
586
|
+
}
|
|
587
|
+
];
|
|
588
|
+
}
|
|
559
589
|
case "tool-call": {
|
|
560
590
|
const lastMessage = result[result.length - 1];
|
|
561
591
|
if (!lastMessage || lastMessage.role !== "assistant") {
|
|
@@ -1958,6 +1988,39 @@ var fromCoreUserMessageToUIMessage = (coreUserMessage) => {
|
|
|
1958
1988
|
};
|
|
1959
1989
|
};
|
|
1960
1990
|
|
|
1991
|
+
// src/agent/extractRunIdFromMessages.ts
|
|
1992
|
+
var extractRunIdFromMessages = (messages) => {
|
|
1993
|
+
for (const message of messages) {
|
|
1994
|
+
const metadataSources = [
|
|
1995
|
+
message.metadata?.pendingToolApprovals,
|
|
1996
|
+
message.metadata?.requireApprovalMetadata,
|
|
1997
|
+
message.metadata?.suspendedTools
|
|
1998
|
+
];
|
|
1999
|
+
for (const source of metadataSources) {
|
|
2000
|
+
if (!source || typeof source !== "object") continue;
|
|
2001
|
+
for (const suspensionData of Object.values(source)) {
|
|
2002
|
+
if (suspensionData && typeof suspensionData === "object" && typeof suspensionData.runId === "string" && suspensionData.runId.length > 0) {
|
|
2003
|
+
return suspensionData.runId;
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
return void 0;
|
|
2009
|
+
};
|
|
2010
|
+
|
|
2011
|
+
// src/agent/signal-data.ts
|
|
2012
|
+
function convertSignalDataToBase64String(content) {
|
|
2013
|
+
if (typeof content === "string") {
|
|
2014
|
+
return content;
|
|
2015
|
+
}
|
|
2016
|
+
const bytes = content instanceof ArrayBuffer ? new Uint8Array(content) : content;
|
|
2017
|
+
let binary = "";
|
|
2018
|
+
for (const byte of bytes) {
|
|
2019
|
+
binary += String.fromCharCode(byte);
|
|
2020
|
+
}
|
|
2021
|
+
return btoa(binary);
|
|
2022
|
+
}
|
|
2023
|
+
|
|
1961
2024
|
// src/agent/hooks.ts
|
|
1962
2025
|
var isThreadSignalUnsupportedError = (error) => {
|
|
1963
2026
|
const candidate = error;
|
|
@@ -1973,6 +2036,7 @@ var useChat = ({
|
|
|
1973
2036
|
threadId,
|
|
1974
2037
|
initialMessages,
|
|
1975
2038
|
requestContext: propsRequestContext,
|
|
2039
|
+
clientTools: hookClientTools,
|
|
1976
2040
|
onSignalSent,
|
|
1977
2041
|
onSignalEcho,
|
|
1978
2042
|
onThreadSignalsUnsupported,
|
|
@@ -2166,6 +2230,7 @@ var useChat = ({
|
|
|
2166
2230
|
requireToolApproval
|
|
2167
2231
|
} = modelSettings || {};
|
|
2168
2232
|
const resolvedRequestContext = requestContext ?? propsRequestContext;
|
|
2233
|
+
const resolvedClientTools = clientTools ?? hookClientTools;
|
|
2169
2234
|
_requestContext.current = resolvedRequestContext;
|
|
2170
2235
|
setIsRunning(true);
|
|
2171
2236
|
const clientWithAbort = new clientJs.MastraClient({
|
|
@@ -2193,7 +2258,7 @@ var useChat = ({
|
|
|
2193
2258
|
providerOptions,
|
|
2194
2259
|
tracingOptions,
|
|
2195
2260
|
requireToolApproval,
|
|
2196
|
-
clientTools
|
|
2261
|
+
clientTools: resolvedClientTools
|
|
2197
2262
|
});
|
|
2198
2263
|
if (response.finishReason === "suspended" && response.suspendPayload) {
|
|
2199
2264
|
const { toolCallId, toolName, args } = response.suspendPayload;
|
|
@@ -2253,6 +2318,23 @@ var useChat = ({
|
|
|
2253
2318
|
requireToolApproval
|
|
2254
2319
|
} = modelSettings || {};
|
|
2255
2320
|
const resolvedRequestContext = requestContext ?? propsRequestContext;
|
|
2321
|
+
const resolvedClientTools = clientTools ?? hookClientTools;
|
|
2322
|
+
const signalContinuationOptions = {
|
|
2323
|
+
maxSteps,
|
|
2324
|
+
modelSettings: {
|
|
2325
|
+
frequencyPenalty,
|
|
2326
|
+
presencePenalty,
|
|
2327
|
+
maxRetries,
|
|
2328
|
+
maxOutputTokens: maxTokens,
|
|
2329
|
+
temperature,
|
|
2330
|
+
topK,
|
|
2331
|
+
topP
|
|
2332
|
+
},
|
|
2333
|
+
instructions,
|
|
2334
|
+
providerOptions,
|
|
2335
|
+
requireToolApproval,
|
|
2336
|
+
tracingOptions
|
|
2337
|
+
};
|
|
2256
2338
|
_requestContext.current = resolvedRequestContext;
|
|
2257
2339
|
setIsRunning(true);
|
|
2258
2340
|
_streamAbortRef.current?.abort();
|
|
@@ -2287,7 +2369,7 @@ var useChat = ({
|
|
|
2287
2369
|
providerOptions,
|
|
2288
2370
|
requireToolApproval,
|
|
2289
2371
|
tracingOptions,
|
|
2290
|
-
clientTools
|
|
2372
|
+
clientTools: resolvedClientTools
|
|
2291
2373
|
});
|
|
2292
2374
|
_onChunk.current = onChunk;
|
|
2293
2375
|
_currentRunId.current = runId;
|
|
@@ -2322,21 +2404,9 @@ var useChat = ({
|
|
|
2322
2404
|
threadId: threadId2,
|
|
2323
2405
|
ifIdle: {
|
|
2324
2406
|
streamOptions: {
|
|
2325
|
-
|
|
2326
|
-
modelSettings: {
|
|
2327
|
-
frequencyPenalty,
|
|
2328
|
-
presencePenalty,
|
|
2329
|
-
maxRetries,
|
|
2330
|
-
maxOutputTokens: maxTokens,
|
|
2331
|
-
temperature,
|
|
2332
|
-
topK,
|
|
2333
|
-
topP
|
|
2334
|
-
},
|
|
2335
|
-
instructions,
|
|
2407
|
+
...signalContinuationOptions,
|
|
2336
2408
|
requestContext: resolvedRequestContext,
|
|
2337
|
-
|
|
2338
|
-
requireToolApproval,
|
|
2339
|
-
tracingOptions
|
|
2409
|
+
clientTools: resolvedClientTools
|
|
2340
2410
|
}
|
|
2341
2411
|
}
|
|
2342
2412
|
});
|