@assistant-ui/react 0.7.21 → 0.7.22

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 (68) hide show
  1. package/dist/api/ComposerRuntime.d.ts +9 -7
  2. package/dist/api/ComposerRuntime.d.ts.map +1 -1
  3. package/dist/api/ComposerRuntime.js +9 -4
  4. package/dist/api/ComposerRuntime.js.map +1 -1
  5. package/dist/api/ComposerRuntime.mjs +9 -4
  6. package/dist/api/ComposerRuntime.mjs.map +1 -1
  7. package/dist/api/MessageRuntime.d.ts +7 -3
  8. package/dist/api/MessageRuntime.d.ts.map +1 -1
  9. package/dist/api/MessageRuntime.js +5 -2
  10. package/dist/api/MessageRuntime.js.map +1 -1
  11. package/dist/api/MessageRuntime.mjs +5 -2
  12. package/dist/api/MessageRuntime.mjs.map +1 -1
  13. package/dist/api/ThreadRuntime.d.ts +5 -5
  14. package/dist/api/ThreadRuntime.d.ts.map +1 -1
  15. package/dist/api/ThreadRuntime.js +3 -2
  16. package/dist/api/ThreadRuntime.js.map +1 -1
  17. package/dist/api/ThreadRuntime.mjs +3 -2
  18. package/dist/api/ThreadRuntime.mjs.map +1 -1
  19. package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +6 -3
  20. package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
  21. package/dist/runtimes/composer/BaseComposerRuntimeCore.js +19 -6
  22. package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
  23. package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +19 -6
  24. package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
  25. package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +2 -2
  26. package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
  27. package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
  28. package/dist/runtimes/core/BaseThreadRuntimeCore.mjs.map +1 -1
  29. package/dist/runtimes/core/ComposerRuntimeCore.d.ts +6 -4
  30. package/dist/runtimes/core/ComposerRuntimeCore.d.ts.map +1 -1
  31. package/dist/runtimes/core/ComposerRuntimeCore.js.map +1 -1
  32. package/dist/runtimes/core/ThreadRuntimeCore.d.ts +6 -1
  33. package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
  34. package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
  35. package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +2 -2
  36. package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
  37. package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
  38. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +2 -2
  39. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
  40. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +2 -2
  41. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
  42. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs +2 -2
  43. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs.map +1 -1
  44. package/dist/runtimes/local/ChatModelAdapter.d.ts +2 -1
  45. package/dist/runtimes/local/ChatModelAdapter.d.ts.map +1 -1
  46. package/dist/runtimes/local/ChatModelAdapter.js.map +1 -1
  47. package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts +3 -2
  48. package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
  49. package/dist/runtimes/local/LocalThreadRuntimeCore.js +14 -5
  50. package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
  51. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +14 -5
  52. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
  53. package/dist/types/AssistantTypes.d.ts +5 -0
  54. package/dist/types/AssistantTypes.d.ts.map +1 -1
  55. package/dist/types/AssistantTypes.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/api/ComposerRuntime.ts +21 -12
  58. package/src/api/MessageRuntime.ts +11 -3
  59. package/src/api/ThreadRuntime.ts +9 -4
  60. package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +26 -6
  61. package/src/runtimes/core/BaseThreadRuntimeCore.tsx +2 -1
  62. package/src/runtimes/core/ComposerRuntimeCore.tsx +9 -6
  63. package/src/runtimes/core/ThreadRuntimeCore.tsx +7 -1
  64. package/src/runtimes/external-store/ExternalStoreAdapter.tsx +4 -1
  65. package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +3 -2
  66. package/src/runtimes/local/ChatModelAdapter.tsx +2 -0
  67. package/src/runtimes/local/LocalThreadRuntimeCore.tsx +17 -4
  68. package/src/types/AssistantTypes.ts +7 -0
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantTypes.d.ts","sourceRoot":"","sources":["../../src/types/AssistantTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;KACh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EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,eAAe,GACf,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { CompleteAttachment } from \"./AttachmentTypes\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ImageContentPart = {\n readonly type: \"image\";\n readonly image: string;\n};\n\nexport type Unstable_AudioContentPart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\nexport type UIContentPart = {\n readonly type: \"ui\";\n readonly display: ReactNode;\n};\n\nexport type CoreToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: TArgs;\n readonly result?: TResult | undefined;\n readonly isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n readonly argsText: string;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | UIContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ToolCallContentPart\n | UIContentPart;\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadStep = {\n readonly usage?:\n | {\n readonly promptTokens: number;\n readonly completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: [TextContentPart];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: ThreadUserContentPart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: ThreadAssistantContentPart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly steps: ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type AppendMessage = CoreMessage & {\n parentId: string | null;\n attachments: readonly CompleteAttachment[];\n startRun?: boolean | undefined;\n};\n\ntype BaseThreadMessage = {\n readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly steps?: ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n readonly attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n\n/** Core Message Types (without UI content parts) */\n\nexport type CoreUserContentPart =\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart;\nexport type CoreAssistantContentPart =\n | TextContentPart\n | CoreToolCallContentPart;\n\nexport type CoreSystemMessage = {\n role: \"system\";\n content: [TextContentPart];\n};\n\nexport type CoreUserMessage = {\n role: \"user\";\n content: CoreUserContentPart[];\n};\n\nexport type CoreAssistantMessage = {\n role: \"assistant\";\n content: CoreAssistantContentPart[];\n};\n\nexport type CoreMessage =\n | CoreSystemMessage\n | CoreUserMessage\n | CoreAssistantMessage;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { CompleteAttachment } from \"./AttachmentTypes\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ImageContentPart = {\n readonly type: \"image\";\n readonly image: string;\n};\n\nexport type Unstable_AudioContentPart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\nexport type UIContentPart = {\n readonly type: \"ui\";\n readonly display: ReactNode;\n};\n\nexport type CoreToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: TArgs;\n readonly result?: TResult | undefined;\n readonly isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n readonly argsText: string;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | UIContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ToolCallContentPart\n | UIContentPart;\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadStep = {\n readonly usage?:\n | {\n readonly promptTokens: number;\n readonly completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: [TextContentPart];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: ThreadUserContentPart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: ThreadAssistantContentPart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly steps: ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type RunConfig = {\n // TODO allow user customization via global type overrides\n custom?: unknown;\n};\n\nexport type AppendMessage = CoreMessage & {\n parentId: string | null;\n attachments: readonly CompleteAttachment[];\n startRun?: boolean | undefined;\n /** TODO: make required in 0.8.0 */\n runConfig?: RunConfig | undefined;\n};\n\ntype BaseThreadMessage = {\n readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly steps?: ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n readonly attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n\n/** Core Message Types (without UI content parts) */\n\nexport type CoreUserContentPart =\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart;\nexport type CoreAssistantContentPart =\n | TextContentPart\n | CoreToolCallContentPart;\n\nexport type CoreSystemMessage = {\n role: \"system\";\n content: [TextContentPart];\n};\n\nexport type CoreUserMessage = {\n role: \"user\";\n content: CoreUserContentPart[];\n};\n\nexport type CoreAssistantMessage = {\n role: \"assistant\";\n content: CoreAssistantContentPart[];\n};\n\nexport type CoreMessage =\n | CoreSystemMessage\n | CoreUserMessage\n | CoreAssistantMessage;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "conversational-ui",
30
30
  "conversational-ai"
