@builder.io/ai-utils 0.3.21 → 0.3.23
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/README.md +3 -0
- package/package.json +1 -1
- package/src/codegen.ts +725 -0
- package/src/completion.ts +174 -0
- package/src/events.ts +485 -0
- package/src/mapping.ts +98 -0
- package/src/messages.ts +393 -0
- package/src/settings.ts +59 -0
- package/src/codegen.d.ts +0 -533
- package/src/codegen.js +0 -1
- package/src/completion.d.ts +0 -154
- package/src/completion.js +0 -1
- package/src/events.d.ts +0 -378
- package/src/events.js +0 -1
- package/src/index.js +0 -6
- package/src/mapping.d.ts +0 -86
- package/src/mapping.js +0 -1
- package/src/messages.d.ts +0 -261
- package/src/messages.js +0 -16
- package/src/settings.d.ts +0 -20
- package/src/settings.js +0 -30
- /package/src/{index.d.ts → index.ts} +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BuilderContent,
|
|
3
|
+
BuilderElement,
|
|
4
|
+
Component,
|
|
5
|
+
} from "@builder.io/sdk";
|
|
6
|
+
import type { Message, MessageParam, Attachment } from "./messages.js";
|
|
7
|
+
import type { BuilderModel } from "./events.js";
|
|
8
|
+
|
|
9
|
+
export type { BuilderContent, BuilderElement, Component };
|
|
10
|
+
|
|
11
|
+
export interface CompletionOptions {
|
|
12
|
+
/**
|
|
13
|
+
* How this assistant is being used. For example, "content-editor"
|
|
14
|
+
* is used when the assistant is being used in the Builder.io content editor.
|
|
15
|
+
*/
|
|
16
|
+
assistantType?: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* LLM Model identifier to lookup which sdk and model to use.
|
|
20
|
+
* If not provided the default model will be used.
|
|
21
|
+
* Note: This is not the Builder.io data model.
|
|
22
|
+
*/
|
|
23
|
+
modelId?: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The unique LOCAL identifier of the thread to submit the user message to.
|
|
27
|
+
* This is used to identify the thread with our own id (openai assistant id is different)
|
|
28
|
+
*/
|
|
29
|
+
id: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The unique OPENAI assistant id of the thread to submit the user message to.
|
|
33
|
+
* If the assistantThreadId is not provided, a new thread will be created.
|
|
34
|
+
*/
|
|
35
|
+
assistantThreadId?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The message history of the conversation, user prompt then assistant response.
|
|
39
|
+
* The messages are ordered from oldest to newest. The last message in the array
|
|
40
|
+
* is the message that the user has just sent.
|
|
41
|
+
*/
|
|
42
|
+
messages: (MessageParam | Message)[];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Which platform (framework) the the user has choosen to get help with.
|
|
46
|
+
*/
|
|
47
|
+
platformId?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The user id of the user sending the message.
|
|
51
|
+
* This is used to track the user's progress in the conversation.
|
|
52
|
+
* User id is stored in localStorage for this domain, its not the builder user id.
|
|
53
|
+
*/
|
|
54
|
+
userId: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The state of the builder editor.
|
|
58
|
+
*/
|
|
59
|
+
builderState?: BuilderEditorState;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Additional console logs
|
|
63
|
+
*/
|
|
64
|
+
debug?: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Date.now() timestamp of when the assistant was started.
|
|
68
|
+
* This is used to calculate the time taken between all events.
|
|
69
|
+
*/
|
|
70
|
+
startMs?: number;
|
|
71
|
+
/**
|
|
72
|
+
* If events should be streamed back throughout the process.
|
|
73
|
+
*
|
|
74
|
+
* Setting to `false` will skip any intermediate processing and emitting
|
|
75
|
+
* events while collecting LLM deltas, but will only emit the final result.
|
|
76
|
+
*
|
|
77
|
+
* Defaults to `true`.
|
|
78
|
+
*/
|
|
79
|
+
stream?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Provide a system prompt id to lookup a pre-defined system prompt
|
|
82
|
+
* text sent to the LLM. Must be a pre-defined system prompt id!
|
|
83
|
+
*/
|
|
84
|
+
systemPromptIds?: {
|
|
85
|
+
"content-edit"?: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Option on how this call should handle the conversation thread.
|
|
89
|
+
*
|
|
90
|
+
* `persist`:
|
|
91
|
+
* - When there is no CompletionOptions `id`, it'll create a new thread id
|
|
92
|
+
* - When given an existing `id`, it'll look up the past thread messages and prefix the messages
|
|
93
|
+
*
|
|
94
|
+
* `ephemeral`:
|
|
95
|
+
* - Creates a new conversation each time, ignoring any existing thread history
|
|
96
|
+
* - Will not save the conversation for future use
|
|
97
|
+
*
|
|
98
|
+
* Defaults to `persist`
|
|
99
|
+
*/
|
|
100
|
+
thread?: "persist" | "ephemeral";
|
|
101
|
+
|
|
102
|
+
attachments?: Attachment[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface BuilderEditorState {
|
|
106
|
+
/**
|
|
107
|
+
* The active locale of the builder editor.
|
|
108
|
+
*/
|
|
109
|
+
activeLocale?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The locale of the provided builder content.
|
|
112
|
+
*/
|
|
113
|
+
contentLocale?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Top level Builder content. The data.blocks array contains the BuilderElement.
|
|
116
|
+
*/
|
|
117
|
+
content?: BuilderContent;
|
|
118
|
+
/**
|
|
119
|
+
* Builder custom components.
|
|
120
|
+
*/
|
|
121
|
+
components?: Component[];
|
|
122
|
+
/**
|
|
123
|
+
* Builder design tokens.
|
|
124
|
+
*/
|
|
125
|
+
designTokens?: Record<string, string>;
|
|
126
|
+
/**
|
|
127
|
+
* Builder model. (not the LLM model)
|
|
128
|
+
*/
|
|
129
|
+
model?: BuilderModel;
|
|
130
|
+
/**
|
|
131
|
+
* Other models in the Builder account
|
|
132
|
+
*/
|
|
133
|
+
otherModels?: BuilderModel[];
|
|
134
|
+
/**
|
|
135
|
+
* The URL that the Builder content preview is pointing to.
|
|
136
|
+
*/
|
|
137
|
+
previewUrl?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Selected ids in the builder.
|
|
140
|
+
*/
|
|
141
|
+
selectedIds?: string[];
|
|
142
|
+
/**
|
|
143
|
+
* Builder space id.
|
|
144
|
+
*/
|
|
145
|
+
spaceId?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Builder user id.
|
|
148
|
+
*/
|
|
149
|
+
userId?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Email of the user in the builder.
|
|
152
|
+
*/
|
|
153
|
+
userEmail?: string;
|
|
154
|
+
/**
|
|
155
|
+
* User's jobs
|
|
156
|
+
*/
|
|
157
|
+
userJobs?: string[];
|
|
158
|
+
/**
|
|
159
|
+
* Builder session id.
|
|
160
|
+
*/
|
|
161
|
+
sessionId?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Custom instructions that could be add into the prompt.
|
|
164
|
+
*/
|
|
165
|
+
customInstructions?: Record<string, string>;
|
|
166
|
+
|
|
167
|
+
// A URL to use as design inspiration when generating content
|
|
168
|
+
styleInspirationURL?: string;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* All targeting attributes of the content.
|
|
172
|
+
*/
|
|
173
|
+
allTargetingAttributes?: Record<string, any>;
|
|
174
|
+
}
|
package/src/events.ts
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import type { BuilderContent, BuilderElement } from "@builder.io/sdk";
|
|
2
|
+
import type { AssistantMessage, AssistantMessageAction } from "./messages.js";
|
|
3
|
+
import type { AssistantSettings } from "./settings.js";
|
|
4
|
+
|
|
5
|
+
export type BuilderAssistantEventHandler = (ev: BuilderAssistantEvent) => void;
|
|
6
|
+
|
|
7
|
+
export type BuilderAssistantEvent =
|
|
8
|
+
| AssistantCompletionResultEvent
|
|
9
|
+
| AssistantErrorEvent
|
|
10
|
+
| AssistantStreamErrorEvent
|
|
11
|
+
| AppCloseEvent
|
|
12
|
+
| AppMessagesClickEvent
|
|
13
|
+
| AppMessagesGenerationEvent
|
|
14
|
+
| AppMessageEditCustomInstructionsEvent
|
|
15
|
+
| AppPromptAbortEvent
|
|
16
|
+
| AppPromptFocusEvent
|
|
17
|
+
| AppPromptSubmitEvent
|
|
18
|
+
| AppReadyEvent
|
|
19
|
+
| AppSettingsSetEvent
|
|
20
|
+
| AppThreadNewEvent
|
|
21
|
+
| AssistantStatsEvent
|
|
22
|
+
| AssistantThemeEvent
|
|
23
|
+
| BuilderEditorAuthEvent
|
|
24
|
+
| BuilderEditorStateEvent
|
|
25
|
+
| ContentUpdateEvent
|
|
26
|
+
| ContentApplySnapshotEvent
|
|
27
|
+
| ModelUndoEvent
|
|
28
|
+
| ModelRedoEvent
|
|
29
|
+
| ResultEvent
|
|
30
|
+
| ThreadCreatedEvent
|
|
31
|
+
| ThreadMessageCompletedEvent
|
|
32
|
+
| ThreadMessageCreatedEvent
|
|
33
|
+
| ThreadMessageDeltaEvent
|
|
34
|
+
| ThreadMessageFeedbackEvent
|
|
35
|
+
| ThreadRunStepCreatedEvent
|
|
36
|
+
| ThreadRunStepDeltaEvent
|
|
37
|
+
| AppAcceptChangeEvent
|
|
38
|
+
| AppAcceptRejectEvent
|
|
39
|
+
| AssistantTrackEvent
|
|
40
|
+
| AssistantEditorAuthMessage
|
|
41
|
+
| AppAttachmentTemplateEvent
|
|
42
|
+
| ThreadMessageRetryEvent
|
|
43
|
+
| AppFigmaImportEvent
|
|
44
|
+
| AppWebImportEvent
|
|
45
|
+
| AppAiTemplatesEvent
|
|
46
|
+
| AssistantContentInitialEvent
|
|
47
|
+
| ThreadMessageSummaryEvent
|
|
48
|
+
| AssistantHeartbeatEvent
|
|
49
|
+
| ShowUpgradeDialogEvent;
|
|
50
|
+
|
|
51
|
+
export interface AssistantCompletionResultEvent {
|
|
52
|
+
type: "assistant.result";
|
|
53
|
+
data: {
|
|
54
|
+
content?: BuilderContent;
|
|
55
|
+
stats?: AssistantStats;
|
|
56
|
+
};
|
|
57
|
+
resolveId?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface AssistantError {
|
|
61
|
+
message: string;
|
|
62
|
+
status?: number;
|
|
63
|
+
// any actions associated with the error such as a "new chat" button
|
|
64
|
+
actions?: AssistantMessageAction[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface AssistantErrorEvent {
|
|
68
|
+
type: "assistant.error";
|
|
69
|
+
data: AssistantError;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface AssistantStreamErrorEvent {
|
|
73
|
+
type: "assistant.stream.error";
|
|
74
|
+
data: AssistantError;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface AppFigmaImportEvent {
|
|
78
|
+
type: "assistant.app.figmaImport";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface AppWebImportEvent {
|
|
82
|
+
type: "assistant.app.webImport";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface AppAiTemplatesEvent {
|
|
86
|
+
type: "assistant.app.aiTemplates";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface AssistantTrackEvent {
|
|
90
|
+
type: "assistant.track";
|
|
91
|
+
data: {
|
|
92
|
+
name: string;
|
|
93
|
+
properties: Record<string, any>;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface AssistantThemeEvent {
|
|
98
|
+
type: "assistant.app.theme.update";
|
|
99
|
+
data: {
|
|
100
|
+
theme: string;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface AppCloseEvent {
|
|
105
|
+
type: "assistant.app.close";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface AppMessagesClickEvent {
|
|
109
|
+
type: "assistant.app.messages.click";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface ShowUpgradeDialogEvent {
|
|
113
|
+
type: "assistant.app.showUpgradeDialog";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface AppAcceptChangeEvent {
|
|
117
|
+
type: "assistant.app.change.accept";
|
|
118
|
+
}
|
|
119
|
+
export interface AppAcceptRejectEvent {
|
|
120
|
+
type: "assistant.app.change.reject";
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface AppMessageEditCustomInstructionsEvent {
|
|
124
|
+
type: "assistant.app.messages.editCustomInstructions";
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface AppAttachmentTemplateEvent {
|
|
128
|
+
type: "assistant.app.attachment.template";
|
|
129
|
+
data: {
|
|
130
|
+
id: number;
|
|
131
|
+
name: string;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface AppMessagesGenerationEvent {
|
|
136
|
+
type: "assistant.app.messages.generation";
|
|
137
|
+
data: {
|
|
138
|
+
state: GenerationState;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* idle: no messages are being generated or queued to be generated
|
|
144
|
+
*
|
|
145
|
+
* queued: messages have been sent to the LLM, but no response has been received yet
|
|
146
|
+
*
|
|
147
|
+
* generating: messages are actively being generated and streaming back to the UI
|
|
148
|
+
*/
|
|
149
|
+
export type GenerationState = "idle" | "queued" | "generating";
|
|
150
|
+
|
|
151
|
+
export interface AppPromptAbortEvent {
|
|
152
|
+
type: "assistant.app.prompt.abort";
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface AppPromptFocusEvent {
|
|
156
|
+
type: "assistant.app.prompt.focus";
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface AppPromptSubmitEvent {
|
|
160
|
+
type: "assistant.app.prompt.submit";
|
|
161
|
+
data: {
|
|
162
|
+
prompt: string;
|
|
163
|
+
attachments: any[];
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface AppReadyEvent {
|
|
168
|
+
type: "assistant.app.ready";
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface AppSettingsSetEvent {
|
|
172
|
+
type: "assistant.app.settings.set";
|
|
173
|
+
data: Partial<AssistantSettings>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface AppThreadNewEvent {
|
|
177
|
+
type: "assistant.app.thread.new";
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface AssistantEditorAuthMessage {
|
|
181
|
+
type: "assistant.editor.auth.update";
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface BuilderEditorAuthEvent extends AwaitResultEvent {
|
|
185
|
+
type: "assistant.editor.auth";
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface BuilderEditorStateEvent extends AwaitResultEvent {
|
|
189
|
+
type: "assistant.editor.state";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface AwaitResultEvent {
|
|
193
|
+
resolveId?: string;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface ResultEvent {
|
|
197
|
+
type: "assistant.result";
|
|
198
|
+
resolveId: string;
|
|
199
|
+
data: any;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface ContentCreatePatch {
|
|
203
|
+
parentId: string;
|
|
204
|
+
insertBeforeId: string;
|
|
205
|
+
element: BuilderElement;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface ContentApplySnapshot {
|
|
209
|
+
/**
|
|
210
|
+
* The id of the BuilderContent to apply the snapshot to
|
|
211
|
+
*/
|
|
212
|
+
id: string;
|
|
213
|
+
/**
|
|
214
|
+
* Each snapshot can be either a full BuilderContent or individual BuilderElements.
|
|
215
|
+
* Order matters, as the snapshots will be applied in the order they are listed.
|
|
216
|
+
* The builder app will handle the logic of applying the snapshots in the correct order
|
|
217
|
+
* and to the right content/elements.
|
|
218
|
+
*/
|
|
219
|
+
snapshots: (BuilderElement | BuilderContent)[];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface ContentApplySnapshotEvent {
|
|
223
|
+
type: "assistant.content.applysnapshot";
|
|
224
|
+
data: ContentApplySnapshot;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface ContentUpdateEvent {
|
|
228
|
+
type: "assistant.content.update";
|
|
229
|
+
data: ContentUpdatePatch[];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export type ContentUpdatePatch = ContentTsUpdateComponentPatch;
|
|
233
|
+
|
|
234
|
+
interface ContentPatchBase {
|
|
235
|
+
id: string;
|
|
236
|
+
nodeId?: string;
|
|
237
|
+
builderId?: string;
|
|
238
|
+
description?: string;
|
|
239
|
+
value: string;
|
|
240
|
+
displayValue?: string;
|
|
241
|
+
ts: number;
|
|
242
|
+
/**
|
|
243
|
+
* A change value is considered incomplete until we also parsed it's closing xml tag.
|
|
244
|
+
*/
|
|
245
|
+
incomplete?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* If there was an error applying the patch, this will contain the error message.
|
|
248
|
+
*/
|
|
249
|
+
error?: string;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* If `true`, Editor AI attempted to process this patch. It could be that the patch
|
|
253
|
+
* had invalid syntax or that the LLM made its changes incorrectly. This can be used
|
|
254
|
+
* to differentiate between a patch that is actively being streamed in, as indicated by
|
|
255
|
+
* the "incomplete" property, and a patch that is has finished streaming and is being
|
|
256
|
+
* processed.
|
|
257
|
+
*/
|
|
258
|
+
attemptedProcess?: boolean;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface ContentTsUpdateComponentPatch extends ContentPatchBase {
|
|
262
|
+
type: "update_component";
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface AssistantStatsEvent {
|
|
266
|
+
type: "assistant.stats";
|
|
267
|
+
data: AssistantStats;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface AssistantStats {
|
|
271
|
+
/**
|
|
272
|
+
* The unique id of the thread (not the openai threadId)
|
|
273
|
+
*/
|
|
274
|
+
threadId: string;
|
|
275
|
+
/**
|
|
276
|
+
* The unique id of the completion, which is a combination of the user's prompt and assistant's response.
|
|
277
|
+
*/
|
|
278
|
+
completionId: string;
|
|
279
|
+
/**
|
|
280
|
+
* The model id used to generate this completion.
|
|
281
|
+
*/
|
|
282
|
+
modelId: string;
|
|
283
|
+
/**
|
|
284
|
+
* The assistant's response message.
|
|
285
|
+
*/
|
|
286
|
+
assistantMessage: string;
|
|
287
|
+
/**
|
|
288
|
+
* The assistant's summary of what it did. This appears after assistantMessage
|
|
289
|
+
* as well as any changes it made.
|
|
290
|
+
*/
|
|
291
|
+
assistantSummary: string;
|
|
292
|
+
/**
|
|
293
|
+
* The user's prompt message.
|
|
294
|
+
*/
|
|
295
|
+
userMessage: string;
|
|
296
|
+
/**
|
|
297
|
+
* The index within the thread the assistant message is.
|
|
298
|
+
* For a first assistant message, the index will be 1 (the user message is index 0).
|
|
299
|
+
* For a second assistant message, the index will be 3 (the user message is index 2), and so on.
|
|
300
|
+
*/
|
|
301
|
+
assistantMessageIndex: number;
|
|
302
|
+
/**
|
|
303
|
+
* The timestamp (Date.now()) of when the user first submitted their prompt.
|
|
304
|
+
*/
|
|
305
|
+
userPromptMs: number;
|
|
306
|
+
/**
|
|
307
|
+
* The timestamp of the first assistant chunk in the response.
|
|
308
|
+
*/
|
|
309
|
+
firstChunkMs: number;
|
|
310
|
+
/**
|
|
311
|
+
* The timestamp of the last assistant chunk in the response.
|
|
312
|
+
*/
|
|
313
|
+
lastChunkMs: number;
|
|
314
|
+
/**
|
|
315
|
+
* The total number of chunks in the assistant's streamed response.
|
|
316
|
+
*/
|
|
317
|
+
chunkCount: number;
|
|
318
|
+
/**
|
|
319
|
+
* The total number of characters in the generated prompt sent to the LLM.
|
|
320
|
+
*/
|
|
321
|
+
promptLength: number;
|
|
322
|
+
/**
|
|
323
|
+
* The total number of characters in the assistant's response.
|
|
324
|
+
*/
|
|
325
|
+
completionLength: number;
|
|
326
|
+
/**
|
|
327
|
+
* If the user provided custom instructions for the prompt.
|
|
328
|
+
*/
|
|
329
|
+
hasCustomInstructions: boolean;
|
|
330
|
+
/**
|
|
331
|
+
* The deployed version.
|
|
332
|
+
*/
|
|
333
|
+
version: string;
|
|
334
|
+
/**
|
|
335
|
+
* Error message if there was one.
|
|
336
|
+
*/
|
|
337
|
+
errorMessage?: string;
|
|
338
|
+
/**
|
|
339
|
+
* Input tokens
|
|
340
|
+
*/
|
|
341
|
+
inputTokens?: number;
|
|
342
|
+
/**
|
|
343
|
+
* Output tokens
|
|
344
|
+
*/
|
|
345
|
+
outputTokens?: number;
|
|
346
|
+
/**
|
|
347
|
+
* Output tokens
|
|
348
|
+
*/
|
|
349
|
+
completionCost?: number;
|
|
350
|
+
/**
|
|
351
|
+
* Number of streamed snapshots
|
|
352
|
+
*/
|
|
353
|
+
streamedSnapshots?: number;
|
|
354
|
+
/**
|
|
355
|
+
* Number of cached input tokens
|
|
356
|
+
*/
|
|
357
|
+
cacheInputTokens?: number;
|
|
358
|
+
/**
|
|
359
|
+
* Number of cached created tokens
|
|
360
|
+
*/
|
|
361
|
+
cacheCreatedTokens?: number;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface ModelUndoEvent {
|
|
365
|
+
type: "assistant.model.undo";
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export interface ModelRedoEvent {
|
|
369
|
+
type: "assistant.model.redo";
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export interface BuilderModel {
|
|
373
|
+
name?: string;
|
|
374
|
+
friendlyName?: string;
|
|
375
|
+
description?: string;
|
|
376
|
+
type?: string;
|
|
377
|
+
fields?: BuilderModelField[];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export interface BuilderModelField {
|
|
381
|
+
name?: string;
|
|
382
|
+
type?: string;
|
|
383
|
+
description?: string;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export interface ThreadMessageFeedbackEvent {
|
|
387
|
+
type: "assistant.thread.message.feedback";
|
|
388
|
+
data: CompletionResponseFeedback;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export interface CompletionResponseFeedback {
|
|
392
|
+
userId: string;
|
|
393
|
+
builderUserId?: string;
|
|
394
|
+
builderEmail?: string;
|
|
395
|
+
responseId?: string;
|
|
396
|
+
frontendUrl: string | undefined;
|
|
397
|
+
frontendCommitId: string | undefined;
|
|
398
|
+
backendDomain?: string;
|
|
399
|
+
backendCommitId: string | undefined;
|
|
400
|
+
feedbackText: string;
|
|
401
|
+
sentiment?: "positive" | "negative";
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export interface ThreadCreatedEvent {
|
|
405
|
+
type: "assistant.thread.created";
|
|
406
|
+
data: ThreadCreated;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface ThreadCreated {
|
|
410
|
+
platformId: string;
|
|
411
|
+
threadId: string;
|
|
412
|
+
vectorStoreId: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export interface ThreadMessageCreatedEvent {
|
|
416
|
+
type: "assistant.thread.message.created";
|
|
417
|
+
data: ThreadMessageCreated;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export interface ThreadMessageCreated {
|
|
421
|
+
id: string;
|
|
422
|
+
responseId: string;
|
|
423
|
+
threadId: string;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface ThreadMessageDeltaEvent {
|
|
427
|
+
type: "assistant.thread.message.delta";
|
|
428
|
+
data: ThreadMessageDelta;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// use this event to keep a streaming connection alive
|
|
432
|
+
export interface AssistantHeartbeatEvent {
|
|
433
|
+
type: "assistant.heartbeat";
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface ThreadMessageDelta {
|
|
437
|
+
id: string;
|
|
438
|
+
text: string;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export interface ThreadMessageCompletedEvent {
|
|
442
|
+
type: "assistant.thread.message.completed";
|
|
443
|
+
data: ThreadMessageCompleted;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export interface ThreadMessageRetryEvent {
|
|
447
|
+
type: "assistant.thread.message.retry";
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export interface ThreadMessageSummaryEvent {
|
|
451
|
+
type: "assistant.thread.message.summary.delta";
|
|
452
|
+
data: ThreadMessageDelta;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export interface ThreadMessageCompleted extends AssistantMessage {
|
|
456
|
+
platformId: string;
|
|
457
|
+
threadId: string;
|
|
458
|
+
commitId?: string;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export interface ThreadRunStepDeltaEvent {
|
|
462
|
+
type: "assistant.thread.run.step.delta";
|
|
463
|
+
data: ThreadMessageStepDelta;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export interface ThreadMessageStepDelta {
|
|
467
|
+
delta: any;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export interface ThreadRunStepCreatedEvent {
|
|
471
|
+
type: "assistant.thread.run.step.created";
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export type DeepPartial<T> = T extends object
|
|
475
|
+
? {
|
|
476
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
477
|
+
}
|
|
478
|
+
: T;
|
|
479
|
+
|
|
480
|
+
export interface AssistantContentInitialEvent {
|
|
481
|
+
type: "assistant.content.initial";
|
|
482
|
+
data: {
|
|
483
|
+
code: string;
|
|
484
|
+
};
|
|
485
|
+
}
|