ai 0.0.0-85f9a635-20240518005312 → 0.0.0-9477ebb9-20250403064906

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +3521 -0
  2. package/README.md +112 -22
  3. package/dist/index.d.mts +3697 -1642
  4. package/dist/index.d.ts +3697 -1642
  5. package/dist/index.js +7201 -2942
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +7249 -2963
  8. package/dist/index.mjs.map +1 -1
  9. package/mcp-stdio/create-child-process.test.ts +92 -0
  10. package/mcp-stdio/create-child-process.ts +21 -0
  11. package/mcp-stdio/dist/index.d.mts +169 -0
  12. package/mcp-stdio/dist/index.d.ts +169 -0
  13. package/mcp-stdio/dist/index.js +352 -0
  14. package/mcp-stdio/dist/index.js.map +1 -0
  15. package/mcp-stdio/dist/index.mjs +337 -0
  16. package/mcp-stdio/dist/index.mjs.map +1 -0
  17. package/mcp-stdio/get-environment.ts +43 -0
  18. package/mcp-stdio/index.ts +4 -0
  19. package/mcp-stdio/mcp-stdio-transport.test.ts +262 -0
  20. package/mcp-stdio/mcp-stdio-transport.ts +157 -0
  21. package/package.json +46 -103
  22. package/react/dist/index.d.mts +10 -557
  23. package/react/dist/index.d.ts +10 -574
  24. package/react/dist/index.js +6 -1397
  25. package/react/dist/index.js.map +1 -1
  26. package/react/dist/index.mjs +10 -1384
  27. package/react/dist/index.mjs.map +1 -1
  28. package/rsc/dist/index.d.ts +432 -199
  29. package/rsc/dist/rsc-server.d.mts +431 -199
  30. package/rsc/dist/rsc-server.mjs +1599 -1357
  31. package/rsc/dist/rsc-server.mjs.map +1 -1
  32. package/rsc/dist/rsc-shared.d.mts +30 -23
  33. package/rsc/dist/rsc-shared.mjs +70 -108
  34. package/rsc/dist/rsc-shared.mjs.map +1 -1
  35. package/test/dist/index.d.mts +65 -0
  36. package/test/dist/index.d.ts +65 -0
  37. package/test/dist/index.js +121 -0
  38. package/test/dist/index.js.map +1 -0
  39. package/test/dist/index.mjs +94 -0
  40. package/test/dist/index.mjs.map +1 -0
  41. package/prompts/dist/index.d.mts +0 -324
  42. package/prompts/dist/index.d.ts +0 -324
  43. package/prompts/dist/index.js +0 -178
  44. package/prompts/dist/index.js.map +0 -1
  45. package/prompts/dist/index.mjs +0 -146
  46. package/prompts/dist/index.mjs.map +0 -1
  47. package/react/dist/index.server.d.mts +0 -17
  48. package/react/dist/index.server.d.ts +0 -17
  49. package/react/dist/index.server.js +0 -50
  50. package/react/dist/index.server.js.map +0 -1
  51. package/react/dist/index.server.mjs +0 -23
  52. package/react/dist/index.server.mjs.map +0 -1
  53. package/solid/dist/index.d.mts +0 -408
  54. package/solid/dist/index.d.ts +0 -408
  55. package/solid/dist/index.js +0 -1072
  56. package/solid/dist/index.js.map +0 -1
  57. package/solid/dist/index.mjs +0 -1044
  58. package/solid/dist/index.mjs.map +0 -1
  59. package/svelte/dist/index.d.mts +0 -484
  60. package/svelte/dist/index.d.ts +0 -484
  61. package/svelte/dist/index.js +0 -1778
  62. package/svelte/dist/index.js.map +0 -1
  63. package/svelte/dist/index.mjs +0 -1749
  64. package/svelte/dist/index.mjs.map +0 -1
  65. package/vue/dist/index.d.mts +0 -402
  66. package/vue/dist/index.d.ts +0 -402
  67. package/vue/dist/index.js +0 -1072
  68. package/vue/dist/index.js.map +0 -1
  69. package/vue/dist/index.mjs +0 -1034
  70. package/vue/dist/index.mjs.map +0 -1
@@ -1,1390 +1,16 @@
1
1
  'use client'
2
2
 
