@intelliweave/embedded 1.6.55 → 1.7.57
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/.github/workflows/test-pr.yml +31 -0
- package/dist/component/component.d.ts +111 -7
- package/dist/component/component.js +28 -27
- package/dist/intelliweave-wordpress.zip +0 -0
- package/dist/node/node.d.ts +111 -8
- package/dist/node/node.js +14 -14
- package/dist/react/react.d.ts +110 -7
- package/dist/react/react.js +24 -23
- package/dist/script-tag/chunk-AIYMQX7V.js +1 -0
- package/dist/script-tag/{ort.bundle.min-5QOPZPPI.js → ort.bundle.min-IUPKB45H.js} +1 -1
- package/dist/script-tag/script-tag.js +3289 -46
- package/dist/webpack/index.d.ts +111 -8
- package/dist/webpack/index.js +25 -24
- package/package.json +3 -1
- package/dist/script-tag/chunk-FSRPMVAS.js +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#
|
|
2
|
+
# This action tests a PR by attempting to build the app.
|
|
3
|
+
|
|
4
|
+
name: Test
|
|
5
|
+
|
|
6
|
+
# Run on any branch
|
|
7
|
+
on:
|
|
8
|
+
workflow_dispatch: # <-- Allows you to manually trigger the workflow
|
|
9
|
+
pull_request: # <-- Run on PRs
|
|
10
|
+
|
|
11
|
+
# Set permissions to read only
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
pull-requests: write
|
|
15
|
+
|
|
16
|
+
# Build job
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
- name: Setup Node
|
|
24
|
+
uses: actions/setup-node@v4
|
|
25
|
+
with:
|
|
26
|
+
node-version: "22"
|
|
27
|
+
cache: npm
|
|
28
|
+
- name: Install dependencies
|
|
29
|
+
run: npm install
|
|
30
|
+
- name: Build
|
|
31
|
+
run: npm run test
|
|
@@ -1,3 +1,83 @@
|
|
|
1
|
+
import { Optional } from 'utility-types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This class helps organize groups of tokenized text along with removing items when the window is full.
|
|
5
|
+
*/
|
|
6
|
+
declare class TokenWindow {
|
|
7
|
+
/** Token window size */
|
|
8
|
+
size: number;
|
|
9
|
+
/** Token groups */
|
|
10
|
+
groups: TokenWindowGroup<any>[];
|
|
11
|
+
/** Create a new group */
|
|
12
|
+
createGroup(id: string): TokenWindowGroup<unknown>;
|
|
13
|
+
/** Get a group */
|
|
14
|
+
group<CustomDataType>(id: string): TokenWindowGroup<CustomDataType> | undefined;
|
|
15
|
+
/** Calculate current tokens in all groups */
|
|
16
|
+
countTokens(): number;
|
|
17
|
+
/** Remove overflow from all groups. */
|
|
18
|
+
removeOverflow(): void;
|
|
19
|
+
/** Remove one overflow item. Returns null if no items were able to be removed. */
|
|
20
|
+
private removeOneItem;
|
|
21
|
+
}
|
|
22
|
+
/** A token group. */
|
|
23
|
+
declare class TokenWindowGroup<CustomDataType> {
|
|
24
|
+
/** Group ID */
|
|
25
|
+
id: string;
|
|
26
|
+
/** List of items */
|
|
27
|
+
items: TokenWindowGroupItem<CustomDataType>[];
|
|
28
|
+
/**
|
|
29
|
+
* Weight controls how many items from this group should be kept in relation to the entire window. For example if all
|
|
30
|
+
* 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,
|
|
31
|
+
* that group will be allowed to keep double the amount of items.
|
|
32
|
+
*/
|
|
33
|
+
weight: number;
|
|
34
|
+
/** Current total token count, computed automatically. Don't update this value manually. */
|
|
35
|
+
tokenCount: number;
|
|
36
|
+
/** Group item separator */
|
|
37
|
+
separator: string;
|
|
38
|
+
/** Token count padding added to each item. */
|
|
39
|
+
private itemPadding;
|
|
40
|
+
/** Sets the token count padding added to each item. Useful if you don't know exactly what will be added by the LLM host. */
|
|
41
|
+
setItemPadding(padding: number): this;
|
|
42
|
+
/** Sort function */
|
|
43
|
+
private sortFunction;
|
|
44
|
+
/** Set sort function */
|
|
45
|
+
sortBy(sortFunction: (a: TokenWindowGroupItem<CustomDataType>, b: TokenWindowGroupItem<CustomDataType>) => number): this;
|
|
46
|
+
/** Set separator */
|
|
47
|
+
setSeparator(separator: string): this;
|
|
48
|
+
/** Set weight */
|
|
49
|
+
setWeight(weight: number): this;
|
|
50
|
+
/** Recalculate all tokens. Note this may take a while. */
|
|
51
|
+
recalculateTokens(): void;
|
|
52
|
+
/** Add an item to the group */
|
|
53
|
+
add(item: string | Omit<Optional<TokenWindowGroupItem<CustomDataType>, 'id' | 'dateAdded' | 'sortOrder'>, 'tokenCount'>): TokenWindowGroupItem<CustomDataType>;
|
|
54
|
+
/** Get all items as a string */
|
|
55
|
+
getAllAsString(): string;
|
|
56
|
+
/** Get all items. Doesn't return disabled items. */
|
|
57
|
+
getAll(): TokenWindowGroupItem<CustomDataType>[];
|
|
58
|
+
/** Remove all items from this group */
|
|
59
|
+
empty(): void;
|
|
60
|
+
}
|
|
61
|
+
/** Token group item */
|
|
62
|
+
interface TokenWindowGroupItem<CustomDataType> {
|
|
63
|
+
/** Each item must have a unique ID. */
|
|
64
|
+
id: string;
|
|
65
|
+
/** The string content of the item */
|
|
66
|
+
content: string;
|
|
67
|
+
/** True if this item should never be removed */
|
|
68
|
+
cannotRemove?: boolean;
|
|
69
|
+
/** Sorting order. If not specified, uses dateAdded instead. */
|
|
70
|
+
sortOrder: number;
|
|
71
|
+
/** Date this item was added */
|
|
72
|
+
dateAdded: number;
|
|
73
|
+
/** Token count in the content */
|
|
74
|
+
tokenCount: number;
|
|
75
|
+
/** Anything to attach to this item */
|
|
76
|
+
customData?: CustomDataType;
|
|
77
|
+
/** If disabled, this item will not be included and will not add tot he token count. */
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
1
81
|
/** ChatGPT config options */
|
|
2
82
|
interface ChatGPTConfig {
|
|
3
83
|
/** API key */
|
|
@@ -39,9 +119,22 @@ interface ChatGPTToolConfig {
|
|
|
39
119
|
callback: (params: any) => any;
|
|
40
120
|
/** If true, this tool call will be removed from the message history after it is executed. */
|
|
41
121
|
removeFromMessageHistory?: boolean;
|
|
122
|
+
/** If true, this item can be removed if there's not enough context available. */
|
|
123
|
+
canRemove?: boolean;
|
|
42
124
|
/** Misc app context */
|
|
43
125
|
[key: string]: any;
|
|
44
126
|
}
|
|
127
|
+
/** ChatGPT message */
|
|
128
|
+
interface ChatGPTMessage {
|
|
129
|
+
/** Role of the message */
|
|
130
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
131
|
+
/** Content of the message */
|
|
132
|
+
content: string;
|
|
133
|
+
/** Tool call ID */
|
|
134
|
+
tool_call_id?: string;
|
|
135
|
+
/** Tool calls made by the AI */
|
|
136
|
+
tool_calls?: any[];
|
|
137
|
+
}
|
|
45
138
|
/**
|
|
46
139
|
* API for interacting with ChatGPT APIs.
|
|
47
140
|
*/
|
|
@@ -52,22 +145,33 @@ declare class ChatGPT {
|
|
|
52
145
|
metadata: any;
|
|
53
146
|
/** Config */
|
|
54
147
|
config: ChatGPTConfig;
|
|
55
|
-
/** List of messages in the chat history */
|
|
56
|
-
messages: any[];
|
|
57
|
-
/** List of available tools */
|
|
58
|
-
tools: ChatGPTToolConfig[];
|
|
59
148
|
/** The maximum tool calls in sequence the AI can make before an error is thrown. */
|
|
60
149
|
maxToolCallsPerMessage: number;
|
|
61
|
-
private _hasRemovedToolCallHistorySinceLastMessage;
|
|
62
150
|
/** Statistics */
|
|
63
151
|
stats: {
|
|
64
152
|
/** Total tokens used this session */
|
|
65
153
|
tokensUsed: number;
|
|
66
154
|
};
|
|
155
|
+
/** Token window management */
|
|
156
|
+
tokenWindow: TokenWindow;
|
|
157
|
+
/** Token window group used for the context message */
|
|
158
|
+
get contextGroup(): TokenWindowGroup<any>;
|
|
159
|
+
/** Token window group used for tools / actions */
|
|
160
|
+
get toolGroup(): TokenWindowGroup<ChatGPTToolConfig>;
|
|
161
|
+
/** Token window group used for messages */
|
|
162
|
+
get messageGroup(): TokenWindowGroup<ChatGPTMessage>;
|
|
67
163
|
/** Constructor */
|
|
68
164
|
constructor(config: ChatGPTConfig);
|
|
69
165
|
/** Send a message, and get the response */
|
|
70
166
|
sendMessage(message: string): Promise<string>;
|
|
167
|
+
/** Insert a message as if the assistant has written it */
|
|
168
|
+
addAssistantMessage(message: string): void;
|
|
169
|
+
/** 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. */
|
|
170
|
+
addUserMessage(message: string): void;
|
|
171
|
+
/** Get all messages */
|
|
172
|
+
getMessages(): ChatGPTMessage[];
|
|
173
|
+
/** Get latest message */
|
|
174
|
+
getLatestMessage(): ChatGPTMessage | undefined;
|
|
71
175
|
/** @private Process messages in the chat history */
|
|
72
176
|
processMessages(): Promise<void>;
|
|
73
177
|
/** Trim message list */
|
|
@@ -597,11 +701,11 @@ declare class IntelliWeave extends EventTarget {
|
|
|
597
701
|
exportState(): {
|
|
598
702
|
type: string;
|
|
599
703
|
conversationID: string;
|
|
600
|
-
messages:
|
|
704
|
+
messages: (ChatGPTMessage | undefined)[] | undefined;
|
|
601
705
|
};
|
|
602
706
|
/** Import conversation state from JSON */
|
|
603
707
|
importState(state: any): void;
|
|
604
|
-
/** Clone this instance */
|
|
708
|
+
/** Clone this instance without any message history */
|
|
605
709
|
clone(): IntelliWeave;
|
|
606
710
|
}
|
|
607
711
|
|