@intelliweave/embedded 1.8.64 → 1.9.66
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/dist/component/component.d.ts +270 -286
- package/dist/component/component.js +21 -19
- package/dist/intelliweave-wordpress.zip +0 -0
- package/dist/node/node.d.ts +728 -690
- package/dist/node/node.js +16 -14
- package/dist/react/react.d.ts +675 -693
- package/dist/react/react.js +21 -19
- package/dist/script-tag/script-tag.js +65 -42
- package/dist/webpack/index.d.ts +389 -351
- package/dist/webpack/index.js +23 -21
- package/package.json +4 -2
|
@@ -1,82 +1,100 @@
|
|
|
1
|
-
import { Optional } from 'utility-types';
|
|
2
1
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { Optional } from 'utility-types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Allows an MCP server to be used as a knowledge source for IntelliWeave.
|
|
6
6
|
*/
|
|
7
|
-
declare class
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
7
|
+
declare class MCPKnowledgeClient {
|
|
8
|
+
/** MCP client */
|
|
9
|
+
client?: Client;
|
|
10
|
+
/** All tools discovered on the MCP server. Only available after connect() has completed. */
|
|
11
|
+
tools: Awaited<ReturnType<Client['listTools']>>['tools'];
|
|
12
|
+
/** All toold discovered, mapped to IntelliWeave knowledge base actions */
|
|
13
|
+
iwActions: KnowledgeBaseItem[];
|
|
14
|
+
/** Statistics */
|
|
15
|
+
stats: {
|
|
16
|
+
toolsCalled: number;
|
|
17
|
+
};
|
|
18
|
+
/** Configuration */
|
|
19
|
+
config: {
|
|
20
|
+
/** Source ID */
|
|
21
|
+
id?: string;
|
|
22
|
+
/** URL to the MCP server endpoint */
|
|
23
|
+
baseURL?: string;
|
|
24
|
+
/** Custom connection function. If specified, baseURL is optional. */
|
|
25
|
+
connect?: () => Promise<Client>;
|
|
26
|
+
/**
|
|
27
|
+
* The name of the tool which provides knowledge searching. If specified, the search() will exclude this function and instead
|
|
28
|
+
* call it and show returned results. If not specified, the search() will just return all tools.
|
|
29
|
+
*/
|
|
30
|
+
searchToolName?: string;
|
|
31
|
+
/** Keep search function available for the AI to use. */
|
|
32
|
+
searchToolVisible?: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** Constructor */
|
|
35
|
+
constructor(config: MCPKnowledgeClient['config']);
|
|
36
|
+
/** In-progress connection attempt */
|
|
37
|
+
private connectionPromise?;
|
|
38
|
+
/** Connect to the client */
|
|
39
|
+
connect(): Promise<Client<{
|
|
40
|
+
method: string;
|
|
41
|
+
params?: {
|
|
42
|
+
[x: string]: unknown;
|
|
43
|
+
_meta?: {
|
|
44
|
+
[x: string]: unknown;
|
|
45
|
+
progressToken?: string | number | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
} | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
method: string;
|
|
50
|
+
params?: {
|
|
51
|
+
[x: string]: unknown;
|
|
52
|
+
_meta?: {
|
|
53
|
+
[x: string]: unknown;
|
|
54
|
+
} | undefined;
|
|
55
|
+
} | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
[x: string]: unknown;
|
|
58
|
+
_meta?: {
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
} | undefined;
|
|
61
|
+
}>>;
|
|
62
|
+
connectInternal(): Promise<Client<{
|
|
63
|
+
method: string;
|
|
64
|
+
params?: {
|
|
65
|
+
[x: string]: unknown;
|
|
66
|
+
_meta?: {
|
|
67
|
+
[x: string]: unknown;
|
|
68
|
+
progressToken?: string | number | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
} | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
method: string;
|
|
73
|
+
params?: {
|
|
74
|
+
[x: string]: unknown;
|
|
75
|
+
_meta?: {
|
|
76
|
+
[x: string]: unknown;
|
|
77
|
+
} | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
}, {
|
|
80
|
+
[x: string]: unknown;
|
|
81
|
+
_meta?: {
|
|
82
|
+
[x: string]: unknown;
|
|
83
|
+
} | undefined;
|
|
84
|
+
}>>;
|
|
85
|
+
/** Disconnect from server */
|
|
86
|
+
disconnect(): Promise<void>;
|
|
87
|
+
/** Fetch list of tools from the MCP server */
|
|
88
|
+
private fetchTools;
|
|
89
|
+
/** Cache last search result */
|
|
90
|
+
lastSearchQuery: string;
|
|
91
|
+
lastSearchResults: KnowledgeBaseItem[];
|
|
92
|
+
/** Perform a search query */
|
|
93
|
+
search(query: string): Promise<KnowledgeBaseItem[]>;
|
|
94
|
+
/** Perform search using the configured search function */
|
|
95
|
+
private performSearchCall;
|
|
96
|
+
/** Perform tool call. */
|
|
97
|
+
private performToolCall;
|
|
80
98
|
}
|
|
81
99
|
|
|
82
100
|
// ==================================================================================================
|
|
@@ -246,208 +264,6 @@ interface JSONSchema7 {
|
|
|
246
264
|
examples?: JSONSchema7Type | undefined;
|
|
247
265
|
}
|
|
248
266
|
|
|
249
|
-
/** ChatGPT config options */
|
|
250
|
-
interface ChatGPTConfig {
|
|
251
|
-
/** API key */
|
|
252
|
-
apiKey: string;
|
|
253
|
-
/** Provider ID */
|
|
254
|
-
providerID?: string;
|
|
255
|
-
/** Endpoint URL if using a custom URL */
|
|
256
|
-
endpoint: string;
|
|
257
|
-
/** LLM model to use */
|
|
258
|
-
model: string;
|
|
259
|
-
/** System message to describe to the AI how to behave. */
|
|
260
|
-
systemMessage: string;
|
|
261
|
-
/** User ID used to uniquely identify users in ChatGPT's API */
|
|
262
|
-
userID: string;
|
|
263
|
-
/** If true, streams the text responses from the API */
|
|
264
|
-
stream: boolean;
|
|
265
|
-
/** Amount of estimated tokens to keep when trimming */
|
|
266
|
-
maxTokens: number;
|
|
267
|
-
/** Callback before the AI sends info to the LLM */
|
|
268
|
-
onBeforeMessageProcessing?: () => void;
|
|
269
|
-
/** Callback when a message from the AI is returned. If isChunk is true, it may be incomplete and be called again with more updates. */
|
|
270
|
-
onAIMessage?: (text: string, isChunk: boolean) => void;
|
|
271
|
-
/** Callback when the AI starts performing an action */
|
|
272
|
-
onAIToolStart?: (toolName: string, input: any) => void;
|
|
273
|
-
}
|
|
274
|
-
/** ChatGPT tool config */
|
|
275
|
-
interface ChatGPTToolConfig {
|
|
276
|
-
/** Name of the tool */
|
|
277
|
-
name: string;
|
|
278
|
-
/** Description of the tool */
|
|
279
|
-
description: string;
|
|
280
|
-
/** Parameters for the tool */
|
|
281
|
-
params: JSONSchema7;
|
|
282
|
-
/** Callback function to process the tool */
|
|
283
|
-
callback: (params: any) => any;
|
|
284
|
-
/** If true, this tool call will be removed from the message history after it is executed. */
|
|
285
|
-
removeFromMessageHistory?: boolean;
|
|
286
|
-
/** If true, this item can be removed if there's not enough context available. */
|
|
287
|
-
canRemove?: boolean;
|
|
288
|
-
/** Misc app context */
|
|
289
|
-
[key: string]: any;
|
|
290
|
-
}
|
|
291
|
-
/** ChatGPT message */
|
|
292
|
-
interface ChatGPTMessage {
|
|
293
|
-
/** Role of the message */
|
|
294
|
-
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
295
|
-
/** Content of the message */
|
|
296
|
-
content: string;
|
|
297
|
-
/** Tool call ID */
|
|
298
|
-
tool_call_id?: string;
|
|
299
|
-
/** Tool calls made by the AI */
|
|
300
|
-
tool_calls?: any[];
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* API for interacting with ChatGPT APIs.
|
|
304
|
-
*/
|
|
305
|
-
declare class ChatGPT {
|
|
306
|
-
/** ID */
|
|
307
|
-
id: string;
|
|
308
|
-
/** Metadata */
|
|
309
|
-
metadata: any;
|
|
310
|
-
/** Config */
|
|
311
|
-
config: ChatGPTConfig;
|
|
312
|
-
/** The maximum tool calls in sequence the AI can make before an error is thrown. */
|
|
313
|
-
maxToolCallsPerMessage: number;
|
|
314
|
-
/** Statistics */
|
|
315
|
-
stats: {
|
|
316
|
-
/** Total tokens used this session */
|
|
317
|
-
tokensUsed: number;
|
|
318
|
-
};
|
|
319
|
-
/** Token window management */
|
|
320
|
-
tokenWindow: TokenWindow;
|
|
321
|
-
/** Token window group used for the context message */
|
|
322
|
-
get contextGroup(): TokenWindowGroup<any>;
|
|
323
|
-
/** Token window group used for tools / actions */
|
|
324
|
-
get toolGroup(): TokenWindowGroup<ChatGPTToolConfig>;
|
|
325
|
-
/** Token window group used for messages */
|
|
326
|
-
get messageGroup(): TokenWindowGroup<ChatGPTMessage>;
|
|
327
|
-
/** Constructor */
|
|
328
|
-
constructor(config: ChatGPTConfig);
|
|
329
|
-
/** Send a message, and get the response */
|
|
330
|
-
sendMessage(message: string): Promise<string>;
|
|
331
|
-
/** Insert a message as if the assistant has written it */
|
|
332
|
-
addAssistantMessage(message: string): void;
|
|
333
|
-
/** Insert a message sent from a user. Note that doing this instead of using `sendMessage()` means you'll need to manually call `await processMessages()` and then `getLatestMessage()` to get the response. */
|
|
334
|
-
addUserMessage(message: string): void;
|
|
335
|
-
/** Get all messages */
|
|
336
|
-
getMessages(): ChatGPTMessage[];
|
|
337
|
-
/** Get latest message */
|
|
338
|
-
getLatestMessage(): ChatGPTMessage | undefined;
|
|
339
|
-
/** @private Process messages in the chat history */
|
|
340
|
-
processMessages(): Promise<void>;
|
|
341
|
-
/** Trim message list */
|
|
342
|
-
trimMessages(): Promise<void>;
|
|
343
|
-
/** @private Send message list to the API and store the response */
|
|
344
|
-
sendToAPI(generatePayloadOnly?: boolean): Promise<any>;
|
|
345
|
-
/** Process incoming message from the AI. Can be used to respond to encoded actions in the text response. */
|
|
346
|
-
processIncomingMessage(message: string): void;
|
|
347
|
-
/** Register a tool. */
|
|
348
|
-
registerTool(tool: ChatGPTToolConfig): void;
|
|
349
|
-
/** @private Process a tool call request from the AI */
|
|
350
|
-
processToolCall(toolCall: any): Promise<void>;
|
|
351
|
-
/** Reset the conversation */
|
|
352
|
-
resetConversation(): void;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Allows an MCP server to be used as a knowledge source for IntelliWeave.
|
|
357
|
-
*/
|
|
358
|
-
declare class MCPKnowledgeClient {
|
|
359
|
-
/** MCP client */
|
|
360
|
-
client?: Client;
|
|
361
|
-
/** All tools discovered on the MCP server. Only available after connect() has completed. */
|
|
362
|
-
tools: Awaited<ReturnType<Client['listTools']>>['tools'];
|
|
363
|
-
/** All toold discovered, mapped to IntelliWeave knowledge base actions */
|
|
364
|
-
iwActions: KnowledgeBaseItem[];
|
|
365
|
-
/** Statistics */
|
|
366
|
-
stats: {
|
|
367
|
-
toolsCalled: number;
|
|
368
|
-
};
|
|
369
|
-
/** Configuration */
|
|
370
|
-
config: {
|
|
371
|
-
/** Source ID */
|
|
372
|
-
id?: string;
|
|
373
|
-
/** URL to the MCP server endpoint */
|
|
374
|
-
baseURL?: string;
|
|
375
|
-
/** Custom connection function. If specified, baseURL is optional. */
|
|
376
|
-
connect?: () => Promise<Client>;
|
|
377
|
-
/**
|
|
378
|
-
* The name of the tool which provides knowledge searching. If specified, the search() will exclude this function and instead
|
|
379
|
-
* call it and show returned results. If not specified, the search() will just return all tools.
|
|
380
|
-
*/
|
|
381
|
-
searchToolName?: string;
|
|
382
|
-
/** Keep search function available for the AI to use. */
|
|
383
|
-
searchToolVisible?: boolean;
|
|
384
|
-
};
|
|
385
|
-
/** Constructor */
|
|
386
|
-
constructor(config: MCPKnowledgeClient['config']);
|
|
387
|
-
/** In-progress connection attempt */
|
|
388
|
-
private connectionPromise?;
|
|
389
|
-
/** Connect to the client */
|
|
390
|
-
connect(): Promise<Client<{
|
|
391
|
-
method: string;
|
|
392
|
-
params?: {
|
|
393
|
-
[x: string]: unknown;
|
|
394
|
-
_meta?: {
|
|
395
|
-
[x: string]: unknown;
|
|
396
|
-
progressToken?: string | number | undefined;
|
|
397
|
-
} | undefined;
|
|
398
|
-
} | undefined;
|
|
399
|
-
}, {
|
|
400
|
-
method: string;
|
|
401
|
-
params?: {
|
|
402
|
-
[x: string]: unknown;
|
|
403
|
-
_meta?: {
|
|
404
|
-
[x: string]: unknown;
|
|
405
|
-
} | undefined;
|
|
406
|
-
} | undefined;
|
|
407
|
-
}, {
|
|
408
|
-
[x: string]: unknown;
|
|
409
|
-
_meta?: {
|
|
410
|
-
[x: string]: unknown;
|
|
411
|
-
} | undefined;
|
|
412
|
-
}>>;
|
|
413
|
-
connectInternal(): Promise<Client<{
|
|
414
|
-
method: string;
|
|
415
|
-
params?: {
|
|
416
|
-
[x: string]: unknown;
|
|
417
|
-
_meta?: {
|
|
418
|
-
[x: string]: unknown;
|
|
419
|
-
progressToken?: string | number | undefined;
|
|
420
|
-
} | undefined;
|
|
421
|
-
} | undefined;
|
|
422
|
-
}, {
|
|
423
|
-
method: string;
|
|
424
|
-
params?: {
|
|
425
|
-
[x: string]: unknown;
|
|
426
|
-
_meta?: {
|
|
427
|
-
[x: string]: unknown;
|
|
428
|
-
} | undefined;
|
|
429
|
-
} | undefined;
|
|
430
|
-
}, {
|
|
431
|
-
[x: string]: unknown;
|
|
432
|
-
_meta?: {
|
|
433
|
-
[x: string]: unknown;
|
|
434
|
-
} | undefined;
|
|
435
|
-
}>>;
|
|
436
|
-
/** Disconnect from server */
|
|
437
|
-
disconnect(): Promise<void>;
|
|
438
|
-
/** Fetch list of tools from the MCP server */
|
|
439
|
-
private fetchTools;
|
|
440
|
-
/** Cache last search result */
|
|
441
|
-
lastSearchQuery: string;
|
|
442
|
-
lastSearchResults: KnowledgeBaseItem[];
|
|
443
|
-
/** Perform a search query */
|
|
444
|
-
search(query: string): Promise<KnowledgeBaseItem[]>;
|
|
445
|
-
/** Perform search using the configured search function */
|
|
446
|
-
private performSearchCall;
|
|
447
|
-
/** Perform tool call. */
|
|
448
|
-
private performToolCall;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
267
|
/**
|
|
452
268
|
* Register knowledge base sources and perform searches.
|
|
453
269
|
*/
|
|
@@ -635,7 +451,7 @@ declare class VoiceDetectionNode extends PCMReceiverNode {
|
|
|
635
451
|
/** Loaded VAD model */
|
|
636
452
|
private vad?;
|
|
637
453
|
/** Sample rate */
|
|
638
|
-
get sampleRate():
|
|
454
|
+
get sampleRate(): 16000 | 8000;
|
|
639
455
|
/** Number of samples */
|
|
640
456
|
get numberOfSamples(): number;
|
|
641
457
|
/** Number of sample chunks */
|
|
@@ -866,12 +682,179 @@ interface IntelliWeaveInstructConfig {
|
|
|
866
682
|
callback?: (txt: string) => void;
|
|
867
683
|
}
|
|
868
684
|
|
|
685
|
+
/**
|
|
686
|
+
* This class helps organize groups of tokenized text along with removing items when the window is full.
|
|
687
|
+
*/
|
|
688
|
+
declare class TokenWindow {
|
|
689
|
+
/** Token window size */
|
|
690
|
+
size: number;
|
|
691
|
+
/** Token groups */
|
|
692
|
+
groups: TokenWindowGroup<any>[];
|
|
693
|
+
/** Create a new group */
|
|
694
|
+
createGroup(id: string): TokenWindowGroup<unknown>;
|
|
695
|
+
/** Get a group */
|
|
696
|
+
group<CustomDataType>(id: string): TokenWindowGroup<CustomDataType> | undefined;
|
|
697
|
+
/** Calculate current tokens in all groups */
|
|
698
|
+
countTokens(): number;
|
|
699
|
+
/** Remove overflow from all groups. */
|
|
700
|
+
removeOverflow(): void;
|
|
701
|
+
/** Remove one overflow item. Returns null if no items were able to be removed. */
|
|
702
|
+
private removeOneItem;
|
|
703
|
+
}
|
|
704
|
+
/** A token group. */
|
|
705
|
+
declare class TokenWindowGroup<CustomDataType> {
|
|
706
|
+
/** Group ID */
|
|
707
|
+
id: string;
|
|
708
|
+
/** List of items */
|
|
709
|
+
items: TokenWindowGroupItem<CustomDataType>[];
|
|
710
|
+
/**
|
|
711
|
+
* Weight controls how many items from this group should be kept in relation to the entire window. For example if all
|
|
712
|
+
* groups have a weight of 1, each group remove items equally if full. If one has a weight of 2 while the rest are 1,
|
|
713
|
+
* that group will be allowed to keep double the amount of items.
|
|
714
|
+
*/
|
|
715
|
+
weight: number;
|
|
716
|
+
/** Current total token count, computed automatically. Don't update this value manually. */
|
|
717
|
+
tokenCount: number;
|
|
718
|
+
/** Group item separator */
|
|
719
|
+
separator: string;
|
|
720
|
+
/** Token count padding added to each item. */
|
|
721
|
+
private itemPadding;
|
|
722
|
+
/** Sets the token count padding added to each item. Useful if you don't know exactly what will be added by the LLM host. */
|
|
723
|
+
setItemPadding(padding: number): this;
|
|
724
|
+
/** Sort function */
|
|
725
|
+
private sortFunction;
|
|
726
|
+
/** Set sort function */
|
|
727
|
+
sortBy(sortFunction: (a: TokenWindowGroupItem<CustomDataType>, b: TokenWindowGroupItem<CustomDataType>) => number): this;
|
|
728
|
+
/** Set separator */
|
|
729
|
+
setSeparator(separator: string): this;
|
|
730
|
+
/** Set weight */
|
|
731
|
+
setWeight(weight: number): this;
|
|
732
|
+
/** Recalculate all tokens. Note this may take a while. */
|
|
733
|
+
recalculateTokens(): void;
|
|
734
|
+
/** Add an item to the group */
|
|
735
|
+
add(item: string | Omit<Optional<TokenWindowGroupItem<CustomDataType>, 'id' | 'dateAdded' | 'sortOrder'>, 'tokenCount'>): TokenWindowGroupItem<CustomDataType>;
|
|
736
|
+
/** Get all items as a string */
|
|
737
|
+
getAllAsString(): string;
|
|
738
|
+
/** Get all items. Doesn't return disabled items. */
|
|
739
|
+
getAll(): TokenWindowGroupItem<CustomDataType>[];
|
|
740
|
+
/** Remove all items from this group */
|
|
741
|
+
empty(): void;
|
|
742
|
+
}
|
|
743
|
+
/** Token group item */
|
|
744
|
+
interface TokenWindowGroupItem<CustomDataType> {
|
|
745
|
+
/** Each item must have a unique ID. */
|
|
746
|
+
id: string;
|
|
747
|
+
/** The string content of the item */
|
|
748
|
+
content: string;
|
|
749
|
+
/** True if this item should never be removed */
|
|
750
|
+
cannotRemove?: boolean;
|
|
751
|
+
/** Sorting order. If not specified, uses dateAdded instead. */
|
|
752
|
+
sortOrder: number;
|
|
753
|
+
/** Date this item was added */
|
|
754
|
+
dateAdded: number;
|
|
755
|
+
/** Token count in the content */
|
|
756
|
+
tokenCount: number;
|
|
757
|
+
/** Anything to attach to this item */
|
|
758
|
+
customData?: CustomDataType;
|
|
759
|
+
/** If disabled, this item will not be included and will not add tot he token count. */
|
|
760
|
+
disabled?: boolean;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** Chat config options */
|
|
764
|
+
interface ChatBaseConfig {
|
|
765
|
+
/** API key */
|
|
766
|
+
apiKey: string;
|
|
767
|
+
/** Provider ID */
|
|
768
|
+
providerID?: string;
|
|
769
|
+
/** Endpoint URL if using a custom URL */
|
|
770
|
+
endpoint: string;
|
|
771
|
+
/** LLM model to use */
|
|
772
|
+
model: string;
|
|
773
|
+
/** System message to describe to the AI how to behave. */
|
|
774
|
+
systemMessage: string;
|
|
775
|
+
/** User ID used to uniquely identify users in ChatGPT's API */
|
|
776
|
+
userID: string;
|
|
777
|
+
/** If true, streams the text responses from the API */
|
|
778
|
+
stream: boolean;
|
|
779
|
+
/** Amount of estimated tokens to keep when trimming */
|
|
780
|
+
maxTokens: number;
|
|
781
|
+
/** Callback before the AI sends info to the LLM */
|
|
782
|
+
onBeforeMessageProcessing?: () => void;
|
|
783
|
+
/** Callback when a message from the AI is returned. If isChunk is true, it may be incomplete and be called again with more updates. */
|
|
784
|
+
onAIMessage?: (text: string, isChunk: boolean) => void;
|
|
785
|
+
/** Callback when the AI starts performing an action */
|
|
786
|
+
onAIToolStart?: (toolName: string, input: any) => void;
|
|
787
|
+
}
|
|
788
|
+
/** Chat tool config */
|
|
789
|
+
interface ChatBaseToolConfig {
|
|
790
|
+
/** Name of the tool, eg "perform_search" */
|
|
791
|
+
name: string;
|
|
792
|
+
/** Description of the tool */
|
|
793
|
+
description: string;
|
|
794
|
+
/** Parameters for the tool */
|
|
795
|
+
params: JSONSchema7;
|
|
796
|
+
/** Callback function to process the tool */
|
|
797
|
+
callback: (params: any) => any;
|
|
798
|
+
/** If true, this tool call will be removed from the message history after it is executed. */
|
|
799
|
+
removeFromMessageHistory?: boolean;
|
|
800
|
+
/** If true, this item can be removed if there's not enough context available. */
|
|
801
|
+
canRemove?: boolean;
|
|
802
|
+
/** Misc app context */
|
|
803
|
+
[key: string]: any;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* API for interacting with chat APIs.
|
|
807
|
+
*/
|
|
808
|
+
declare class ChatBase<
|
|
809
|
+
/** Format for messages in the token window */
|
|
810
|
+
MessageFormat = any,
|
|
811
|
+
/** Optional extended config */
|
|
812
|
+
ConfigFormat extends ChatBaseConfig = ChatBaseConfig> {
|
|
813
|
+
/** ID */
|
|
814
|
+
id: string;
|
|
815
|
+
/** Metadata */
|
|
816
|
+
metadata: any;
|
|
817
|
+
/** Config */
|
|
818
|
+
config: ConfigFormat;
|
|
819
|
+
/** The maximum tool calls in sequence the AI can make before an error is thrown. */
|
|
820
|
+
maxToolCallsPerMessage: number;
|
|
821
|
+
/** Statistics */
|
|
822
|
+
stats: {
|
|
823
|
+
/** Total tokens used this session */
|
|
824
|
+
tokensUsed: number;
|
|
825
|
+
};
|
|
826
|
+
/** Token window management */
|
|
827
|
+
tokenWindow: TokenWindow;
|
|
828
|
+
/** Token window group used for the context message */
|
|
829
|
+
get contextGroup(): TokenWindowGroup<any>;
|
|
830
|
+
/** Token window group used for tools / actions */
|
|
831
|
+
get toolGroup(): TokenWindowGroup<ChatBaseToolConfig>;
|
|
832
|
+
/** Token window group used for messages */
|
|
833
|
+
get messageGroup(): TokenWindowGroup<MessageFormat>;
|
|
834
|
+
/** Constructor */
|
|
835
|
+
constructor(config: ConfigFormat);
|
|
836
|
+
/** Send a message, and get the response */
|
|
837
|
+
sendMessage(message: string): Promise<string>;
|
|
838
|
+
/** Add a user message to the message history */
|
|
839
|
+
addUserMessage(message: string): void;
|
|
840
|
+
/** Add an assistant message to the message history */
|
|
841
|
+
addAssistantMessage(message: string): void;
|
|
842
|
+
/** Process incoming message from the AI. Can be used to respond to encoded actions in the text response. */
|
|
843
|
+
onBeforeIncomingMessage(message: MessageFormat): void;
|
|
844
|
+
/** Reset the conversation */
|
|
845
|
+
resetConversation(): void;
|
|
846
|
+
/** Trim message list */
|
|
847
|
+
trimMessages(): Promise<void>;
|
|
848
|
+
/** Register a tool. */
|
|
849
|
+
registerTool(tool: ChatBaseToolConfig): TokenWindowGroupItem<ChatBaseToolConfig>;
|
|
850
|
+
}
|
|
851
|
+
|
|
869
852
|
/** Persona config received from the hub */
|
|
870
853
|
interface WebWeaverGPTConfig {
|
|
871
854
|
/** ID */
|
|
872
855
|
id: string;
|
|
873
|
-
/**
|
|
874
|
-
model:
|
|
856
|
+
/** Chat API config */
|
|
857
|
+
model: ChatBaseConfig;
|
|
875
858
|
/** If true, message history will be sent to the IntelliWeave hub for analysis */
|
|
876
859
|
analytics?: boolean;
|
|
877
860
|
/** Persona name */
|
|
@@ -918,7 +901,7 @@ interface WebWeaverGPTConfig {
|
|
|
918
901
|
* - event `webweaver_loaded` - Fired when the AI is loaded with a new configuration. This is a global event that is fired on the window object.
|
|
919
902
|
* - event `webweaver_error` - Fired when an error occurs during loading. This is a global event that is fired on the window object.
|
|
920
903
|
* - event `input` - Fired when the user sends a message to the AI.
|
|
921
|
-
* - event `output` - Fired when the AI sends a message back to the user. If `event.detail.isChunk` is true, the message is incomplete and will be followed by more
|
|
904
|
+
* - event `output` - Fired when the AI sends a message back to the user. If `event.detail.isChunk` is true, the message is incomplete and will be followed by more events.
|
|
922
905
|
* - event `toolstart` - Fired when the AI starts performing an action.
|
|
923
906
|
* - event `tool` - Fired when the AI finishes performing an action.
|
|
924
907
|
*/
|
|
@@ -928,7 +911,7 @@ declare class IntelliWeave extends EventTarget {
|
|
|
928
911
|
/** Callback when a message from the AI is returned. If isChunk is true, it may be incomplete and be called again with more updates. */
|
|
929
912
|
onAIMessage?: (text: string, isChunk: boolean) => void;
|
|
930
913
|
/** Callback when the AI starts performing an action */
|
|
931
|
-
onAIToolStart?:
|
|
914
|
+
onAIToolStart?: ChatBaseConfig['onAIToolStart'];
|
|
932
915
|
/** Current conversation ID */
|
|
933
916
|
conversationID: string;
|
|
934
917
|
/** Knowledge database interface */
|
|
@@ -944,11 +927,11 @@ declare class IntelliWeave extends EventTarget {
|
|
|
944
927
|
/** Available LLMs */
|
|
945
928
|
models: {
|
|
946
929
|
id: string;
|
|
947
|
-
config:
|
|
930
|
+
config: ChatBaseConfig;
|
|
948
931
|
priority?: number;
|
|
949
932
|
}[];
|
|
950
933
|
/** Current LLM */
|
|
951
|
-
currentModel?:
|
|
934
|
+
currentModel?: ChatBase;
|
|
952
935
|
/** The audio system. Set this to a new instance of AudioSystem to enable audio support */
|
|
953
936
|
audio: AudioSystem | null;
|
|
954
937
|
/** Silero VAD model blob */
|
|
@@ -978,7 +961,6 @@ declare class IntelliWeave extends EventTarget {
|
|
|
978
961
|
getContextPrefix(): Promise<string>;
|
|
979
962
|
/** Get system message to send to the AI */
|
|
980
963
|
onBeforeMessageProcessing(): Promise<void>;
|
|
981
|
-
private _lastOutput?;
|
|
982
964
|
/** @private Process incoming message from the AI. Can be used to respond to encoded actions in the text response. */
|
|
983
965
|
processIncomingMessage(message: string, isChunk?: boolean): void;
|
|
984
966
|
/** True if currently processing a message */
|
|
@@ -999,7 +981,7 @@ declare class IntelliWeave extends EventTarget {
|
|
|
999
981
|
exportState(): {
|
|
1000
982
|
type: string;
|
|
1001
983
|
conversationID: string;
|
|
1002
|
-
messages:
|
|
984
|
+
messages: any[] | undefined;
|
|
1003
985
|
};
|
|
1004
986
|
/** Import conversation state from JSON */
|
|
1005
987
|
importState(state: any): void;
|
|
@@ -1106,6 +1088,8 @@ declare class WebWeaverEmbed extends BaseComponent {
|
|
|
1106
1088
|
resetConversation(): void;
|
|
1107
1089
|
/** True if busy processing */
|
|
1108
1090
|
private _isProcessing;
|
|
1091
|
+
/** The element which will receive the current message from the AI */
|
|
1092
|
+
currentOutputElement?: HTMLElement;
|
|
1109
1093
|
/** Process input text from the user */
|
|
1110
1094
|
processInput(inputText: string): Promise<void>;
|
|
1111
1095
|
/** Called when the AI responds with some text */
|