3
- // react/use-chat.ts
4
- import { useCallback, useEffect, useId, useRef, useState } from "react";
5
- import useSWR from "swr";
6
-
7
- // shared/generate-id.ts
8
- import { customAlphabet } from "nanoid/non-secure";
9
- var generateId = customAlphabet(
10
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
11
- 7
12
- );
13
-
14
- // shared/stream-parts.ts
15
- var textStreamPart = {
16
- code: "0",
17
- name: "text",
18
- parse: (value) => {
19
- if (typeof value !== "string") {
20
- throw new Error('"text" parts expect a string value.');
21
- }
22
- return { type: "text", value };
23
- }
24
- };
25
- var functionCallStreamPart = {
26
- code: "1",
27
- name: "function_call",
28
- parse: (value) => {
29
- if (value == null || typeof value !== "object" || !("function_call" in value) || typeof value.function_call !== "object" || value.function_call == null || !("name" in value.function_call) || !("arguments" in value.function_call) || typeof value.function_call.name !== "string" || typeof value.function_call.arguments !== "string") {
30
- throw new Error(
31
- '"function_call" parts expect an object with a "function_call" property.'
32
- );
33
- }
34
- return {
35
- type: "function_call",
36
- value
37
- };
38
- }
39
- };
40
- var dataStreamPart = {
41
- code: "2",
42
- name: "data",
43
- parse: (value) => {
44
- if (!Array.isArray(value)) {
45
- throw new Error('"data" parts expect an array value.');
46
- }
47
- return { type: "data", value };
48
- }
49
- };
50
- var errorStreamPart = {
51
- code: "3",
52
- name: "error",
53
- parse: (value) => {
54
- if (typeof value !== "string") {
55
- throw new Error('"error" parts expect a string value.');
56
- }
57
- return { type: "error", value };
58
- }
59
- };
60
- var assistantMessageStreamPart = {
61
- code: "4",
62
- name: "assistant_message",
63
- parse: (value) => {
64
- if (value == null || typeof value !== "object" || !("id" in value) || !("role" in value) || !("content" in value) || typeof value.id !== "string" || typeof value.role !== "string" || value.role !== "assistant" || !Array.isArray(value.content) || !value.content.every(
65
- (item) => item != null && typeof item === "object" && "type" in item && item.type === "text" && "text" in item && item.text != null && typeof item.text === "object" && "value" in item.text && typeof item.text.value === "string"
66
- )) {
67
- throw new Error(
68
- '"assistant_message" parts expect an object with an "id", "role", and "content" property.'
69
- );
70
- }
71
- return {
72
- type: "assistant_message",
73
- value
74
- };
75
- }
76
- };
77
- var assistantControlDataStreamPart = {
78
- code: "5",
79
- name: "assistant_control_data",
80
- parse: (value) => {
81
- if (value == null || typeof value !== "object" || !("threadId" in value) || !("messageId" in value) || typeof value.threadId !== "string" || typeof value.messageId !== "string") {
82
- throw new Error(
83
- '"assistant_control_data" parts expect an object with a "threadId" and "messageId" property.'
84
- );
85
- }
86
- return {
87
- type: "assistant_control_data",
88
- value: {
89
- threadId: value.threadId,
90
- messageId: value.messageId
91
- }
92
- };
93
- }
94
- };
95
- var dataMessageStreamPart = {
96
- code: "6",
97
- name: "data_message",
98
- parse: (value) => {
99
- if (value == null || typeof value !== "object" || !("role" in value) || !("data" in value) || typeof value.role !== "string" || value.role !== "data") {
100
- throw new Error(
101
- '"data_message" parts expect an object with a "role" and "data" property.'
102
- );
103
- }
104
- return {
105
- type: "data_message",
106
- value
107
- };
108
- }
109
- };
110
- var toolCallsStreamPart = {
111
- code: "7",
112
- name: "tool_calls",
113
- parse: (value) => {
114
- if (value == null || typeof value !== "object" || !("tool_calls" in value) || typeof value.tool_calls !== "object" || value.tool_calls == null || !Array.isArray(value.tool_calls) || value.tool_calls.some(
115
- (tc) => tc == null || typeof tc !== "object" || !("id" in tc) || typeof tc.id !== "string" || !("type" in tc) || typeof tc.type !== "string" || !("function" in tc) || tc.function == null || typeof tc.function !== "object" || !("arguments" in tc.function) || typeof tc.function.name !== "string" || typeof tc.function.arguments !== "string"
116
- )) {
117
- throw new Error(
118
- '"tool_calls" parts expect an object with a ToolCallPayload.'
119
- );
120
- }
121
- return {
122
- type: "tool_calls",
123
- value
124
- };
125
- }
126
- };
127
- var messageAnnotationsStreamPart = {
128
- code: "8",
129
- name: "message_annotations",
130
- parse: (value) => {
131
- if (!Array.isArray(value)) {
132
- throw new Error('"message_annotations" parts expect an array value.');
133
- }
134
- return { type: "message_annotations", value };
135
- }
136
- };
137
- var toolCallStreamPart = {
138
- code: "9",
139
- name: "tool_call",
140
- parse: (value) => {
141
- if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("toolName" in value) || typeof value.toolName !== "string" || !("args" in value) || typeof value.args !== "object") {
142
- throw new Error(
143
- '"tool_call" parts expect an object with a "toolCallId", "toolName", and "args" property.'
144
- );
145
- }
146
- return {
147
- type: "tool_call",
148
- value
149
- };
150
- }
151
- };
152
- var toolResultStreamPart = {
153
- code: "a",
154
- name: "tool_result",
155
- parse: (value) => {
156
- if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("toolName" in value) || typeof value.toolName !== "string" || !("args" in value) || typeof value.args !== "object" || !("result" in value)) {
157
- throw new Error(
158
- '"tool_result" parts expect an object with a "toolCallId", "toolName", "args", and "result" property.'
159
- );
160
- }
161
- return {
162
- type: "tool_result",
163
- value
164
- };
165
- }
166
- };
167
- var streamParts = [
168
- textStreamPart,
169
- functionCallStreamPart,
170
- dataStreamPart,
171
- errorStreamPart,
172
- assistantMessageStreamPart,
173
- assistantControlDataStreamPart,
174
- dataMessageStreamPart,
175
- toolCallsStreamPart,
176
- messageAnnotationsStreamPart,
177
- toolCallStreamPart,
178
- toolResultStreamPart
179
- ];
180
- var streamPartsByCode = {
181
- [textStreamPart.code]: textStreamPart,
182
- [functionCallStreamPart.code]: functionCallStreamPart,
183
- [dataStreamPart.code]: dataStreamPart,
184
- [errorStreamPart.code]: errorStreamPart,
185
- [assistantMessageStreamPart.code]: assistantMessageStreamPart,
186
- [assistantControlDataStreamPart.code]: assistantControlDataStreamPart,
187
- [dataMessageStreamPart.code]: dataMessageStreamPart,
188
- [toolCallsStreamPart.code]: toolCallsStreamPart,
189
- [messageAnnotationsStreamPart.code]: messageAnnotationsStreamPart,
190
- [toolCallStreamPart.code]: toolCallStreamPart,
191
- [toolResultStreamPart.code]: toolResultStreamPart
192
- };
193
- var StreamStringPrefixes = {
194
- [textStreamPart.name]: textStreamPart.code,
195
- [functionCallStreamPart.name]: functionCallStreamPart.code,
196
- [dataStreamPart.name]: dataStreamPart.code,
197
- [errorStreamPart.name]: errorStreamPart.code,
198
- [assistantMessageStreamPart.name]: assistantMessageStreamPart.code,
199
- [assistantControlDataStreamPart.name]: assistantControlDataStreamPart.code,
200
- [dataMessageStreamPart.name]: dataMessageStreamPart.code,
201
- [toolCallsStreamPart.name]: toolCallsStreamPart.code,
202
- [messageAnnotationsStreamPart.name]: messageAnnotationsStreamPart.code,
203
- [toolCallStreamPart.name]: toolCallStreamPart.code,
204
- [toolResultStreamPart.name]: toolResultStreamPart.code
205
- };
206
- var validCodes = streamParts.map((part) => part.code);
207
- var parseStreamPart = (line) => {
208
- const firstSeparatorIndex = line.indexOf(":");
209
- if (firstSeparatorIndex === -1) {
210
- throw new Error("Failed to parse stream string. No separator found.");
211
- }
212
- const prefix = line.slice(0, firstSeparatorIndex);
213
- if (!validCodes.includes(prefix)) {
214
- throw new Error(`Failed to parse stream string. Invalid code ${prefix}.`);
215
- }
216
- const code = prefix;
217
- const textValue = line.slice(firstSeparatorIndex + 1);
218
- const jsonValue = JSON.parse(textValue);
219
- return streamPartsByCode[code].parse(jsonValue);
220
- };
221
-
222
- // shared/read-data-stream.ts
223
- var NEWLINE = "\n".charCodeAt(0);
224
- function concatChunks(chunks, totalLength) {
225
- const concatenatedChunks = new Uint8Array(totalLength);
226
- let offset = 0;
227
- for (const chunk of chunks) {
228
- concatenatedChunks.set(chunk, offset);
229
- offset += chunk.length;
230
- }
231
- chunks.length = 0;
232
- return concatenatedChunks;
233
- }
234
- async function* readDataStream(reader, {
235
- isAborted
236
- } = {}) {
237
- const decoder = new TextDecoder();
238
- const chunks = [];
239
- let totalLength = 0;
240
- while (true) {
241
- const { value } = await reader.read();
242
- if (value) {
243
- chunks.push(value);
244
- totalLength += value.length;
245
- if (value[value.length - 1] !== NEWLINE) {
246
- continue;
247
- }
248
- }
249
- if (chunks.length === 0) {
250
- break;
251
- }
252
- const concatenatedChunks = concatChunks(chunks, totalLength);
253
- totalLength = 0;
254
- const streamParts2 = decoder.decode(concatenatedChunks, { stream: true }).split("\n").filter((line) => line !== "").map(parseStreamPart);
255
- for (const streamPart of streamParts2) {
256
- yield streamPart;
257
- }
258
- if (isAborted == null ? void 0 : isAborted()) {
259
- reader.cancel();
260
- break;
261
- }
262
- }
263
- }
264
-
265
- // shared/parse-complex-response.ts
266
- function assignAnnotationsToMessage(message, annotations) {
267
- if (!message || !annotations || !annotations.length)
268
- return message;
269
- return { ...message, annotations: [...annotations] };
270
- }
271
- async function parseComplexResponse({
272
- reader,
273
- abortControllerRef,
274
- update,
275
- onFinish,
276
- generateId: generateId2 = generateId,
277
- getCurrentDate = () => /* @__PURE__ */ new Date()
278
- }) {
279
- const createdAt = getCurrentDate();
280
- const prefixMap = {
281
- data: []
282
- };
283
- let message_annotations = void 0;
284
- for await (const { type, value } of readDataStream(reader, {
285
- isAborted: () => (abortControllerRef == null ? void 0 : abortControllerRef.current) === null
286
- })) {
287
- if (type === "text") {
288
- if (prefixMap["text"]) {
289
- prefixMap["text"] = {
290
- ...prefixMap["text"],
291
- content: (prefixMap["text"].content || "") + value
292
- };
293
- } else {
294
- prefixMap["text"] = {
295
- id: generateId2(),
296
- role: "assistant",
297
- content: value,
298
- createdAt
299
- };
300
- }
301
- }
302
- if (type === "tool_call") {
303
- if (prefixMap.text == null) {
304
- prefixMap.text = {
305
- id: generateId2(),
306
- role: "assistant",
307
- content: "",
308
- createdAt
309
- };
310
- }
311
- if (prefixMap.text.toolInvocations == null) {
312
- prefixMap.text.toolInvocations = [];
313
- }
314
- prefixMap.text.toolInvocations.push(value);
315
- } else if (type === "tool_result") {
316
- if (prefixMap.text == null) {
317
- prefixMap.text = {
318
- id: generateId2(),
319
- role: "assistant",
320
- content: "",
321
- createdAt
322
- };
323
- }
324
- if (prefixMap.text.toolInvocations == null) {
325
- prefixMap.text.toolInvocations = [];
326
- }
327
- const toolInvocationIndex = prefixMap.text.toolInvocations.findIndex(
328
- (invocation) => invocation.toolCallId === value.toolCallId
329
- );
330
- if (toolInvocationIndex !== -1) {
331
- prefixMap.text.toolInvocations[toolInvocationIndex] = value;
332
- } else {
333
- prefixMap.text.toolInvocations.push(value);
334
- }
335
- }
336
- let functionCallMessage = null;
337
- if (type === "function_call") {
338
- prefixMap["function_call"] = {
339
- id: generateId2(),
340
- role: "assistant",
341
- content: "",
342
- function_call: value.function_call,
343
- name: value.function_call.name,
344
- createdAt
345
- };
346
- functionCallMessage = prefixMap["function_call"];
347
- }
348
- let toolCallMessage = null;
349
- if (type === "tool_calls") {
350
- prefixMap["tool_calls"] = {
351
- id: generateId2(),
352
- role: "assistant",
353
- content: "",
354
- tool_calls: value.tool_calls,
355
- createdAt
356
- };
357
- toolCallMessage = prefixMap["tool_calls"];
358
- }
359
- if (type === "data") {
360
- prefixMap["data"].push(...value);
361
- }
362
- let responseMessage = prefixMap["text"];
363
- if (type === "message_annotations") {
364
- if (!message_annotations) {
365
- message_annotations = [...value];
366
- } else {
367
- message_annotations.push(...value);
368
- }
369
- functionCallMessage = assignAnnotationsToMessage(
370
- prefixMap["function_call"],
371
- message_annotations
372
- );
373
- toolCallMessage = assignAnnotationsToMessage(
374
- prefixMap["tool_calls"],
375
- message_annotations
376
- );
377
- responseMessage = assignAnnotationsToMessage(
378
- prefixMap["text"],
379
- message_annotations
380
- );
381
- }
382
- if (message_annotations == null ? void 0 : message_annotations.length) {
383
- const messagePrefixKeys = [
384
- "text",
385
- "function_call",
386
- "tool_calls"
387
- ];
388
- messagePrefixKeys.forEach((key) => {
389
- if (prefixMap[key]) {
390
- prefixMap[key].annotations = [...message_annotations];
391
- }
392
- });
393
- }
394
- const merged = [functionCallMessage, toolCallMessage, responseMessage].filter(Boolean).map((message) => ({
395
- ...assignAnnotationsToMessage(message, message_annotations)
396
- }));
397
- update(merged, [...prefixMap["data"]]);
398
- }
399
- onFinish == null ? void 0 : onFinish(prefixMap);
400
- return {
401
- messages: [
402
- prefixMap.text,
403
- prefixMap.function_call,
404
- prefixMap.tool_calls
405
- ].filter(Boolean),
406
- data: prefixMap.data
407
- };
408
- }
409
-
410
- // shared/utils.ts
411
- function createChunkDecoder(complex) {
412
- const decoder = new TextDecoder();
413
- if (!complex) {
414
- return function(chunk) {
415
- if (!chunk)
416
- return "";
417
- return decoder.decode(chunk, { stream: true });
418
- };
419
- }
420
- return function(chunk) {
421
- const decoded = decoder.decode(chunk, { stream: true }).split("\n").filter((line) => line !== "");
422
- return decoded.map(parseStreamPart).filter(Boolean);
423
- };
424
- }
425
-
426
- // shared/call-chat-api.ts
427
- async function callChatApi({
428
- api,
429
- messages,
430
- body,
431
- streamMode = "stream-data",
432
- credentials,
433
- headers,
434
- abortController,
435
- restoreMessagesOnFailure,
436
- onResponse,
437
- onUpdate,
438
- onFinish,
439
- generateId: generateId2
440
- }) {
441
- var _a;
442
- const response = await fetch(api, {
443
- method: "POST",
444
- body: JSON.stringify({
445
- messages,
446
- ...body
447
- }),
448
- headers: {
449
- "Content-Type": "application/json",
450
- ...headers
451
- },
452
- signal: (_a = abortController == null ? void 0 : abortController()) == null ? void 0 : _a.signal,
453
- credentials
454
- }).catch((err) => {
455
- restoreMessagesOnFailure();
456
- throw err;
457
- });
458
- if (onResponse) {
459
- try {
460
- await onResponse(response);
461
- } catch (err) {
462
- throw err;
463
- }
464
- }
465
- if (!response.ok) {
466
- restoreMessagesOnFailure();
467
- throw new Error(
468
- await response.text() || "Failed to fetch the chat response."
469
- );
470
- }
471
- if (!response.body) {
472
- throw new Error("The response body is empty.");
473
- }
474
- const reader = response.body.getReader();
475
- switch (streamMode) {
476
- case "text": {
477
- const decoder = createChunkDecoder();
478
- const resultMessage = {
479
- id: generateId2(),
480
- createdAt: /* @__PURE__ */ new Date(),
481
- role: "assistant",
482
- content: ""
483
- };
484
- while (true) {
485
- const { done, value } = await reader.read();
486
- if (done) {
487
- break;
488
- }
489
- resultMessage.content += decoder(value);
490
- resultMessage.id = generateId2();
491
- onUpdate([{ ...resultMessage }], []);
492
- if ((abortController == null ? void 0 : abortController()) === null) {
493
- reader.cancel();
494
- break;
495
- }
496
- }
497
- onFinish == null ? void 0 : onFinish(resultMessage);
498
- return {
499
- messages: [resultMessage],
500
- data: []
501
- };
502
- }
503
- case "stream-data": {
504
- return await parseComplexResponse({
505
- reader,
506
- abortControllerRef: abortController != null ? { current: abortController() } : void 0,
507
- update: onUpdate,
508
- onFinish(prefixMap) {
509
- if (onFinish && prefixMap.text != null) {
510
- onFinish(prefixMap.text);
511
- }
512
- },
513
- generateId: generateId2
514
- });
515
- }
516
- default: {
517
- const exhaustiveCheck = streamMode;
518
- throw new Error(`Unknown stream mode: ${exhaustiveCheck}`);
519
- }
520
- }
521
- }
522
-
523
- // shared/process-chat-stream.ts
524
- async function processChatStream({
525
- getStreamedResponse: getStreamedResponse2,
526
- experimental_onFunctionCall,
527
- experimental_onToolCall,
528
- updateChatRequest,
529
- getCurrentMessages
530
- }) {
531
- while (true) {
532
- const messagesAndDataOrJustMessage = await getStreamedResponse2();
533
- if ("messages" in messagesAndDataOrJustMessage) {
534
- let hasFollowingResponse = false;
535
- for (const message of messagesAndDataOrJustMessage.messages) {
536
- if ((message.function_call === void 0 || typeof message.function_call === "string") && (message.tool_calls === void 0 || typeof message.tool_calls === "string")) {
537
- continue;
538
- }
539
- hasFollowingResponse = true;
540
- if (experimental_onFunctionCall) {
541
- const functionCall = message.function_call;
542
- if (typeof functionCall !== "object") {
543
- console.warn(
544
- "experimental_onFunctionCall should not be defined when using tools"
545
- );
546
- continue;
547
- }
548
- const functionCallResponse = await experimental_onFunctionCall(
549
- getCurrentMessages(),
550
- functionCall
551
- );
552
- if (functionCallResponse === void 0) {
553
- hasFollowingResponse = false;
554
- break;
555
- }
556
- updateChatRequest(functionCallResponse);
557
- }
558
- if (experimental_onToolCall) {
559
- const toolCalls = message.tool_calls;
560
- if (!Array.isArray(toolCalls) || toolCalls.some((toolCall) => typeof toolCall !== "object")) {
561
- console.warn(
562
- "experimental_onToolCall should not be defined when using tools"
563
- );
564
- continue;
565
- }
566
- const toolCallResponse = await experimental_onToolCall(getCurrentMessages(), toolCalls);
567
- if (toolCallResponse === void 0) {
568
- hasFollowingResponse = false;
569
- break;
570
- }
571
- updateChatRequest(toolCallResponse);
572
- }
573
- }
574
- if (!hasFollowingResponse) {
575
- break;
576
- }
577
- } else {
578
- let fixFunctionCallArguments2 = function(response) {
579
- for (const message of response.messages) {
580
- if (message.tool_calls !== void 0) {
581
- for (const toolCall of message.tool_calls) {
582
- if (typeof toolCall === "object") {
583
- if (toolCall.function.arguments && typeof toolCall.function.arguments !== "string") {
584
- toolCall.function.arguments = JSON.stringify(
585
- toolCall.function.arguments
586
- );
587
- }
588
- }
589
- }
590
- }
591
- if (message.function_call !== void 0) {
592
- if (typeof message.function_call === "object") {
593
- if (message.function_call.arguments && typeof message.function_call.arguments !== "string") {
594
- message.function_call.arguments = JSON.stringify(
595
- message.function_call.arguments
596
- );
597
- }
598
- }
599
- }
600
- }
601
- };
602
- var fixFunctionCallArguments = fixFunctionCallArguments2;
603
- const streamedResponseMessage = messagesAndDataOrJustMessage;
604
- if ((streamedResponseMessage.function_call === void 0 || typeof streamedResponseMessage.function_call === "string") && (streamedResponseMessage.tool_calls === void 0 || typeof streamedResponseMessage.tool_calls === "string")) {
605
- break;
606
- }
607
- if (experimental_onFunctionCall) {
608
- const functionCall = streamedResponseMessage.function_call;
609
- if (!(typeof functionCall === "object")) {
610
- console.warn(
611
- "experimental_onFunctionCall should not be defined when using tools"
612
- );
613
- continue;
614
- }
615
- const functionCallResponse = await experimental_onFunctionCall(getCurrentMessages(), functionCall);
616
- if (functionCallResponse === void 0)
617
- break;
618
- fixFunctionCallArguments2(functionCallResponse);
619
- updateChatRequest(functionCallResponse);
620
- }
621
- if (experimental_onToolCall) {
622
- const toolCalls = streamedResponseMessage.tool_calls;
623
- if (!(typeof toolCalls === "object")) {
624
- console.warn(
625
- "experimental_onToolCall should not be defined when using functions"
626
- );
627
- continue;
628
- }
629
- const toolCallResponse = await experimental_onToolCall(getCurrentMessages(), toolCalls);
630
- if (toolCallResponse === void 0)
631
- break;
632
- fixFunctionCallArguments2(toolCallResponse);
633
- updateChatRequest(toolCallResponse);
634
- }
635
- }
636
- }
637
- }
638
-
639
- // react/use-chat.ts
640
- var getStreamedResponse = async (api, chatRequest, mutate, mutateStreamData, existingData, extraMetadataRef, messagesRef, abortControllerRef, generateId2, streamMode, onFinish, onResponse, sendExtraMessageFields) => {
641
- var _a, _b;
642
- const previousMessages = messagesRef.current;
643
- mutate(chatRequest.messages, false);
644
- const constructedMessagesPayload = sendExtraMessageFields ? chatRequest.messages : chatRequest.messages.map(
645
- ({
646
- role,
647
- content,
648
- name,
649
- toolInvocations,
650
- function_call,
651
- tool_calls,
652
- tool_call_id
653
- }) => ({
654
- role,
655
- content,
656
- ...name !== void 0 && { name },
657
- ...toolInvocations !== void 0 && { toolInvocations },
658
- // outdated function/tool call handling (TODO deprecate):
659
- tool_call_id,
660
- ...function_call !== void 0 && { function_call },
661
- ...tool_calls !== void 0 && { tool_calls }
662
- })
663
- );
664
- if (typeof api !== "string") {
665
- const replyId = generateId2();
666
- const createdAt = /* @__PURE__ */ new Date();
667
- let responseMessage = {
668
- id: replyId,
669
- createdAt,
670
- content: "",
671
- role: "assistant"
672
- };
673
- async function readRow(promise) {
674
- const { content, ui, next } = await promise;
675
- responseMessage["content"] = content;
676
- responseMessage["ui"] = await ui;
677
- mutate([...chatRequest.messages, { ...responseMessage }], false);
678
- if (next) {
679
- await readRow(next);
680
- }
681
- }
682
- try {
683
- const promise = api({
684
- messages: constructedMessagesPayload,
685
- data: chatRequest.data
686
- });
687
- await readRow(promise);
688
- } catch (e) {
689
- mutate(previousMessages, false);
690
- throw e;
691
- }
692
- if (onFinish) {
693
- onFinish(responseMessage);
694
- }
695
- return responseMessage;
696
- }
697
- return await callChatApi({
698
- api,
699
- messages: constructedMessagesPayload,
700
- body: {
701
- data: chatRequest.data,
702
- ...extraMetadataRef.current.body,
703
- ...(_a = chatRequest.options) == null ? void 0 : _a.body,
704
- ...chatRequest.functions !== void 0 && {
705
- functions: chatRequest.functions
706
- },
707
- ...chatRequest.function_call !== void 0 && {
708
- function_call: chatRequest.function_call
709
- },
710
- ...chatRequest.tools !== void 0 && {
711
- tools: chatRequest.tools
712
- },
713
- ...chatRequest.tool_choice !== void 0 && {
714
- tool_choice: chatRequest.tool_choice
715
- }
716
- },
717
- streamMode,
718
- credentials: extraMetadataRef.current.credentials,
719
- headers: {
720
- ...extraMetadataRef.current.headers,
721
- ...(_b = chatRequest.options) == null ? void 0 : _b.headers
722
- },
723
- abortController: () => abortControllerRef.current,
724
- restoreMessagesOnFailure() {
725
- mutate(previousMessages, false);
726
- },
727
- onResponse,
728
- onUpdate(merged, data) {
729
- mutate([...chatRequest.messages, ...merged], false);
730
- mutateStreamData([...existingData || [], ...data || []], false);
731
- },
732
- onFinish,
733
- generateId: generateId2
734
- });
735
- };
736
- function useChat({
737
- api = "/api/chat",
738
- id,
739
- initialMessages,
740
- initialInput = "",
741
- sendExtraMessageFields,
742
- experimental_onFunctionCall,
743
- experimental_onToolCall,
744
- streamMode,
745
- onResponse,
746
- onFinish,
747
- onError,
748
- credentials,
749
- headers,
750
- body,
751
- generateId: generateId2 = generateId
752
- } = {}) {
753
- const hookId = useId();
754
- const idKey = id != null ? id : hookId;
755
- const chatKey = typeof api === "string" ? [api, idKey] : idKey;
756
- const [initialMessagesFallback] = useState([]);
757
- const { data: messages, mutate } = useSWR(
758
- [chatKey, "messages"],
759
- null,
760
- { fallbackData: initialMessages != null ? initialMessages : initialMessagesFallback }
761
- );
762
- const { data: isLoading = false, mutate: mutateLoading } = useSWR(
763
- [chatKey, "loading"],
764
- null
765
- );
766
- const { data: streamData, mutate: mutateStreamData } = useSWR([chatKey, "streamData"], null);
767
- const { data: error = void 0, mutate: setError } = useSWR([chatKey, "error"], null);
768
- const messagesRef = useRef(messages || []);
769
- useEffect(() => {
770
- messagesRef.current = messages || [];
771
- }, [messages]);
772
- const abortControllerRef = useRef(null);
773
- const extraMetadataRef = useRef({
774
- credentials,
775
- headers,
776
- body
777
- });
778
- useEffect(() => {
779
- extraMetadataRef.current = {
780
- credentials,
781
- headers,
782
- body
783
- };
784
- }, [credentials, headers, body]);
785
- const triggerRequest = useCallback(
786
- async (chatRequest) => {
787
- try {
788
- mutateLoading(true);
789
- setError(void 0);
790
- const abortController = new AbortController();
791
- abortControllerRef.current = abortController;
792
- await processChatStream({
793
- getStreamedResponse: () => getStreamedResponse(
794
- api,
795
- chatRequest,
796
- mutate,
797
- mutateStreamData,
798
- streamData,
799
- extraMetadataRef,
800
- messagesRef,
801
- abortControllerRef,
802
- generateId2,
803
- streamMode,
804
- onFinish,
805
- onResponse,
806
- sendExtraMessageFields
807
- ),
808
- experimental_onFunctionCall,
809
- experimental_onToolCall,
810
- updateChatRequest: (chatRequestParam) => {
811
- chatRequest = chatRequestParam;
812
- },
813
- getCurrentMessages: () => messagesRef.current
814
- });
815
- abortControllerRef.current = null;
816
- } catch (err) {
817
- if (err.name === "AbortError") {
818
- abortControllerRef.current = null;
819
- return null;
820
- }
821
- if (onError && err instanceof Error) {
822
- onError(err);
823
- }
824
- setError(err);
825
- } finally {
826
- mutateLoading(false);
827
- }
828
- },
829
- [
830
- mutate,
831
- mutateLoading,
832
- api,
833
- extraMetadataRef,
834
- onResponse,
835
- onFinish,
836
- onError,
837
- setError,
838
- mutateStreamData,
839
- streamData,
840
- streamMode,
841
- sendExtraMessageFields,
842
- experimental_onFunctionCall,
843
- experimental_onToolCall,
844
- messagesRef,
845
- abortControllerRef,
846
- generateId2
847
- ]
848
- );
849
- const append = useCallback(
850
- async (message, {
851
- options,
852
- functions,
853
- function_call,
854
- tools,
855
- tool_choice,
856
- data
857
- } = {}) => {
858
- if (!message.id) {
859
- message.id = generateId2();
860
- }
861
- const chatRequest = {
862
- messages: messagesRef.current.concat(message),
863
- options,
864
- data,
865
- ...functions !== void 0 && { functions },
866
- ...function_call !== void 0 && { function_call },
867
- ...tools !== void 0 && { tools },
868
- ...tool_choice !== void 0 && { tool_choice }
869
- };
870
- return triggerRequest(chatRequest);
871
- },
872
- [triggerRequest, generateId2]
873
- );
874
- const reload = useCallback(
875
- async ({
876
- options,
877
- functions,
878
- function_call,
879
- tools,
880
- tool_choice
881
- } = {}) => {
882
- if (messagesRef.current.length === 0)
883
- return null;
884
- const lastMessage = messagesRef.current[messagesRef.current.length - 1];
885
- if (lastMessage.role === "assistant") {
886
- const chatRequest2 = {
887
- messages: messagesRef.current.slice(0, -1),
888
- options,
889
- ...functions !== void 0 && { functions },
890
- ...function_call !== void 0 && { function_call },
891
- ...tools !== void 0 && { tools },
892
- ...tool_choice !== void 0 && { tool_choice }
893
- };
894
- return triggerRequest(chatRequest2);
895
- }
896
- const chatRequest = {
897
- messages: messagesRef.current,
898
- options,
899
- ...functions !== void 0 && { functions },
900
- ...function_call !== void 0 && { function_call },
901
- ...tools !== void 0 && { tools },
902
- ...tool_choice !== void 0 && { tool_choice }
903
- };
904
- return triggerRequest(chatRequest);
905
- },
906
- [triggerRequest]
907
- );
908
- const stop = useCallback(() => {
909
- if (abortControllerRef.current) {
910
- abortControllerRef.current.abort();
911
- abortControllerRef.current = null;
912
- }
913
- }, []);
914
- const setMessages = useCallback(
915
- (messages2) => {
916
- mutate(messages2, false);
917
- messagesRef.current = messages2;
918
- },
919
- [mutate]
920
- );
921
- const [input, setInput] = useState(initialInput);
922
- const handleSubmit = useCallback(
923
- (e, options = {}, metadata) => {
924
- if (metadata) {
925
- extraMetadataRef.current = {
926
- ...extraMetadataRef.current,
927
- ...metadata
928
- };
929
- }
930
- e.preventDefault();
931
- if (!input)
932
- return;
933
- append(
934
- {
935
- content: input,
936
- role: "user",
937
- createdAt: /* @__PURE__ */ new Date()
938
- },
939
- options
940
- );
941
- setInput("");
942
- },
943
- [input, append]
944
- );
945
- const handleInputChange = (e) => {
946
- setInput(e.target.value);
947
- };
948
- return {
949
- messages: messages || [],
950
- error,
951
- append,
952
- reload,
953
- stop,
954
- setMessages,
955
- input,
956
- setInput,
957
- handleInputChange,
958
- handleSubmit,
959
- isLoading,
960
- data: streamData,
961
- experimental_addToolResult: ({
962
- toolCallId,
963
- result
964
- }) => {
965
- const updatedMessages = messagesRef.current.map(
966
- (message, index, arr) => (
967
- // update the tool calls in the last assistant message:
968
- index === arr.length - 1 && message.role === "assistant" && message.toolInvocations ? {
969
- ...message,
970
- toolInvocations: message.toolInvocations.map(
971
- (toolInvocation) => toolInvocation.toolCallId === toolCallId ? { ...toolInvocation, result } : toolInvocation
972
- )
973
- } : message
974
- )
975
- );
976
- mutate(updatedMessages, false);
977
- const lastMessage = updatedMessages[updatedMessages.length - 1];
978
- if (lastMessage.role === "assistant" && lastMessage.toolInvocations && lastMessage.toolInvocations.length > 0 && lastMessage.toolInvocations.every(
979
- (toolInvocation) => "result" in toolInvocation
980
- )) {
981
- triggerRequest({ messages: updatedMessages });
982
- }
983
- }
984
- };
985
- }
986
-
987
- // react/use-completion.ts
988
- import { useCallback as useCallback2, useEffect as useEffect2, useId as useId2, useRef as useRef2, useState as useState2 } from "react";
989
- import useSWR2 from "swr";
990
-
991
- // shared/call-completion-api.ts
992
- async function callCompletionApi({
993
- api,
994
- prompt,
995
- credentials,
996
- headers,
997
- body,
998
- streamMode = "stream-data",
999
- setCompletion,
1000
- setLoading,
1001
- setError,
1002
- setAbortController,
1003
- onResponse,
1004
- onFinish,
1005
- onError,
1006
- onData
1007
- }) {
1008
- try {
1009
- setLoading(true);
1010
- setError(void 0);
1011
- const abortController = new AbortController();
1012
- setAbortController(abortController);
1013
- setCompletion("");
1014
- const res = await fetch(api, {
1015
- method: "POST",
1016
- body: JSON.stringify({
1017
- prompt,
1018
- ...body
1019
- }),
1020
- credentials,
1021
- headers: {
1022
- "Content-Type": "application/json",
1023
- ...headers
1024
- },
1025
- signal: abortController.signal
1026
- }).catch((err) => {
1027
- throw err;
1028
- });
1029
- if (onResponse) {
1030
- try {
1031
- await onResponse(res);
1032
- } catch (err) {
1033
- throw err;
1034
- }
1035
- }
1036
- if (!res.ok) {
1037
- throw new Error(
1038
- await res.text() || "Failed to fetch the chat response."
1039
- );
1040
- }
1041
- if (!res.body) {
1042
- throw new Error("The response body is empty.");
1043
- }
1044
- let result = "";
1045
- const reader = res.body.getReader();
1046
- switch (streamMode) {
1047
- case "text": {
1048
- const decoder = createChunkDecoder();
1049
- while (true) {
1050
- const { done, value } = await reader.read();
1051
- if (done) {
1052
- break;
1053
- }
1054
- result += decoder(value);
1055
- setCompletion(result);
1056
- if (abortController === null) {
1057
- reader.cancel();
1058
- break;
1059
- }
1060
- }
1061
- break;
1062
- }
1063
- case "stream-data": {
1064
- for await (const { type, value } of readDataStream(reader, {
1065
- isAborted: () => abortController === null
1066
- })) {
1067
- switch (type) {
1068
- case "text": {
1069
- result += value;
1070
- setCompletion(result);
1071
- break;
1072
- }
1073
- case "data": {
1074
- onData == null ? void 0 : onData(value);
1075
- break;
1076
- }
1077
- }
1078
- }
1079
- break;
1080
- }
1081
- default: {
1082
- const exhaustiveCheck = streamMode;
1083
- throw new Error(`Unknown stream mode: ${exhaustiveCheck}`);
1084
- }
1085
- }
1086
- if (onFinish) {
1087
- onFinish(prompt, result);
1088
- }
1089
- setAbortController(null);
1090
- return result;
1091
- } catch (err) {
1092
- if (err.name === "AbortError") {
1093
- setAbortController(null);
1094
- return null;
1095
- }
1096
- if (err instanceof Error) {
1097
- if (onError) {
1098
- onError(err);
1099
- }
1100
- }
1101
- setError(err);
1102
- } finally {
1103
- setLoading(false);
1104
- }
1105
- }
1106
-
1107
- // react/use-completion.ts
1108
- function useCompletion({
1109
- api = "/api/completion",
1110
- id,
1111
- initialCompletion = "",
1112
- initialInput = "",
1113
- credentials,
1114
- headers,
1115
- body,
1116
- streamMode,
1117
- onResponse,
1118
- onFinish,
1119
- onError
1120
- } = {}) {
1121
- const hookId = useId2();
1122
- const completionId = id || hookId;
1123
- const { data, mutate } = useSWR2([api, completionId], null, {
1124
- fallbackData: initialCompletion
1125
- });
1126
- const { data: isLoading = false, mutate: mutateLoading } = useSWR2(
1127
- [completionId, "loading"],
1128
- null
1129
- );
1130
- const { data: streamData, mutate: mutateStreamData } = useSWR2([completionId, "streamData"], null);
1131
- const [error, setError] = useState2(void 0);
1132
- const completion = data;
1133
- const [abortController, setAbortController] = useState2(null);
1134
- const extraMetadataRef = useRef2({
1135
- credentials,
1136
- headers,
1137
- body
1138
- });
1139
- useEffect2(() => {
1140
- extraMetadataRef.current = {
1141
- credentials,
1142
- headers,
1143
- body
1144
- };
1145
- }, [credentials, headers, body]);
1146
- const triggerRequest = useCallback2(
1147
- async (prompt, options) => callCompletionApi({
1148
- api,
1149
- prompt,
1150
- credentials: extraMetadataRef.current.credentials,
1151
- headers: { ...extraMetadataRef.current.headers, ...options == null ? void 0 : options.headers },
1152
- body: {
1153
- ...extraMetadataRef.current.body,
1154
- ...options == null ? void 0 : options.body
1155
- },
1156
- streamMode,
1157
- setCompletion: (completion2) => mutate(completion2, false),
1158
- setLoading: mutateLoading,
1159
- setError,
1160
- setAbortController,
1161
- onResponse,
1162
- onFinish,
1163
- onError,
1164
- onData: (data2) => {
1165
- mutateStreamData([...streamData || [], ...data2 || []], false);
1166
- }
1167
- }),
1168
- [
1169
- mutate,
1170
- mutateLoading,
1171
- api,
1172
- extraMetadataRef,
1173
- setAbortController,
1174
- onResponse,
1175
- onFinish,
1176
- onError,
1177
- setError,
1178
- streamData,
1179
- streamMode,
1180
- mutateStreamData
1181
- ]
1182
- );
1183
- const stop = useCallback2(() => {
1184
- if (abortController) {
1185
- abortController.abort();
1186
- setAbortController(null);
1187
- }
1188
- }, [abortController]);
1189
- const setCompletion = useCallback2(
1190
- (completion2) => {
1191
- mutate(completion2, false);
1192
- },
1193
- [mutate]
1194
- );
1195
- const complete = useCallback2(
1196
- async (prompt, options) => {
1197
- return triggerRequest(prompt, options);
1198
- },
1199
- [triggerRequest]
1200
- );
1201
- const [input, setInput] = useState2(initialInput);
1202
- const handleSubmit = useCallback2(
1203
- (e) => {
1204
- e.preventDefault();
1205
- if (!input)
1206
- return;
1207
- return complete(input);
1208
- },
1209
- [input, complete]
1210
- );
1211
- const handleInputChange = (e) => {
1212
- setInput(e.target.value);
1213
- };
1214
- return {
1215
- completion,
1216
- complete,
1217
- error,
1218
- setCompletion,
1219
- stop,
1220
- input,
1221
- setInput,
1222
- handleInputChange,
1223
- handleSubmit,
1224
- isLoading,
1225
- data: streamData
1226
- };
1227
- }
1228
-
1229
- // react/use-assistant.ts
1230
- import { isAbortError } from "@ai-sdk/provider-utils";
1231
- import { useCallback as useCallback3, useRef as useRef3, useState as useState3 } from "react";
1232
- function useAssistant({
1233
- api,
1234
- threadId: threadIdParam,
1235
- credentials,
1236
- headers,
1237
- body,
1238
- onError
1239
- }) {
1240
- const [messages, setMessages] = useState3([]);
1241
- const [input, setInput] = useState3("");
1242
- const [threadId, setThreadId] = useState3(void 0);
1243
- const [status, setStatus] = useState3("awaiting_message");
1244
- const [error, setError] = useState3(void 0);
1245
- const handleInputChange = (event) => {
1246
- setInput(event.target.value);
1247
- };
1248
- const abortControllerRef = useRef3(null);
1249
- const stop = useCallback3(() => {
1250
- if (abortControllerRef.current) {
1251
- abortControllerRef.current.abort();
1252
- abortControllerRef.current = null;
1253
- }
1254
- }, []);
1255
- const append = async (message, requestOptions) => {
1256
- var _a;
1257
- setStatus("in_progress");
1258
- setMessages((messages2) => {
1259
- var _a2;
1260
- return [
1261
- ...messages2,
1262
- {
1263
- ...message,
1264
- id: (_a2 = message.id) != null ? _a2 : generateId()
1265
- }
1266
- ];
1267
- });
1268
- setInput("");
1269
- const abortController = new AbortController();
1270
- try {
1271
- abortControllerRef.current = abortController;
1272
- const result = await fetch(api, {
1273
- method: "POST",
1274
- credentials,
1275
- signal: abortController.signal,
1276
- headers: { "Content-Type": "application/json", ...headers },
1277
- body: JSON.stringify({
1278
- ...body,
1279
- // always use user-provided threadId when available:
1280
- threadId: (_a = threadIdParam != null ? threadIdParam : threadId) != null ? _a : null,
1281
- message: message.content,
1282
- // optional request data:
1283
- data: requestOptions == null ? void 0 : requestOptions.data
1284
- })
1285
- });
1286
- if (result.body == null) {
1287
- throw new Error("The response body is empty.");
1288
- }
1289
- for await (const { type, value } of readDataStream(
1290
- result.body.getReader()
1291
- )) {
1292
- switch (type) {
1293
- case "assistant_message": {
1294
- setMessages((messages2) => [
1295
- ...messages2,
1296
- {
1297
- id: value.id,
1298
- role: value.role,
1299
- content: value.content[0].text.value
1300
- }
1301
- ]);
1302
- break;
1303
- }
1304
- case "text": {
1305
- setMessages((messages2) => {
1306
- const lastMessage = messages2[messages2.length - 1];
1307
- return [
1308
- ...messages2.slice(0, messages2.length - 1),
1309
- {
1310
- id: lastMessage.id,
1311
- role: lastMessage.role,
1312
- content: lastMessage.content + value
1313
- }
1314
- ];
1315
- });
1316
- break;
1317
- }
1318
- case "data_message": {
1319
- setMessages((messages2) => {
1320
- var _a2;
1321
- return [
1322
- ...messages2,
1323
- {
1324
- id: (_a2 = value.id) != null ? _a2 : generateId(),
1325
- role: "data",
1326
- content: "",
1327
- data: value.data
1328
- }
1329
- ];
1330
- });
1331
- break;
1332
- }
1333
- case "assistant_control_data": {
1334
- setThreadId(value.threadId);
1335
- setMessages((messages2) => {
1336
- const lastMessage = messages2[messages2.length - 1];
1337
- lastMessage.id = value.messageId;
1338
- return [...messages2.slice(0, messages2.length - 1), lastMessage];
1339
- });
1340
- break;
1341
- }
1342
- case "error": {
1343
- setError(new Error(value));
1344
- break;
1345
- }
1346
- }
1347
- }
1348
- } catch (error2) {
1349
- if (isAbortError(error2) && abortController.signal.aborted) {
1350
- abortControllerRef.current = null;
1351
- return;
1352
- }
1353
- if (onError && error2 instanceof Error) {
1354
- onError(error2);
1355
- }
1356
- setError(error2);
1357
- } finally {
1358
- abortControllerRef.current = null;
1359
- setStatus("awaiting_message");
1360
- }
1361
- };
1362
- const submitMessage = async (event, requestOptions) => {
1363
- var _a;
1364
- (_a = event == null ? void 0 : event.preventDefault) == null ? void 0 : _a.call(event);
1365
- if (input === "") {
1366
- return;
1367
- }
1368
- append({ role: "user", content: input }, requestOptions);
1369
- };
1370
- return {
1371
- append,
1372
- messages,
1373
- setMessages,
1374
- threadId,
1375
- input,
1376
- setInput,
1377
- handleInputChange,
1378
- submitMessage,
1379
- status,
1380
- error,
1381
- stop
1382
- };
1383
- }
1384
- var experimental_useAssistant = useAssistant;
3
+ // react/index.ts
4
+ import {
5
+ useChat as useChatReact,
6
+ useCompletion as useCompletionReact,
7
+ experimental_useObject as experimental_useObjectReact
8
+ } from "@ai-sdk/react";
9
+ var useChat = useChatReact;
10
+ var useCompletion = useCompletionReact;
11
+ var experimental_useObject = experimental_useObjectReact;
1385
12
  export {
1386
- experimental_useAssistant,
1387
- useAssistant,
13
+ experimental_useObject,
1388
14
  useChat,
1389
15
  useCompletion
1390
16
  };