ai 3.1.8 → 3.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "3.1.8",
3
+ "version": "3.1.10",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -74,12 +74,12 @@
74
74
  "devDependencies": {
75
75
  "@anthropic-ai/sdk": "0.18.0",
76
76
  "@aws-sdk/client-bedrock-runtime": "3.451.0",
77
- "@edge-runtime/vm": "^3.1.7",
77
+ "@edge-runtime/vm": "^3.2.0",
78
78
  "@google/generative-ai": "0.1.1",
79
79
  "@huggingface/inference": "2.6.4",
80
80
  "@mistralai/mistralai": "0.1.3",
81
81
  "@solidjs/testing-library": "0.8.4",
82
- "@testing-library/jest-dom": "^6.1.4",
82
+ "@testing-library/jest-dom": "^6.4.5",
83
83
  "@testing-library/react": "^14.0.0",
84
84
  "@testing-library/user-event": "^14.5.1",
85
85
  "@testing-library/vue": "^8.0.1",
@@ -91,10 +91,10 @@
91
91
  "@vitejs/plugin-vue": "4.5.0",
92
92
  "cohere-ai": "^7.6.2",
93
93
  "eslint": "^7.32.0",
94
- "jsdom": "^23.0.0",
94
+ "jsdom": "^24.0.0",
95
95
  "langchain": "0.0.196",
96
96
  "msw": "2.0.9",
97
- "openai": "4.42.0",
97
+ "openai": "4.47.1",
98
98
  "react-dom": "^18.2.0",
99
99
  "react-server-dom-webpack": "18.3.0-canary-eb33bd747-20240312",
100
100
  "solid-js": "^1.8.7",
@@ -162,15 +162,15 @@
162
162
  "type-check": "tsc --noEmit",
163
163
  "prettier-check": "prettier --check \"./**/*.ts*\"",
164
164
  "test": "pnpm test:node && pnpm test:edge && pnpm test:ui",
165
- "test:edge": "vitest --config vitest.edge.config.js --run --threads=false",
166
- "test:node": "vitest --config vitest.node.config.js --run --threads=false",
167
- "test:node:core": "pnpm vitest --config vitest.node.config.js --run --threads=false ./core/",
165
+ "test:edge": "vitest --config vitest.edge.config.js --run",
166
+ "test:node": "vitest --config vitest.node.config.js --run",
167
+ "test:node:core": "pnpm vitest --config vitest.node.config.js --run ./core/",
168
168
  "test:ui": "pnpm test:ui:react && pnpm test:ui:vue && pnpm test:ui:solid",
169
169
  "test:ui:react": "vitest --config vitest.ui.react.config.js --run",
170
170
  "test:ui:solid": "vitest --config vitest.ui.solid.config.js --run",
171
171
  "test:ui:vue": "vitest --config vitest.ui.vue.config.js --run",
172
- "test:edge:watch": "vitest --config vitest.edge.config.js --threads=false",
173
- "test:node:watch": "vitest --config vitest.node.config.js --threads=false",
172
+ "test:edge:watch": "vitest --config vitest.edge.config.js",
173
+ "test:node:watch": "vitest --config vitest.node.config.js",
174
174
  "test:ui:react:watch": "vitest --config vitest.ui.react.config.js",
175
175
  "test:ui:solid:watch": "vitest --config vitest.ui.solid.config.js",
176
176
  "test:ui:vue:watch": "vitest --config vitest.ui.vue.config.js"
@@ -40,6 +40,38 @@ interface ToolResult<NAME extends string, ARGS, RESULT> {
40
40
  result: RESULT;
41
41
  }
42
42
 
43
+ type AssistantStatus = 'in_progress' | 'awaiting_message';
44
+ type UseAssistantOptions = {
45
+ /**
46
+ * The API endpoint that accepts a `{ threadId: string | null; message: string; }` object and returns an `AssistantResponse` stream.
47
+ * The threadId refers to an existing thread with messages (or is `null` to create a new thread).
48
+ * The message is the next message that should be appended to the thread and sent to the assistant.
49
+ */
50
+ api: string;
51
+ /**
52
+ * An optional string that represents the ID of an existing thread.
53
+ * If not provided, a new thread will be created.
54
+ */
55
+ threadId?: string;
56
+ /**
57
+ * An optional literal that sets the mode of credentials to be used on the request.
58
+ * Defaults to "same-origin".
59
+ */
60
+ credentials?: RequestCredentials;
61
+ /**
62
+ * An optional object of headers to be passed to the API endpoint.
63
+ */
64
+ headers?: Record<string, string> | Headers;
65
+ /**
66
+ * An optional, additional body object to be passed to the API endpoint.
67
+ */
68
+ body?: object;
69
+ /**
70
+ * An optional callback that will be called when the assistant encounters an error.
71
+ */
72
+ onError?: (error: Error) => void;
73
+ };
74
+
43
75
  interface FunctionCall {
44
76
  /**
45
77
  * The arguments to call the function with, as generated by the model in JSON
@@ -474,14 +506,13 @@ type UseCompletionHelpers = {
474
506
  };
475
507
  declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamMode, onResponse, onFinish, onError, }?: UseCompletionOptions): UseCompletionHelpers;
476
508
 
477
- type AssistantStatus = 'in_progress' | 'awaiting_message';
478
509
  type UseAssistantHelpers = {
479
510
  /**
480
511
  * The current array of chat messages.
481
512
  */
482
513
  messages: Message[];
483
514
  /**
484
- * setState-powered method to update the messages array.
515
+ * Update the message store with a new array of messages.
485
516
  */
486
517
  setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
487
518
  /**
@@ -528,40 +559,10 @@ type UseAssistantHelpers = {
528
559
  */
529
560
  error: undefined | unknown;
530
561
  };
531
- type UseAssistantOptions = {
532
- /**
533
- * The API endpoint that accepts a `{ threadId: string | null; message: string; }` object and returns an `AssistantResponse` stream.
534
- * The threadId refers to an existing thread with messages (or is `null` to create a new thread).
535
- * The message is the next message that should be appended to the thread and sent to the assistant.
536
- */
537
- api: string;
538
- /**
539
- * An optional string that represents the ID of an existing thread.
540
- * If not provided, a new thread will be created.
541
- */
542
- threadId?: string;
543
- /**
544
- * An optional literal that sets the mode of credentials to be used on the request.
545
- * Defaults to "same-origin".
546
- */
547
- credentials?: RequestCredentials;
548
- /**
549
- * An optional object of headers to be passed to the API endpoint.
550
- */
551
- headers?: Record<string, string> | Headers;
552
- /**
553
- * An optional, additional body object to be passed to the API endpoint.
554
- */
555
- body?: object;
556
- /**
557
- * An optional callback that will be called when the assistant encounters an error.
558
- */
559
- onError?: (error: Error) => void;
560
- };
561
562
  declare function useAssistant({ api, threadId: threadIdParam, credentials, headers, body, onError, }: UseAssistantOptions): UseAssistantHelpers;
562
563
  /**
563
564
  @deprecated Use `useAssistant` instead.
564
565
  */
565
566
  declare const experimental_useAssistant: typeof useAssistant;
566
567
 
567
- export { AssistantStatus, CreateMessage, Message, UseAssistantHelpers, UseAssistantOptions, UseChatHelpers, UseChatOptions, UseCompletionHelpers, UseCompletionOptions, experimental_useAssistant, useAssistant, useChat, useCompletion };
568
+ export { CreateMessage, Message, UseAssistantHelpers, UseChatHelpers, UseChatOptions, UseCompletionHelpers, UseCompletionOptions, experimental_useAssistant, useAssistant, useChat, useCompletion };
@@ -40,6 +40,38 @@ interface ToolResult<NAME extends string, ARGS, RESULT> {
40
40
  result: RESULT;
41
41
  }
42
42
 
43
+ type AssistantStatus = 'in_progress' | 'awaiting_message';
44
+ type UseAssistantOptions = {
45
+ /**
46
+ * The API endpoint that accepts a `{ threadId: string | null; message: string; }` object and returns an `AssistantResponse` stream.
47
+ * The threadId refers to an existing thread with messages (or is `null` to create a new thread).
48
+ * The message is the next message that should be appended to the thread and sent to the assistant.
49
+ */
50
+ api: string;
51
+ /**
52
+ * An optional string that represents the ID of an existing thread.
53
+ * If not provided, a new thread will be created.
54
+ */
55
+ threadId?: string;
56
+ /**
57
+ * An optional literal that sets the mode of credentials to be used on the request.
58
+ * Defaults to "same-origin".
59
+ */
60
+ credentials?: RequestCredentials;
61
+ /**
62
+ * An optional object of headers to be passed to the API endpoint.
63
+ */
64
+ headers?: Record<string, string> | Headers;
65
+ /**
66
+ * An optional, additional body object to be passed to the API endpoint.
67
+ */
68
+ body?: object;
69
+ /**
70
+ * An optional callback that will be called when the assistant encounters an error.
71
+ */
72
+ onError?: (error: Error) => void;
73
+ };
74
+
43
75
  interface FunctionCall {
44
76
  /**
45
77
  * The arguments to call the function with, as generated by the model in JSON
@@ -474,14 +506,13 @@ type UseCompletionHelpers = {
474
506
  };
475
507
  declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, streamMode, onResponse, onFinish, onError, }?: UseCompletionOptions): UseCompletionHelpers;
476
508
 
477
- type AssistantStatus = 'in_progress' | 'awaiting_message';
478
509
  type UseAssistantHelpers = {
479
510
  /**
480
511
  * The current array of chat messages.
481
512
  */
482
513
  messages: Message[];
483
514
  /**
484
- * setState-powered method to update the messages array.
515
+ * Update the message store with a new array of messages.
485
516
  */
486
517
  setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
487
518
  /**
@@ -528,43 +559,13 @@ type UseAssistantHelpers = {
528
559
  */
529
560
  error: undefined | unknown;
530
561
  };
531
- type UseAssistantOptions = {
532
- /**
533
- * The API endpoint that accepts a `{ threadId: string | null; message: string; }` object and returns an `AssistantResponse` stream.
534
- * The threadId refers to an existing thread with messages (or is `null` to create a new thread).
535
- * The message is the next message that should be appended to the thread and sent to the assistant.
536
- */
537
- api: string;
538
- /**
539
- * An optional string that represents the ID of an existing thread.
540
- * If not provided, a new thread will be created.
541
- */
542
- threadId?: string;
543
- /**
544
- * An optional literal that sets the mode of credentials to be used on the request.
545
- * Defaults to "same-origin".
546
- */
547
- credentials?: RequestCredentials;
548
- /**
549
- * An optional object of headers to be passed to the API endpoint.
550
- */
551
- headers?: Record<string, string> | Headers;
552
- /**
553
- * An optional, additional body object to be passed to the API endpoint.
554
- */
555
- body?: object;
556
- /**
557
- * An optional callback that will be called when the assistant encounters an error.
558
- */
559
- onError?: (error: Error) => void;
560
- };
561
562
  declare function useAssistant({ api, threadId: threadIdParam, credentials, headers, body, onError, }: UseAssistantOptions): UseAssistantHelpers;
562
563
  /**
563
564
  @deprecated Use `useAssistant` instead.
564
565
  */
565
566
  declare const experimental_useAssistant: typeof useAssistant;
566
567
 
567
- export { AssistantStatus, CreateMessage, Message, UseAssistantHelpers, UseAssistantOptions, UseChatHelpers, UseChatOptions, UseCompletionHelpers, UseCompletionOptions, experimental_useAssistant, useAssistant, useChat, useCompletion };
568
+ export { CreateMessage, Message, UseAssistantHelpers, UseChatHelpers, UseChatOptions, UseCompletionHelpers, UseCompletionOptions, experimental_useAssistant, useAssistant, useChat, useCompletion };
568
569
  import * as react_jsx_runtime from 'react/jsx-runtime';
569
570
 
570
571
  type Props = {
@@ -1378,8 +1378,7 @@ function useAssistant({
1378
1378
  break;
1379
1379
  }
1380
1380
  case "error": {
1381
- const errorObj = new Error(value);
1382
- setError(errorObj);
1381
+ setError(new Error(value));
1383
1382
  break;
1384
1383
  }
1385
1384
  }