31
31
  ],
32
- "version": "0.7.21",
32
+ "version": "0.7.22",
33
33
  "license": "MIT",
34
34
  "exports": {
35
35
  ".": {
@@ -16,7 +16,7 @@ import {
16
16
  import { ShallowMemoizeSubject } from "./subscribable/ShallowMemoizeSubject";
17
17
  import { SKIP_UPDATE } from "./subscribable/SKIP_UPDATE";
18
18
  import { ComposerRuntimePath } from "./RuntimePathTypes";
19
- import { MessageRole } from "../types/AssistantTypes";
19
+ import { MessageRole, RunConfig } from "../types/AssistantTypes";
20
20
 
21
21
  export type ThreadComposerRuntimeCoreBinding = SubscribableWithState<
22
22
  ThreadComposerRuntimeCore | undefined,
@@ -34,13 +34,14 @@ export type ComposerRuntimeCoreBinding = SubscribableWithState<
34
34
  >;
35
35
 
36
36
  type BaseComposerState = {
37
- readonly text: string;
38
- readonly role: MessageRole;
39
- readonly attachments: readonly Attachment[];
40
-
41
37
  readonly canCancel: boolean;
42
38
  readonly isEditing: boolean;
43
39
  readonly isEmpty: boolean;
40
+
41
+ readonly text: string;
42
+ readonly role: MessageRole;
43
+ readonly attachments: readonly Attachment[];
44
+ readonly runConfig: RunConfig;
44
45
  };
45
46
 
46
47
  export type ThreadComposerState = BaseComposerState & {
@@ -56,6 +57,7 @@ export type EditComposerState = BaseComposerState & {
56
57
  export type ComposerState = ThreadComposerState | EditComposerState;
57
58
 
58
59
  const EMPTY_ARRAY = Object.freeze([]);
60
+ const EMPTY_OBJECT = Object.freeze({});
59
61
  const getThreadComposerState = (
60
62
  runtime: ThreadComposerRuntimeCore | undefined,
61
63
  ): ThreadComposerState => {
@@ -65,9 +67,11 @@ const getThreadComposerState = (
65
67
  isEditing: runtime?.isEditing ?? false,
66
68
  canCancel: runtime?.canCancel ?? false,
67
69
  isEmpty: runtime?.isEmpty ?? true,
68
- text: runtime?.text ?? "",
70
+
69
71
  attachments: runtime?.attachments ?? EMPTY_ARRAY,
72
+ text: runtime?.text ?? "",
70
73
  role: runtime?.role ?? "user",
74
+ runConfig: runtime?.runConfig ?? EMPTY_OBJECT,
71
75
 
72
76
  value: runtime?.text ?? "",
73
77
  });
@@ -82,9 +86,11 @@ const getEditComposerState = (
82
86
  isEditing: runtime?.isEditing ?? false,
83
87
  canCancel: runtime?.canCancel ?? false,
84
88
  isEmpty: runtime?.isEmpty ?? true,
89
+
85
90
  text: runtime?.text ?? "",
86
- attachments: runtime?.attachments ?? EMPTY_ARRAY,
87
91
  role: runtime?.role ?? "user",
92
+ attachments: runtime?.attachments ?? EMPTY_ARRAY,
93
+ runConfig: runtime?.runConfig ?? EMPTY_OBJECT,
88
94
 
89
95
  value: runtime?.text ?? "",
90
96
  });
@@ -95,12 +101,13 @@ export type ComposerRuntime = {
95
101
  readonly type: "edit" | "thread";
96
102
  getState(): ComposerState;
97
103
 
98
- setText(text: string): void;
99
- setValue(text: string): void;
100
-
101
104
  getAttachmentAccept(): string;
102
105
  addAttachment(file: File): Promise<void>;
103
106
 
107
+ setText(text: string): void;
108
+ setRole(role: MessageRole): void;
109
+ setRunConfig(runConfig: RunConfig): void;
110
+
104
111
  reset(): void;
105
112
  send(): void;
106
113
  cancel(): void;
@@ -125,8 +132,10 @@ export abstract class ComposerRuntimeImpl implements ComposerRuntime {
125
132
  core.setText(text);
126
133
  }
127
134
 
128
- public setValue(text: string) {
129
- this.setText(text);
135
+ public setRunConfig(runConfig: RunConfig) {
136
+ const core = this._core.getState();
137
+ if (!core) throw new Error("Composer is not available");
138
+ core.setRunConfig(runConfig);
130
139
  }
131
140
 
132
141
  public addAttachment(file: File) {
@@ -10,6 +10,7 @@ import {
10
10
  } from "../types";
11
11
  import {
12
12
  ContentPartStatus,
13
+ RunConfig,
13
14
  ToolCallContentPartStatus,
14
15
  } from "../types/AssistantTypes";
15
16
  import { getThreadMessageText } from "../utils/getThreadMessageText";
@@ -110,13 +111,17 @@ export type MessageStateBinding = SubscribableWithState<
110
111
  MessageRuntimePath
111
112
  >;
112
113
 
114
+ type ReloadConfig = {
115
+ runConfig?: RunConfig;
116
+ };
117
+
113
118
  export type MessageRuntime = {
114
119
  readonly path: MessageRuntimePath;
115
120
 
116
121
  readonly composer: EditComposerRuntime;
117
122
 
118
123
  getState(): MessageState;
119
- reload(): void;
124
+ reload(config?: ReloadConfig): void;
120
125
  /**
121
126
  * @deprecated This API is still under active development and might change without notice.
122
127
  */
@@ -175,12 +180,15 @@ export class MessageRuntimeImpl implements MessageRuntime {
175
180
  return this._core.getState();
176
181
  }
177
182
 
178
- public reload() {
183
+ public reload({ runConfig = {} }: ReloadConfig = {}) {
179
184
  const state = this._core.getState();
180
185
  if (state.role !== "assistant")
181
186
  throw new Error("Can only reload assistant messages");
182
187
 
183
- this._threadBinding.getState().startRun(state.parentId);
188
+ this._threadBinding.getState().startRun({
189
+ parentId: state.parentId,
190
+ runConfig,
191
+ });
184
192
  }
185
193
 
186
194
  public speak() {
@@ -4,6 +4,7 @@ import {
4
4
  ThreadRuntimeCore,
5
5
  SpeechState,
6
6
  ThreadRuntimeEventType,
7
+ StartRunConfig,
7
8
  } from "../runtimes/core/ThreadRuntimeCore";
8
9
  import { ExportedMessageRepository } from "../runtimes/utils/MessageRepository";
9
10
  import {
@@ -189,10 +190,10 @@ export type ThreadRuntime = {
189
190
  append(message: CreateAppendMessage): void;
190
191
 
191
192
  /**
192
- *
193
- * @param parentId
193
+ * @deprecated pass an object with `parentId` instead. This will be removed in 0.8.0.
194
194
  */
195
195
  startRun(parentId: string | null): void;
196
+ startRun(config: StartRunConfig): void;
196
197
  subscribe(callback: () => void): Unsubscribe;
197
198
  cancelRun(): void;
198
199
  getModelConfig(): ModelConfig;
@@ -286,8 +287,12 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
286
287
  return this._threadBinding.getState().getModelConfig();
287
288
  }
288
289
 
289
- public startRun(parentId: string | null) {
290
- return this._threadBinding.getState().startRun(parentId);
290
+ public startRun(configOrParentId: string | null | StartRunConfig) {
291
+ const config =
292
+ configOrParentId === null || typeof configOrParentId === "string"
293
+ ? { parentId: configOrParentId }
294
+ : configOrParentId;
295
+ return this._threadBinding.getState().startRun(config);
291
296
  }
292
297
 
293
298
  public cancelRun() {
@@ -9,7 +9,7 @@ import {
9
9
  ComposerRuntimeCore,
10
10
  ComposerRuntimeEventType,
11
11
  } from "../core/ComposerRuntimeCore";
12
- import { MessageRole } from "../../types/AssistantTypes";
12
+ import { MessageRole, RunConfig } from "../../types/AssistantTypes";
13
13
 
14
14
  const isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>
15
15
  a.status.type === "complete";
@@ -51,25 +51,44 @@ export abstract class BaseComposerRuntimeCore implements ComposerRuntimeCore {
51
51
  return this._role;
52
52
  }
53
53
 
54
+ private _runConfig: RunConfig = {};
55
+
56
+ get runConfig() {
57
+ return this._runConfig;
58
+ }
59
+
60
+ public setText(value: string) {
61
+ if (this._text === value) return;
62
+
63
+ this._text = value;
64
+ this.notifySubscribers();
65
+ }
66
+
54
67
  public setRole(role: MessageRole) {
68
+ if (this._role === role) return;
69
+
55
70
  this._role = role;
56
71
  this.notifySubscribers();
57
72
  }
58
73
 
59
- public setText(value: string) {
60
- this._text = value;
74
+ public setRunConfig(runConfig: RunConfig) {
75
+ if (this._runConfig === runConfig) return;
76
+
77
+ this._runConfig = runConfig;
61
78
  this.notifySubscribers();
62
79
  }
63
80
 
64
81
  private _resetInternal() {
82
+ // TODO attachmentAdapter.remove should be called here
83
+ this._attachments = [];
65
84
  this._text = "";
66
85
  this._role = "user";
67
- this._attachments = [];
86
+ this._runConfig = {};
68
87
  this.notifySubscribers();
69
88
  }
70
89
 
71
- public reset() {
72
- this._resetInternal();
90
+ public async reset() {
91
+ return this._resetInternal();
73
92
  }
74
93
 
75
94
  public async send() {
@@ -89,6 +108,7 @@ export abstract class BaseComposerRuntimeCore implements ComposerRuntimeCore {
89
108
  role: this.role,
90
109
  content: this.text ? [{ type: "text", text: this.text }] : [],
91
110
  attachments,
111
+ runConfig: this.runConfig,
92
112
  };
93
113
  this._resetInternal();
94
114
 
@@ -17,6 +17,7 @@ import {
17
17
  RuntimeCapabilities,
18
18
  SubmittedFeedback,
19
19
  ThreadRuntimeEventType,
20
+ StartRunConfig,
20
21
  } from "../core/ThreadRuntimeCore";
21
22
  import { DefaultEditComposerRuntimeCore } from "../composer/DefaultEditComposerRuntimeCore";
22
23
  import { SpeechSynthesisAdapter } from "../speech/SpeechAdapterTypes";
@@ -42,7 +43,7 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
42
43
 
43
44
  public abstract get capabilities(): RuntimeCapabilities;
44
45
  public abstract append(message: AppendMessage): void;
45
- public abstract startRun(parentId: string | null): void;
46
+ public abstract startRun(config: StartRunConfig): void;
46
47
  public abstract addToolResult(options: AddToolResultOptions): void;
47
48
  public abstract cancelRun(): void;
48
49
 
@@ -1,26 +1,29 @@
1
1
  import type { Attachment, PendingAttachment, Unsubscribe } from "../../types";
2
- import { MessageRole } from "../../types/AssistantTypes";
2
+ import { MessageRole, RunConfig } from "../../types/AssistantTypes";
3
3
 
4
4
  export type ComposerRuntimeEventType = "send";
5
5
 
6
6
  export type ComposerRuntimeCore = Readonly<{
7
+ isEditing: boolean;
8
+
9
+ canCancel: boolean;
10
+ isEmpty: boolean;
11
+
7
12
  attachments: readonly Attachment[];
8
13
 
9
14
  getAttachmentAccept(): string;
10
15
  addAttachment: (file: File) => Promise<void>;
11
16
  removeAttachment: (attachmentId: string) => Promise<void>;
12
17
 
13
- isEditing: boolean;
14
-
15
- canCancel: boolean;
16
- isEmpty: boolean;
17
-
18
18
  text: string;
19
19
  setText: (value: string) => void;
20
20
 
21
21
  role: MessageRole;
22
22
  setRole: (role: MessageRole) => void;
23
23
 
24
+ runConfig: RunConfig;
25
+ setRunConfig: (runConfig: RunConfig) => void;
26
+
24
27
  reset: () => void;
25
28
 
26
29
  send: () => void;
@@ -1,4 +1,5 @@
1
1
  import { AppendMessage, ModelConfig, ThreadMessage } from "../../types";
2
+ import { RunConfig } from "../../types/AssistantTypes";
2
3
  import type { Unsubscribe } from "../../types/Unsubscribe";
3
4
  import { SpeechSynthesisAdapter } from "../speech/SpeechAdapterTypes";
4
5
  import { ExportedMessageRepository } from "../utils/MessageRepository";
@@ -48,6 +49,11 @@ export type ThreadRuntimeEventType =
48
49
  | "initialize"
49
50
  | "model-config-update";
50
51
 
52
+ export type StartRunConfig = {
53
+ parentId: string | null;
54
+ runConfig?: RunConfig | undefined;
55
+ };
56
+
51
57
  export type ThreadRuntimeCore = Readonly<{
52
58
  getMessageById: (messageId: string) =>
53
59
  | {
@@ -60,7 +66,7 @@ export type ThreadRuntimeCore = Readonly<{
60
66
  switchToBranch: (branchId: string) => void;
61
67
 
62
68
  append: (message: AppendMessage) => void;
63
- startRun: (parentId: string | null) => void;
69
+ startRun: (config: StartRunConfig) => void;
64
70
  cancelRun: () => void;
65
71
 
66
72
  addToolResult: (options: AddToolResultOptions) => void;
@@ -2,6 +2,7 @@ import { AppendMessage, ThreadMessage } from "../../types";
2
2
  import { AttachmentAdapter } from "../attachment";
3
3
  import {
4
4
  AddToolResultOptions,
5
+ StartRunConfig,
5
6
  ThreadSuggestion,
6
7
  } from "../core/ThreadRuntimeCore";
7
8
  import { FeedbackAdapter } from "../feedback/FeedbackAdapter";
@@ -57,7 +58,9 @@ type ExternalStoreAdapterBase<T> = {
57
58
  setMessages?: ((messages: T[]) => void) | undefined;
58
59
  onNew: (message: AppendMessage) => Promise<void>;
59
60
  onEdit?: ((message: AppendMessage) => Promise<void>) | undefined;
60
- onReload?: ((parentId: string | null) => Promise<void>) | undefined;
61
+ onReload?: // TODO: remove parentId in 0.8.0
62
+ | ((parentId: string | null, config: StartRunConfig) => Promise<void>)
63
+ | undefined;
61
64
  onCancel?: (() => Promise<void>) | undefined;
62
65
  onAddToolResult?:
63
66
  | ((options: AddToolResultOptions) => Promise<void> | void)
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AddToolResultOptions,
3
+ StartRunConfig,
3
4
  ThreadSuggestion,
4
5
  } from "../core/ThreadRuntimeCore";
5
6
 
@@ -192,11 +193,11 @@ export class ExternalStoreThreadRuntimeCore
192
193
  }
193
194
  }
194
195
 
195
- public async startRun(parentId: string | null): Promise<void> {
196
+ public async startRun(config: StartRunConfig): Promise<void> {
196
197
  if (!this._store.onReload)
197
198
  throw new Error("Runtime does not support reloading messages.");
198
199
 
199
- await this._store.onReload(parentId);
200
+ await this._store.onReload(config.parentId, config);
200
201
  }
201
202
 
202
203
  public cancelRun(): void {
@@ -2,6 +2,7 @@
2
2
 
3
3
  import type {
4
4
  MessageStatus,
5
+ RunConfig,
5
6
  ThreadAssistantContentPart,
6
7
  ThreadMessage,
7
8
  ThreadStep,
@@ -24,6 +25,7 @@ export type ChatModelRunResult = {
24
25
 
25
26
  export type ChatModelRunOptions = {
26
27
  messages: ThreadMessage[];
28
+ runConfig: RunConfig;
27
29
  abortSignal: AbortSignal;
28
30
  config: ModelConfig;
29
31
 
@@ -12,8 +12,10 @@ import {
12
12
  AddToolResultOptions,
13
13
  ThreadSuggestion,
14
14
  ThreadRuntimeCore,
15
+ StartRunConfig,
15
16
  } from "../core/ThreadRuntimeCore";
16
17
  import { BaseThreadRuntimeCore } from "../core/BaseThreadRuntimeCore";
18
+ import { RunConfig } from "../../types/AssistantTypes";
17
19
 
18
20
  export class LocalThreadRuntimeCore
19
21
  extends BaseThreadRuntimeCore
@@ -49,6 +51,8 @@ export class LocalThreadRuntimeCore
49
51
 
50
52
  private _options!: LocalRuntimeOptionsBase;
51
53
 
54
+ private _lastRunConfig: RunConfig = {};
55
+
52
56
  public get extras() {
53
57
  return undefined;
54
58
  }
@@ -91,14 +95,20 @@ export class LocalThreadRuntimeCore
91
95
 
92
96
  const startRun = message.startRun ?? message.role === "user";
93
97
  if (startRun) {
94
- await this.startRun(newMessage.id);
98
+ await this.startRun({
99
+ parentId: newMessage.id,
100
+ runConfig: message.runConfig ?? {},
101
+ });
95
102
  } else {
96
103
  this.repository.resetHead(newMessage.id);
97
104
  this._notifySubscribers();
98
105
  }
99
106
  }
100
107
 
101
- public async startRun(parentId: string | null): Promise<void> {
108
+ public async startRun({
109
+ parentId,
110
+ runConfig,
111
+ }: StartRunConfig): Promise<void> {
102
112
  this.ensureInitialized();
103
113
 
104
114
  this.repository.resetHead(parentId);
@@ -117,13 +127,14 @@ export class LocalThreadRuntimeCore
117
127
  this._notifyEventSubscribers("run-start");
118
128
 
119
129
  do {
120
- message = await this.performRoundtrip(parentId, message);
130
+ message = await this.performRoundtrip(parentId, message, runConfig);
121
131
  } while (shouldContinue(message));
122
132
  }
123
133
 
124
134
  private async performRoundtrip(
125
135
  parentId: string | null,
126
136
  message: ThreadAssistantMessage,
137
+ runConfig: RunConfig | undefined,
127
138
  ) {
128
139
  const messages = this.repository.getMessages();
129
140
 
@@ -185,8 +196,10 @@ export class LocalThreadRuntimeCore
185
196
  }
186
197
 
187
198
  try {
199
+ this._lastRunConfig = runConfig ?? {};
188
200
  const promiseOrGenerator = this.adapters.chatModel.run({
189
201
  messages,
202
+ runConfig: this._lastRunConfig,
190
203
  abortSignal: this.abortController.signal,
191
204
  config: this.getModelConfig(),
192
205
  unstable_assistantMessageId: message.id,
@@ -267,7 +280,7 @@ export class LocalThreadRuntimeCore
267
280
  this.repository.addOrUpdateMessage(parentId, message);
268
281
 
269
282
  if (added && shouldContinue(message)) {
270
- this.performRoundtrip(parentId, message);
283
+ this.performRoundtrip(parentId, message, this._lastRunConfig);
271
284
  }
272
285
  }
273
286
  }
@@ -146,10 +146,17 @@ export type ThreadAssistantMessage = MessageCommonProps & {
146
146
  };
147
147
  };
148
148
 
149
+ export type RunConfig = {
150
+ // TODO allow user customization via global type overrides
151
+ custom?: unknown;
152
+ };
153
+
149
154
  export type AppendMessage = CoreMessage & {
150
155
  parentId: string | null;
151
156
  attachments: readonly CompleteAttachment[];
152
157
  startRun?: boolean | undefined;
158
+ /** TODO: make required in 0.8.0 */
159
+ runConfig?: RunConfig | undefined;
153
160
  };
154
161
 
155
162
  type BaseThreadMessage = {