@assistant-ui/react 0.5.95 → 0.5.96

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ import { LocalThreadManagerRuntimeCore } from "./LocalThreadManagerRuntimeCore";
5
5
  export declare class LocalRuntimeCore extends BaseAssistantRuntimeCore {
6
6
  readonly threadManager: LocalThreadManagerRuntimeCore;
7
7
  private _options;
8
- constructor(options: LocalRuntimeOptionsBase, initialMessages?: CoreMessage[]);
8
+ constructor(options: LocalRuntimeOptionsBase, initialMessages: readonly CoreMessage[] | undefined);
9
9
  setOptions(options: LocalRuntimeOptionsBase): void;
10
10
  reset({ initialMessages, }?: {
11
11
  initialMessages?: readonly CoreMessage[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"LocalRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAehF,qBAAa,gBAAiB,SAAQ,wBAAwB;IAC5D,SAAgB,aAAa,gCAAC;IAE9B,OAAO,CAAC,QAAQ,CAA0B;gBAGxC,OAAO,EAAE,uBAAuB,EAChC,eAAe,CAAC,EAAE,WAAW,EAAE;IAuB1B,UAAU,CAAC,OAAO,EAAE,uBAAuB;IAM3C,KAAK,CAAC,EACX,eAAe,GAChB,GAAE;QACD,eAAe,CAAC,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,CAAC;KACjD;CAQP"}
1
+ {"version":3,"file":"LocalRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAehF,qBAAa,gBAAiB,SAAQ,wBAAwB;IAC5D,SAAgB,aAAa,gCAAC;IAE9B,OAAO,CAAC,QAAQ,CAA0B;gBAGxC,OAAO,EAAE,uBAAuB,EAChC,eAAe,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS;IAuB9C,UAAU,CAAC,OAAO,EAAE,uBAAuB;IAM3C,KAAK,CAAC,EACX,eAAe,GAChB,GAAE;QACD,eAAe,CAAC,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,CAAC;KACjD;CAQP"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"sourcesContent":["import type { CoreMessage } from \"../../types/AssistantTypes\";\nimport { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport { fromCoreMessages } from \"../edge/converters/fromCoreMessage\";\nimport { LocalThreadManagerRuntimeCore } from \"./LocalThreadManagerRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\n\nconst getExportFromInitialMessages = (\n initialMessages: readonly CoreMessage[],\n): ExportedMessageRepository => {\n const messages = fromCoreMessages(initialMessages);\n return {\n messages: messages.map((m, idx) => ({\n parentId: messages[idx - 1]?.id ?? null,\n message: m,\n })),\n };\n};\n\nexport class LocalRuntimeCore extends BaseAssistantRuntimeCore {\n public readonly threadManager;\n\n private _options: LocalRuntimeOptionsBase;\n\n constructor(\n options: LocalRuntimeOptionsBase,\n initialMessages?: CoreMessage[],\n ) {\n super();\n\n this._options = options;\n\n this.threadManager = new LocalThreadManagerRuntimeCore((threadId, data) => {\n const thread = new LocalThreadRuntimeCore(\n this._proxyConfigProvider,\n threadId,\n this._options,\n );\n thread.import(data);\n return thread;\n });\n\n if (initialMessages) {\n this.threadManager.mainThread.import(\n getExportFromInitialMessages(initialMessages),\n );\n }\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n this._options = options;\n\n this.threadManager.mainThread.setOptions(options);\n }\n\n public reset({\n initialMessages,\n }: {\n initialMessages?: readonly CoreMessage[] | undefined;\n } = {}) {\n this.threadManager.switchToNewThread();\n if (!initialMessages) return;\n\n this.threadManager.mainThread.import(\n getExportFromInitialMessages(initialMessages),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sCAAyC;AACzC,oCAAuC;AAEvC,6BAAiC;AACjC,2CAA8C;AAG9C,MAAM,+BAA+B,CACnC,oBAC8B;AAC9B,QAAM,eAAW,yCAAiB,eAAe;AACjD,SAAO;AAAA,IACL,UAAU,SAAS,IAAI,CAAC,GAAG,SAAS;AAAA,MAClC,UAAU,SAAS,MAAM,CAAC,GAAG,MAAM;AAAA,MACnC,SAAS;AAAA,IACX,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,yBAAyB,yDAAyB;AAAA,EAC7C;AAAA,EAER;AAAA,EAER,YACE,SACA,iBACA;AACA,UAAM;AAEN,SAAK,WAAW;AAEhB,SAAK,gBAAgB,IAAI,mEAA8B,CAAC,UAAU,SAAS;AACzE,YAAM,SAAS,IAAI;AAAA,QACjB,KAAK;AAAA,QACL;AAAA,QACA,KAAK;AAAA,MACP;AACA,aAAO,OAAO,IAAI;AAClB,aAAO;AAAA,IACT,CAAC;AAED,QAAI,iBAAiB;AACnB,WAAK,cAAc,WAAW;AAAA,QAC5B,6BAA6B,eAAe;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AAAA,EAEO,WAAW,SAAkC;AAClD,SAAK,WAAW;AAEhB,SAAK,cAAc,WAAW,WAAW,OAAO;AAAA,EAClD;AAAA,EAEO,MAAM;AAAA,IACX;AAAA,EACF,IAEI,CAAC,GAAG;AACN,SAAK,cAAc,kBAAkB;AACrC,QAAI,CAAC,gBAAiB;AAEtB,SAAK,cAAc,WAAW;AAAA,MAC5B,6BAA6B,eAAe;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"sourcesContent":["import type { CoreMessage } from \"../../types/AssistantTypes\";\nimport { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport { fromCoreMessages } from \"../edge/converters/fromCoreMessage\";\nimport { LocalThreadManagerRuntimeCore } from \"./LocalThreadManagerRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\n\nconst getExportFromInitialMessages = (\n initialMessages: readonly CoreMessage[],\n): ExportedMessageRepository => {\n const messages = fromCoreMessages(initialMessages);\n return {\n messages: messages.map((m, idx) => ({\n parentId: messages[idx - 1]?.id ?? null,\n message: m,\n })),\n };\n};\n\nexport class LocalRuntimeCore extends BaseAssistantRuntimeCore {\n public readonly threadManager;\n\n private _options: LocalRuntimeOptionsBase;\n\n constructor(\n options: LocalRuntimeOptionsBase,\n initialMessages: readonly CoreMessage[] | undefined,\n ) {\n super();\n\n this._options = options;\n\n this.threadManager = new LocalThreadManagerRuntimeCore((threadId, data) => {\n const thread = new LocalThreadRuntimeCore(\n this._proxyConfigProvider,\n threadId,\n this._options,\n );\n thread.import(data);\n return thread;\n });\n\n if (initialMessages) {\n this.threadManager.mainThread.import(\n getExportFromInitialMessages(initialMessages),\n );\n }\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n this._options = options;\n\n this.threadManager.mainThread.setOptions(options);\n }\n\n public reset({\n initialMessages,\n }: {\n initialMessages?: readonly CoreMessage[] | undefined;\n } = {}) {\n this.threadManager.switchToNewThread();\n if (!initialMessages) return;\n\n this.threadManager.mainThread.import(\n getExportFromInitialMessages(initialMessages),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sCAAyC;AACzC,oCAAuC;AAEvC,6BAAiC;AACjC,2CAA8C;AAG9C,MAAM,+BAA+B,CACnC,oBAC8B;AAC9B,QAAM,eAAW,yCAAiB,eAAe;AACjD,SAAO;AAAA,IACL,UAAU,SAAS,IAAI,CAAC,GAAG,SAAS;AAAA,MAClC,UAAU,SAAS,MAAM,CAAC,GAAG,MAAM;AAAA,MACnC,SAAS;AAAA,IACX,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,yBAAyB,yDAAyB;AAAA,EAC7C;AAAA,EAER;AAAA,EAER,YACE,SACA,iBACA;AACA,UAAM;AAEN,SAAK,WAAW;AAEhB,SAAK,gBAAgB,IAAI,mEAA8B,CAAC,UAAU,SAAS;AACzE,YAAM,SAAS,IAAI;AAAA,QACjB,KAAK;AAAA,QACL;AAAA,QACA,KAAK;AAAA,MACP;AACA,aAAO,OAAO,IAAI;AAClB,aAAO;AAAA,IACT,CAAC;AAED,QAAI,iBAAiB;AACnB,WAAK,cAAc,WAAW;AAAA,QAC5B,6BAA6B,eAAe;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AAAA,EAEO,WAAW,SAAkC;AAClD,SAAK,WAAW;AAEhB,SAAK,cAAc,WAAW,WAAW,OAAO;AAAA,EAClD;AAAA,EAEO,MAAM;AAAA,IACX;AAAA,EACF,IAEI,CAAC,GAAG;AACN,SAAK,cAAc,kBAAkB;AACrC,QAAI,CAAC,gBAAiB;AAEtB,SAAK,cAAc,WAAW;AAAA,MAC5B,6BAA6B,eAAe;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"sourcesContent":["import type { CoreMessage } from \"../../types/AssistantTypes\";\nimport { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport { fromCoreMessages } from \"../edge/converters/fromCoreMessage\";\nimport { LocalThreadManagerRuntimeCore } from \"./LocalThreadManagerRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\n\nconst getExportFromInitialMessages = (\n initialMessages: readonly CoreMessage[],\n): ExportedMessageRepository => {\n const messages = fromCoreMessages(initialMessages);\n return {\n messages: messages.map((m, idx) => ({\n parentId: messages[idx - 1]?.id ?? null,\n message: m,\n })),\n };\n};\n\nexport class LocalRuntimeCore extends BaseAssistantRuntimeCore {\n public readonly threadManager;\n\n private _options: LocalRuntimeOptionsBase;\n\n constructor(\n options: LocalRuntimeOptionsBase,\n initialMessages?: CoreMessage[],\n ) {\n super();\n\n this._options = options;\n\n this.threadManager = new LocalThreadManagerRuntimeCore((threadId, data) => {\n const thread = new LocalThreadRuntimeCore(\n this._proxyConfigProvider,\n threadId,\n this._options,\n );\n thread.import(data);\n return thread;\n });\n\n if (initialMessages) {\n this.threadManager.mainThread.import(\n getExportFromInitialMessages(initialMessages),\n );\n }\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n this._options = options;\n\n this.threadManager.mainThread.setOptions(options);\n }\n\n public reset({\n initialMessages,\n }: {\n initialMessages?: readonly CoreMessage[] | undefined;\n } = {}) {\n this.threadManager.switchToNewThread();\n if (!initialMessages) return;\n\n this.threadManager.mainThread.import(\n getExportFromInitialMessages(initialMessages),\n );\n }\n}\n"],"mappings":"AACA,SAAS,gCAAgC;AACzC,SAAS,8BAA8B;AAEvC,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAG9C,MAAM,+BAA+B,CACnC,oBAC8B;AAC9B,QAAM,WAAW,iBAAiB,eAAe;AACjD,SAAO;AAAA,IACL,UAAU,SAAS,IAAI,CAAC,GAAG,SAAS;AAAA,MAClC,UAAU,SAAS,MAAM,CAAC,GAAG,MAAM;AAAA,MACnC,SAAS;AAAA,IACX,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,yBAAyB,yBAAyB;AAAA,EAC7C;AAAA,EAER;AAAA,EAER,YACE,SACA,iBACA;AACA,UAAM;AAEN,SAAK,WAAW;AAEhB,SAAK,gBAAgB,IAAI,8BAA8B,CAAC,UAAU,SAAS;AACzE,YAAM,SAAS,IAAI;AAAA,QACjB,KAAK;AAAA,QACL;AAAA,QACA,KAAK;AAAA,MACP;AACA,aAAO,OAAO,IAAI;AAClB,aAAO;AAAA,IACT,CAAC;AAED,QAAI,iBAAiB;AACnB,WAAK,cAAc,WAAW;AAAA,QAC5B,6BAA6B,eAAe;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AAAA,EAEO,WAAW,SAAkC;AAClD,SAAK,WAAW;AAEhB,SAAK,cAAc,WAAW,WAAW,OAAO;AAAA,EAClD;AAAA,EAEO,MAAM;AAAA,IACX;AAAA,EACF,IAEI,CAAC,GAAG;AACN,SAAK,cAAc,kBAAkB;AACrC,QAAI,CAAC,gBAAiB;AAEtB,SAAK,cAAc,WAAW;AAAA,MAC5B,6BAA6B,eAAe;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeCore.tsx"],"sourcesContent":["import type { CoreMessage } from \"../../types/AssistantTypes\";\nimport { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport { fromCoreMessages } from \"../edge/converters/fromCoreMessage\";\nimport { LocalThreadManagerRuntimeCore } from \"./LocalThreadManagerRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\n\nconst getExportFromInitialMessages = (\n initialMessages: readonly CoreMessage[],\n): ExportedMessageRepository => {\n const messages = fromCoreMessages(initialMessages);\n return {\n messages: messages.map((m, idx) => ({\n parentId: messages[idx - 1]?.id ?? null,\n message: m,\n })),\n };\n};\n\nexport class LocalRuntimeCore extends BaseAssistantRuntimeCore {\n public readonly threadManager;\n\n private _options: LocalRuntimeOptionsBase;\n\n constructor(\n options: LocalRuntimeOptionsBase,\n initialMessages: readonly CoreMessage[] | undefined,\n ) {\n super();\n\n this._options = options;\n\n this.threadManager = new LocalThreadManagerRuntimeCore((threadId, data) => {\n const thread = new LocalThreadRuntimeCore(\n this._proxyConfigProvider,\n threadId,\n this._options,\n );\n thread.import(data);\n return thread;\n });\n\n if (initialMessages) {\n this.threadManager.mainThread.import(\n getExportFromInitialMessages(initialMessages),\n );\n }\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n this._options = options;\n\n this.threadManager.mainThread.setOptions(options);\n }\n\n public reset({\n initialMessages,\n }: {\n initialMessages?: readonly CoreMessage[] | undefined;\n } = {}) {\n this.threadManager.switchToNewThread();\n if (!initialMessages) return;\n\n this.threadManager.mainThread.import(\n getExportFromInitialMessages(initialMessages),\n );\n }\n}\n"],"mappings":"AACA,SAAS,gCAAgC;AACzC,SAAS,8BAA8B;AAEvC,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAG9C,MAAM,+BAA+B,CACnC,oBAC8B;AAC9B,QAAM,WAAW,iBAAiB,eAAe;AACjD,SAAO;AAAA,IACL,UAAU,SAAS,IAAI,CAAC,GAAG,SAAS;AAAA,MAClC,UAAU,SAAS,MAAM,CAAC,GAAG,MAAM;AAAA,MACnC,SAAS;AAAA,IACX,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,yBAAyB,yBAAyB;AAAA,EAC7C;AAAA,EAER;AAAA,EAER,YACE,SACA,iBACA;AACA,UAAM;AAEN,SAAK,WAAW;AAEhB,SAAK,gBAAgB,IAAI,8BAA8B,CAAC,UAAU,SAAS;AACzE,YAAM,SAAS,IAAI;AAAA,QACjB,KAAK;AAAA,QACL;AAAA,QACA,KAAK;AAAA,MACP;AACA,aAAO,OAAO,IAAI;AAClB,aAAO;AAAA,IACT,CAAC;AAED,QAAI,iBAAiB;AACnB,WAAK,cAAc,WAAW;AAAA,QAC5B,6BAA6B,eAAe;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AAAA,EAEO,WAAW,SAAkC;AAClD,SAAK,WAAW;AAEhB,SAAK,cAAc,WAAW,WAAW,OAAO;AAAA,EAClD;AAAA,EAEO,MAAM;AAAA,IACX;AAAA,EACF,IAEI,CAAC,GAAG;AACN,SAAK,cAAc,kBAAkB;AACrC,QAAI,CAAC,gBAAiB;AAEtB,SAAK,cAAc,WAAW;AAAA,MAC5B,6BAA6B,eAAe;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
@@ -5,5 +5,5 @@ import { AssistantRuntime } from "../../api/AssistantRuntime";
5
5
  export type LocalRuntime = AssistantRuntime & {
6
6
  reset: (options?: Parameters<LocalRuntimeCore["reset"]>[0]) => void;
7
7
  };
8
- export declare const useLocalRuntime: (adapter: ChatModelAdapter, options?: LocalRuntimeOptions) => LocalRuntime;
8
+ export declare const useLocalRuntime: (adapter: ChatModelAdapter, { initialMessages, ...options }?: LocalRuntimeOptions) => LocalRuntime;
9
9
  //# sourceMappingURL=useLocalRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,gBAAgB,EAEjB,MAAM,4BAA4B,CAAC;AAIpC,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CACrE,CAAC;AAsBF,eAAO,MAAM,eAAe,YACjB,gBAAgB,YAChB,mBAAmB,iBAiB7B,CAAC"}
1
+ {"version":3,"file":"useLocalRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,gBAAgB,EAEjB,MAAM,4BAA4B,CAAC;AAIpC,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CACrE,CAAC;AAsBF,eAAO,MAAM,eAAe,YACjB,gBAAgB,oCACQ,mBAAmB,iBAiBrD,CAAC"}
@@ -41,7 +41,7 @@ class LocalRuntimeImpl extends import_AssistantRuntime.AssistantRuntimeImpl {
41
41
  );
42
42
  }
43
43
  }
44
- const useLocalRuntime = (adapter, options = {}) => {
44
+ const useLocalRuntime = (adapter, { initialMessages, ...options } = {}) => {
45
45
  const opt = {
46
46
  ...options,
47
47
  adapters: {
@@ -49,7 +49,7 @@ const useLocalRuntime = (adapter, options = {}) => {
49
49
  chatModel: adapter
50
50
  }
51
51
  };
52
- const [runtime] = (0, import_react.useState)(() => new import_LocalRuntimeCore.LocalRuntimeCore(opt));
52
+ const [runtime] = (0, import_react.useState)(() => new import_LocalRuntimeCore.LocalRuntimeCore(opt, initialMessages));
53
53
  (0, import_react.useEffect)(() => {
54
54
  runtime.setOptions(opt);
55
55
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport {\n AssistantRuntime,\n AssistantRuntimeImpl,\n} from \"../../api/AssistantRuntime\";\nimport { ThreadRuntimeImpl } from \"../../internal\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\n\nexport type LocalRuntime = AssistantRuntime & {\n reset: (options?: Parameters<LocalRuntimeCore[\"reset\"]>[0]) => void;\n};\n\nclass LocalRuntimeImpl extends AssistantRuntimeImpl implements LocalRuntime {\n private constructor(\n private core: LocalRuntimeCore,\n thread: ThreadRuntime,\n ) {\n super(core, thread);\n }\n\n public reset(options?: Parameters<LocalRuntimeCore[\"reset\"]>[0]) {\n this.core.reset(options);\n }\n\n public static override create(_core: LocalRuntimeCore) {\n return new LocalRuntimeImpl(\n _core,\n AssistantRuntimeImpl.createMainThreadRuntime(_core, ThreadRuntimeImpl),\n ) as LocalRuntime;\n }\n}\n\nexport const useLocalRuntime = (\n adapter: ChatModelAdapter,\n options: LocalRuntimeOptions = {},\n) => {\n const opt = {\n ...options,\n adapters: {\n ...options.adapters,\n chatModel: adapter,\n },\n };\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt));\n\n useEffect(() => {\n runtime.setOptions(opt);\n });\n\n return useMemo(() => LocalRuntimeImpl.create(runtime), [runtime]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA6C;AAE7C,8BAAiC;AAEjC,8BAGO;AACP,sBAAkC;AAOlC,MAAM,yBAAyB,6CAA6C;AAAA,EAClE,YACE,MACR,QACA;AACA,UAAM,MAAM,MAAM;AAHV;AAAA,EAIV;AAAA,EAEO,MAAM,SAAoD;AAC/D,SAAK,KAAK,MAAM,OAAO;AAAA,EACzB;AAAA,EAEA,OAAuB,OAAO,OAAyB;AACrD,WAAO,IAAI;AAAA,MACT;AAAA,MACA,6CAAqB,wBAAwB,OAAO,iCAAiB;AAAA,IACvE;AAAA,EACF;AACF;AAEO,MAAM,kBAAkB,CAC7B,SACA,UAA+B,CAAC,MAC7B;AACH,QAAM,MAAM;AAAA,IACV,GAAG;AAAA,IACH,UAAU;AAAA,MACR,GAAG,QAAQ;AAAA,MACX,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,CAAC,OAAO,QAAI,uBAAS,MAAM,IAAI,yCAAiB,GAAG,CAAC;AAE1D,8BAAU,MAAM;AACd,YAAQ,WAAW,GAAG;AAAA,EACxB,CAAC;AAED,aAAO,sBAAQ,MAAM,iBAAiB,OAAO,OAAO,GAAG,CAAC,OAAO,CAAC;AAClE;","names":[]}
1
+ {"version":3,"sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport {\n AssistantRuntime,\n AssistantRuntimeImpl,\n} from \"../../api/AssistantRuntime\";\nimport { ThreadRuntimeImpl } from \"../../internal\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\n\nexport type LocalRuntime = AssistantRuntime & {\n reset: (options?: Parameters<LocalRuntimeCore[\"reset\"]>[0]) => void;\n};\n\nclass LocalRuntimeImpl extends AssistantRuntimeImpl implements LocalRuntime {\n private constructor(\n private core: LocalRuntimeCore,\n thread: ThreadRuntime,\n ) {\n super(core, thread);\n }\n\n public reset(options?: Parameters<LocalRuntimeCore[\"reset\"]>[0]) {\n this.core.reset(options);\n }\n\n public static override create(_core: LocalRuntimeCore) {\n return new LocalRuntimeImpl(\n _core,\n AssistantRuntimeImpl.createMainThreadRuntime(_core, ThreadRuntimeImpl),\n ) as LocalRuntime;\n }\n}\n\nexport const useLocalRuntime = (\n adapter: ChatModelAdapter,\n { initialMessages, ...options }: LocalRuntimeOptions = {},\n) => {\n const opt = {\n ...options,\n adapters: {\n ...options.adapters,\n chatModel: adapter,\n },\n };\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));\n\n useEffect(() => {\n runtime.setOptions(opt);\n });\n\n return useMemo(() => LocalRuntimeImpl.create(runtime), [runtime]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA6C;AAE7C,8BAAiC;AAEjC,8BAGO;AACP,sBAAkC;AAOlC,MAAM,yBAAyB,6CAA6C;AAAA,EAClE,YACE,MACR,QACA;AACA,UAAM,MAAM,MAAM;AAHV;AAAA,EAIV;AAAA,EAEO,MAAM,SAAoD;AAC/D,SAAK,KAAK,MAAM,OAAO;AAAA,EACzB;AAAA,EAEA,OAAuB,OAAO,OAAyB;AACrD,WAAO,IAAI;AAAA,MACT;AAAA,MACA,6CAAqB,wBAAwB,OAAO,iCAAiB;AAAA,IACvE;AAAA,EACF;AACF;AAEO,MAAM,kBAAkB,CAC7B,SACA,EAAE,iBAAiB,GAAG,QAAQ,IAAyB,CAAC,MACrD;AACH,QAAM,MAAM;AAAA,IACV,GAAG;AAAA,IACH,UAAU;AAAA,MACR,GAAG,QAAQ;AAAA,MACX,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,CAAC,OAAO,QAAI,uBAAS,MAAM,IAAI,yCAAiB,KAAK,eAAe,CAAC;AAE3E,8BAAU,MAAM;AACd,YAAQ,WAAW,GAAG;AAAA,EACxB,CAAC;AAED,aAAO,sBAAQ,MAAM,iBAAiB,OAAO,OAAO,GAAG,CAAC,OAAO,CAAC;AAClE;","names":[]}
@@ -20,7 +20,7 @@ class LocalRuntimeImpl extends AssistantRuntimeImpl {
20
20
  );
21
21
  }
22
22
  }
23
- const useLocalRuntime = (adapter, options = {}) => {
23
+ const useLocalRuntime = (adapter, { initialMessages, ...options } = {}) => {
24
24
  const opt = {
25
25
  ...options,
26
26
  adapters: {
@@ -28,7 +28,7 @@ const useLocalRuntime = (adapter, options = {}) => {
28
28
  chatModel: adapter
29
29
  }
30
30
  };
31
- const [runtime] = useState(() => new LocalRuntimeCore(opt));
31
+ const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));
32
32
  useEffect(() => {
33
33
  runtime.setOptions(opt);
34
34
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport {\n AssistantRuntime,\n AssistantRuntimeImpl,\n} from \"../../api/AssistantRuntime\";\nimport { ThreadRuntimeImpl } from \"../../internal\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\n\nexport type LocalRuntime = AssistantRuntime & {\n reset: (options?: Parameters<LocalRuntimeCore[\"reset\"]>[0]) => void;\n};\n\nclass LocalRuntimeImpl extends AssistantRuntimeImpl implements LocalRuntime {\n private constructor(\n private core: LocalRuntimeCore,\n thread: ThreadRuntime,\n ) {\n super(core, thread);\n }\n\n public reset(options?: Parameters<LocalRuntimeCore[\"reset\"]>[0]) {\n this.core.reset(options);\n }\n\n public static override create(_core: LocalRuntimeCore) {\n return new LocalRuntimeImpl(\n _core,\n AssistantRuntimeImpl.createMainThreadRuntime(_core, ThreadRuntimeImpl),\n ) as LocalRuntime;\n }\n}\n\nexport const useLocalRuntime = (\n adapter: ChatModelAdapter,\n options: LocalRuntimeOptions = {},\n) => {\n const opt = {\n ...options,\n adapters: {\n ...options.adapters,\n chatModel: adapter,\n },\n };\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt));\n\n useEffect(() => {\n runtime.setOptions(opt);\n });\n\n return useMemo(() => LocalRuntimeImpl.create(runtime), [runtime]);\n};\n"],"mappings":";AAEA,SAAS,WAAW,SAAS,gBAAgB;AAE7C,SAAS,wBAAwB;AAEjC;AAAA,EAEE;AAAA,OACK;AACP,SAAS,yBAAyB;AAOlC,MAAM,yBAAyB,qBAA6C;AAAA,EAClE,YACE,MACR,QACA;AACA,UAAM,MAAM,MAAM;AAHV;AAAA,EAIV;AAAA,EAEO,MAAM,SAAoD;AAC/D,SAAK,KAAK,MAAM,OAAO;AAAA,EACzB;AAAA,EAEA,OAAuB,OAAO,OAAyB;AACrD,WAAO,IAAI;AAAA,MACT;AAAA,MACA,qBAAqB,wBAAwB,OAAO,iBAAiB;AAAA,IACvE;AAAA,EACF;AACF;AAEO,MAAM,kBAAkB,CAC7B,SACA,UAA+B,CAAC,MAC7B;AACH,QAAM,MAAM;AAAA,IACV,GAAG;AAAA,IACH,UAAU;AAAA,MACR,GAAG,QAAQ;AAAA,MACX,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,CAAC,OAAO,IAAI,SAAS,MAAM,IAAI,iBAAiB,GAAG,CAAC;AAE1D,YAAU,MAAM;AACd,YAAQ,WAAW,GAAG;AAAA,EACxB,CAAC;AAED,SAAO,QAAQ,MAAM,iBAAiB,OAAO,OAAO,GAAG,CAAC,OAAO,CAAC;AAClE;","names":[]}
1
+ {"version":3,"sources":["../../../src/runtimes/local/useLocalRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntimeCore } from \"./LocalRuntimeCore\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\nimport {\n AssistantRuntime,\n AssistantRuntimeImpl,\n} from \"../../api/AssistantRuntime\";\nimport { ThreadRuntimeImpl } from \"../../internal\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\n\nexport type LocalRuntime = AssistantRuntime & {\n reset: (options?: Parameters<LocalRuntimeCore[\"reset\"]>[0]) => void;\n};\n\nclass LocalRuntimeImpl extends AssistantRuntimeImpl implements LocalRuntime {\n private constructor(\n private core: LocalRuntimeCore,\n thread: ThreadRuntime,\n ) {\n super(core, thread);\n }\n\n public reset(options?: Parameters<LocalRuntimeCore[\"reset\"]>[0]) {\n this.core.reset(options);\n }\n\n public static override create(_core: LocalRuntimeCore) {\n return new LocalRuntimeImpl(\n _core,\n AssistantRuntimeImpl.createMainThreadRuntime(_core, ThreadRuntimeImpl),\n ) as LocalRuntime;\n }\n}\n\nexport const useLocalRuntime = (\n adapter: ChatModelAdapter,\n { initialMessages, ...options }: LocalRuntimeOptions = {},\n) => {\n const opt = {\n ...options,\n adapters: {\n ...options.adapters,\n chatModel: adapter,\n },\n };\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));\n\n useEffect(() => {\n runtime.setOptions(opt);\n });\n\n return useMemo(() => LocalRuntimeImpl.create(runtime), [runtime]);\n};\n"],"mappings":";AAEA,SAAS,WAAW,SAAS,gBAAgB;AAE7C,SAAS,wBAAwB;AAEjC;AAAA,EAEE;AAAA,OACK;AACP,SAAS,yBAAyB;AAOlC,MAAM,yBAAyB,qBAA6C;AAAA,EAClE,YACE,MACR,QACA;AACA,UAAM,MAAM,MAAM;AAHV;AAAA,EAIV;AAAA,EAEO,MAAM,SAAoD;AAC/D,SAAK,KAAK,MAAM,OAAO;AAAA,EACzB;AAAA,EAEA,OAAuB,OAAO,OAAyB;AACrD,WAAO,IAAI;AAAA,MACT;AAAA,MACA,qBAAqB,wBAAwB,OAAO,iBAAiB;AAAA,IACvE;AAAA,EACF;AACF;AAEO,MAAM,kBAAkB,CAC7B,SACA,EAAE,iBAAiB,GAAG,QAAQ,IAAyB,CAAC,MACrD;AACH,QAAM,MAAM;AAAA,IACV,GAAG;AAAA,IACH,UAAU;AAAA,MACR,GAAG,QAAQ;AAAA,MACX,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,CAAC,OAAO,IAAI,SAAS,MAAM,IAAI,iBAAiB,KAAK,eAAe,CAAC;AAE3E,YAAU,MAAM;AACd,YAAQ,WAAW,GAAG;AAAA,EACxB,CAAC;AAED,SAAO,QAAQ,MAAM,iBAAiB,OAAO,OAAO,GAAG,CAAC,OAAO,CAAC;AAClE;","names":[]}
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "conversational-ui",
30
30
  "conversational-ai"
31
31
  ],
32
- "version": "0.5.95",
32
+ "version": "0.5.96",
33
33
  "license": "MIT",
34
34
  "exports": {
35
35
  ".": {
@@ -25,7 +25,7 @@ export class LocalRuntimeCore extends BaseAssistantRuntimeCore {
25
25
 
26
26
  constructor(
27
27
  options: LocalRuntimeOptionsBase,
28
- initialMessages?: CoreMessage[],
28
+ initialMessages: readonly CoreMessage[] | undefined,
29
29
  ) {
30
30
  super();
31
31
 
@@ -37,7 +37,7 @@ class LocalRuntimeImpl extends AssistantRuntimeImpl implements LocalRuntime {
37
37
 
38
38
  export const useLocalRuntime = (
39
39
  adapter: ChatModelAdapter,
40
- options: LocalRuntimeOptions = {},
40
+ { initialMessages, ...options }: LocalRuntimeOptions = {},
41
41
  ) => {
42
42
  const opt = {
43
43
  ...options,
@@ -47,7 +47,7 @@ export const useLocalRuntime = (
47
47
  },
48
48
  };
49
49
 
50
- const [runtime] = useState(() => new LocalRuntimeCore(opt));
50
+ const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));
51
51
 
52
52
  useEffect(() => {
53
53
  runtime.setOptions(opt);