@crewdle/web-sdk-types 1.0.22 → 1.0.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/dist/ai/GenerativeAI.d.ts +157 -15
- package/dist/ai/GenerativeAI.js +36 -0
- package/dist/ai/GenerativeAIContext.d.ts +90 -8
- package/dist/ai/GenerativeAIWorkerConnector.d.ts +6 -4
- package/dist/graph-database/GraphDatabase.d.ts +5 -0
- package/dist/graph-database/GraphDatabaseConnector.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { IJobParameters, IJobResult } from '../job';
|
|
2
|
+
/**
|
|
3
|
+
* The AI prompt rating Enum
|
|
4
|
+
* @category AI
|
|
5
|
+
*/
|
|
6
|
+
export declare enum PromptRating {
|
|
7
|
+
Up = "up",
|
|
8
|
+
Down = "down"
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* The AI prompt source Enum
|
|
4
12
|
* @category AI
|
|
@@ -28,6 +36,23 @@ export interface IPromptHistory {
|
|
|
28
36
|
*/
|
|
29
37
|
message: string;
|
|
30
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* The type of parameters supported for agentic functions
|
|
41
|
+
*/
|
|
42
|
+
export declare enum PromptFunctionParamsType {
|
|
43
|
+
/**
|
|
44
|
+
* The parameter is a string.
|
|
45
|
+
*/
|
|
46
|
+
String = "string",
|
|
47
|
+
/**
|
|
48
|
+
* The parameter is a number.
|
|
49
|
+
*/
|
|
50
|
+
Number = "number",
|
|
51
|
+
/**
|
|
52
|
+
* The parameter is a boolean.
|
|
53
|
+
*/
|
|
54
|
+
Boolean = "boolean"
|
|
55
|
+
}
|
|
31
56
|
/**
|
|
32
57
|
* The AI prompt function parameters Interface
|
|
33
58
|
* Represents the parameters for a prompt function.
|
|
@@ -35,7 +60,7 @@ export interface IPromptHistory {
|
|
|
35
60
|
*/
|
|
36
61
|
export interface IPromptFunctionParams {
|
|
37
62
|
[key: string]: {
|
|
38
|
-
type:
|
|
63
|
+
type: PromptFunctionParamsType;
|
|
39
64
|
};
|
|
40
65
|
}
|
|
41
66
|
/**
|
|
@@ -59,12 +84,24 @@ export interface IPromptFunction {
|
|
|
59
84
|
[key: string]: string | number | boolean;
|
|
60
85
|
}) => string | Promise<string>;
|
|
61
86
|
}
|
|
87
|
+
export type AIJobOptions = IPromptOptions | IRatingOptions;
|
|
88
|
+
/**
|
|
89
|
+
* The AI options Interface
|
|
90
|
+
* Represents the options for an AI job.
|
|
91
|
+
* @category AI
|
|
92
|
+
*/
|
|
93
|
+
export interface IAIOptions {
|
|
94
|
+
/**
|
|
95
|
+
* The thread id
|
|
96
|
+
*/
|
|
97
|
+
threadId?: string;
|
|
98
|
+
}
|
|
62
99
|
/**
|
|
63
100
|
* The AI prompt options Interface
|
|
64
101
|
* Represents the options for an AI prompt.
|
|
65
102
|
* @category AI
|
|
66
103
|
*/
|
|
67
|
-
export interface IPromptOptions {
|
|
104
|
+
export interface IPromptOptions extends IAIOptions {
|
|
68
105
|
/**
|
|
69
106
|
* The instructions for the AI job.
|
|
70
107
|
*/
|
|
@@ -85,10 +122,13 @@ export interface IPromptOptions {
|
|
|
85
122
|
* The functions that can be called by the LLM.
|
|
86
123
|
*/
|
|
87
124
|
functions?: Map<string, IPromptFunction>;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The AI rating options Interface
|
|
128
|
+
* Represents the options for an AI rating.
|
|
129
|
+
* @category AI
|
|
130
|
+
*/
|
|
131
|
+
export interface IRatingOptions extends IAIOptions {
|
|
92
132
|
}
|
|
93
133
|
/**
|
|
94
134
|
* The AI prompt type text
|
|
@@ -103,7 +143,11 @@ export type PromptTypeVector = number[];
|
|
|
103
143
|
* Represents the result of an AI prompt.
|
|
104
144
|
* @category AI
|
|
105
145
|
*/
|
|
106
|
-
export interface
|
|
146
|
+
export interface IGenerativeAIPromptResult extends IJobResultAI {
|
|
147
|
+
/**
|
|
148
|
+
* The prompt AI job type.
|
|
149
|
+
*/
|
|
150
|
+
type: AIJobType.Prompt;
|
|
107
151
|
/**
|
|
108
152
|
* The output of the AI job.
|
|
109
153
|
*/
|
|
@@ -122,31 +166,129 @@ export interface IPromptResult {
|
|
|
122
166
|
outputTokens?: number;
|
|
123
167
|
}
|
|
124
168
|
/**
|
|
125
|
-
* The AI
|
|
126
|
-
*
|
|
169
|
+
* The AI rating status Enum
|
|
170
|
+
* @category AI
|
|
171
|
+
*/
|
|
172
|
+
export declare enum AIRatingStatus {
|
|
173
|
+
Success = "success",
|
|
174
|
+
Error = "error"
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The AI rating result Interface
|
|
178
|
+
* Represents the result of an AI rating.
|
|
127
179
|
* @category AI
|
|
128
180
|
*/
|
|
129
|
-
export interface
|
|
181
|
+
export interface IGenerativeAIRatingResult extends IJobResultAI {
|
|
130
182
|
/**
|
|
131
|
-
* The
|
|
183
|
+
* The rating AI job type.
|
|
132
184
|
*/
|
|
133
|
-
|
|
185
|
+
type: AIJobType.Rating;
|
|
134
186
|
/**
|
|
135
|
-
* The
|
|
187
|
+
* The status of the rating.
|
|
136
188
|
*/
|
|
137
|
-
|
|
189
|
+
status: AIRatingStatus;
|
|
138
190
|
}
|
|
191
|
+
export type GenerativeAIJobResult = IGenerativeAIPromptResult | IGenerativeAIRatingResult;
|
|
139
192
|
/**
|
|
140
193
|
* The AI job result Interface
|
|
141
194
|
* Represents the result of an AI job.
|
|
142
195
|
* @category AI
|
|
143
196
|
*/
|
|
144
|
-
export interface IJobResultAI extends IJobResult
|
|
197
|
+
export interface IJobResultAI extends IJobResult {
|
|
198
|
+
/**
|
|
199
|
+
* The AI job type.
|
|
200
|
+
*/
|
|
201
|
+
type: AIJobType;
|
|
145
202
|
/**
|
|
146
203
|
* The index of the output, in case of partial results.
|
|
147
204
|
*/
|
|
148
205
|
index?: number;
|
|
149
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* The AI job type Enum
|
|
209
|
+
* @category AI
|
|
210
|
+
*/
|
|
211
|
+
export declare const enum AIJobType {
|
|
212
|
+
/**
|
|
213
|
+
* The AI job generates a prompt.
|
|
214
|
+
*/
|
|
215
|
+
Prompt = "prompt",
|
|
216
|
+
/**
|
|
217
|
+
* The AI job rates a prompt.
|
|
218
|
+
*/
|
|
219
|
+
Rating = "rate"
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The AI job parameters Interface
|
|
223
|
+
* Parameters for AI job type.
|
|
224
|
+
* @category AI
|
|
225
|
+
*/
|
|
226
|
+
export interface IJobParametersGenerativeAI extends IJobParameters, IPromptOptions, IRatingOptions {
|
|
227
|
+
/**
|
|
228
|
+
* The AI job type.
|
|
229
|
+
*/
|
|
230
|
+
type: AIJobType;
|
|
231
|
+
/**
|
|
232
|
+
* The thread id, if within a conversation.
|
|
233
|
+
*/
|
|
234
|
+
threadId: string;
|
|
235
|
+
}
|
|
236
|
+
export type GenerativeAIWorkerParameters = IGenerativeAIPromptWorkerParameters | IGenerativeAIRatingWorkerParameters;
|
|
237
|
+
export interface IGenerativeAIWorkerParameters extends IJobParametersGenerativeAI {
|
|
238
|
+
/**
|
|
239
|
+
* The AI job type.
|
|
240
|
+
*/
|
|
241
|
+
type: AIJobType;
|
|
242
|
+
}
|
|
243
|
+
export interface IGenerativeAIPromptWorkerParameters extends IGenerativeAIWorkerParameters {
|
|
244
|
+
/**
|
|
245
|
+
* The AI job type.
|
|
246
|
+
*/
|
|
247
|
+
type: AIJobType.Prompt;
|
|
248
|
+
/**
|
|
249
|
+
* The prompt for the AI job.
|
|
250
|
+
*/
|
|
251
|
+
prompt: string;
|
|
252
|
+
}
|
|
253
|
+
export interface IGenerativeAIRatingWorkerParameters extends IGenerativeAIWorkerParameters {
|
|
254
|
+
/**
|
|
255
|
+
* The AI job type.
|
|
256
|
+
*/
|
|
257
|
+
type: AIJobType.Rating;
|
|
258
|
+
/**
|
|
259
|
+
* The job ID.
|
|
260
|
+
*/
|
|
261
|
+
jobId: string;
|
|
262
|
+
/**
|
|
263
|
+
* The rating for the AI prompt.
|
|
264
|
+
*/
|
|
265
|
+
rating: PromptRating;
|
|
266
|
+
/**
|
|
267
|
+
* The feedback for the AI prompt
|
|
268
|
+
*/
|
|
269
|
+
feedback?: string;
|
|
270
|
+
}
|
|
271
|
+
export type GenerativeAIWorkerConnectorParameters = IGenerativeAIPromptWorkerConnectorParameters;
|
|
272
|
+
export type GenerativeAIWorkerConnectorResult = IGenerativeAIWorkerConnectorPromptResult;
|
|
273
|
+
export type GenerativeAIWorkerConnectorTypes = GenerativeAIWorkerConnectorResult['type'];
|
|
274
|
+
export interface IGenerativeAIWorkerConnectorPromptResult extends IGenerativeAIPromptResult {
|
|
275
|
+
}
|
|
276
|
+
export interface IGenerativeAIWorkerConnectorParameters {
|
|
277
|
+
/**
|
|
278
|
+
* The AI job type.
|
|
279
|
+
*/
|
|
280
|
+
type: AIJobType;
|
|
281
|
+
}
|
|
282
|
+
export interface IGenerativeAIPromptWorkerConnectorParameters extends IGenerativeAIWorkerConnectorParameters, IPromptOptions {
|
|
283
|
+
/**
|
|
284
|
+
* The AI job type.
|
|
285
|
+
*/
|
|
286
|
+
type: AIJobType.Prompt;
|
|
287
|
+
/**
|
|
288
|
+
* The prompt for the AI job.
|
|
289
|
+
*/
|
|
290
|
+
prompt: string;
|
|
291
|
+
}
|
|
150
292
|
/**
|
|
151
293
|
* Represents a search result.
|
|
152
294
|
* @category AI
|
package/dist/ai/GenerativeAI.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AI prompt rating Enum
|
|
3
|
+
* @category AI
|
|
4
|
+
*/
|
|
5
|
+
export var PromptRating;
|
|
6
|
+
(function (PromptRating) {
|
|
7
|
+
PromptRating["Up"] = "up";
|
|
8
|
+
PromptRating["Down"] = "down";
|
|
9
|
+
})(PromptRating || (PromptRating = {}));
|
|
1
10
|
/**
|
|
2
11
|
* The AI prompt source Enum
|
|
3
12
|
* @category AI
|
|
@@ -15,3 +24,30 @@ export var PromptSource;
|
|
|
15
24
|
})(PromptSource || (PromptSource = {}));
|
|
16
25
|
;
|
|
17
26
|
;
|
|
27
|
+
/**
|
|
28
|
+
* The type of parameters supported for agentic functions
|
|
29
|
+
*/
|
|
30
|
+
export var PromptFunctionParamsType;
|
|
31
|
+
(function (PromptFunctionParamsType) {
|
|
32
|
+
/**
|
|
33
|
+
* The parameter is a string.
|
|
34
|
+
*/
|
|
35
|
+
PromptFunctionParamsType["String"] = "string";
|
|
36
|
+
/**
|
|
37
|
+
* The parameter is a number.
|
|
38
|
+
*/
|
|
39
|
+
PromptFunctionParamsType["Number"] = "number";
|
|
40
|
+
/**
|
|
41
|
+
* The parameter is a boolean.
|
|
42
|
+
*/
|
|
43
|
+
PromptFunctionParamsType["Boolean"] = "boolean";
|
|
44
|
+
})(PromptFunctionParamsType || (PromptFunctionParamsType = {}));
|
|
45
|
+
/**
|
|
46
|
+
* The AI rating status Enum
|
|
47
|
+
* @category AI
|
|
48
|
+
*/
|
|
49
|
+
export var AIRatingStatus;
|
|
50
|
+
(function (AIRatingStatus) {
|
|
51
|
+
AIRatingStatus["Success"] = "success";
|
|
52
|
+
AIRatingStatus["Error"] = "error";
|
|
53
|
+
})(AIRatingStatus || (AIRatingStatus = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPromptOptions,
|
|
1
|
+
import { AIJobType, IPromptOptions, IGenerativeAIPromptResult, IRatingOptions, IGenerativeAIRatingResult, PromptRating } from '.';
|
|
2
2
|
/**
|
|
3
3
|
* Represents bounded prompt job ready to be run or streamed.
|
|
4
4
|
*/
|
|
@@ -19,12 +19,88 @@ export interface IGenerativeAIPromptJob {
|
|
|
19
19
|
* Run the prompt job.
|
|
20
20
|
* @returns A promise that resolves with the result
|
|
21
21
|
*/
|
|
22
|
-
run: () => Promise<
|
|
22
|
+
run: () => Promise<IGenerativeAIPromptResult>;
|
|
23
23
|
/**
|
|
24
24
|
* Stream the prompt job.
|
|
25
25
|
* @returns An async generator that yields the result
|
|
26
26
|
*/
|
|
27
|
-
stream: () => AsyncGenerator<
|
|
27
|
+
stream: () => AsyncGenerator<IGenerativeAIPromptResult>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents a Generative AI job.
|
|
31
|
+
*/
|
|
32
|
+
export type GenerativeAIJob = IGenerativeAIPromptJob | IGenerativeAIRatingJob;
|
|
33
|
+
/**
|
|
34
|
+
* Represents bounded rating job ready to be run or streamed.
|
|
35
|
+
*/
|
|
36
|
+
export interface IGenerativeAIRatingJob {
|
|
37
|
+
/**
|
|
38
|
+
* The job ID.
|
|
39
|
+
*/
|
|
40
|
+
id: string;
|
|
41
|
+
/**
|
|
42
|
+
* The rating for the job.
|
|
43
|
+
*/
|
|
44
|
+
rating: PromptRating;
|
|
45
|
+
/**
|
|
46
|
+
* The feedback for the job.
|
|
47
|
+
*/
|
|
48
|
+
feedback?: string;
|
|
49
|
+
/**
|
|
50
|
+
* The options for the rating.
|
|
51
|
+
*/
|
|
52
|
+
options: IRatingOptions;
|
|
53
|
+
/**
|
|
54
|
+
* Run the rating job.
|
|
55
|
+
* @returns A promise that resolves with the result
|
|
56
|
+
*/
|
|
57
|
+
rate: () => Promise<IGenerativeAIRatingResult>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Represents the parameters of an AI job.
|
|
61
|
+
*/
|
|
62
|
+
export type CreateAIJobParameters = IGenerativeAIPromptParameters | IGenerativeAIRatingParameters;
|
|
63
|
+
/**
|
|
64
|
+
* Represents the parameters of a prompt job.
|
|
65
|
+
*/
|
|
66
|
+
export interface IGenerativeAIPromptParameters {
|
|
67
|
+
/**
|
|
68
|
+
* The prompt job type.
|
|
69
|
+
*/
|
|
70
|
+
type: AIJobType.Prompt;
|
|
71
|
+
/**
|
|
72
|
+
* The prompt to be processed.
|
|
73
|
+
*/
|
|
74
|
+
prompt: string;
|
|
75
|
+
/**
|
|
76
|
+
* The options for the prompt.
|
|
77
|
+
*/
|
|
78
|
+
options?: IPromptOptions;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Represents the parameters of a rating job.
|
|
82
|
+
*/
|
|
83
|
+
export interface IGenerativeAIRatingParameters {
|
|
84
|
+
/**
|
|
85
|
+
* The rating job type.
|
|
86
|
+
*/
|
|
87
|
+
type: AIJobType.Rating;
|
|
88
|
+
/**
|
|
89
|
+
* The job ID associated with the message.
|
|
90
|
+
*/
|
|
91
|
+
jobId: string;
|
|
92
|
+
/**
|
|
93
|
+
* The rating of the prompt.
|
|
94
|
+
*/
|
|
95
|
+
rating: PromptRating;
|
|
96
|
+
/**
|
|
97
|
+
* The feedback for the prompt.
|
|
98
|
+
*/
|
|
99
|
+
feedback?: string;
|
|
100
|
+
/**
|
|
101
|
+
* The options for the rating.
|
|
102
|
+
*/
|
|
103
|
+
options?: IRatingOptions;
|
|
28
104
|
}
|
|
29
105
|
/**
|
|
30
106
|
* Represents a context for a Generative AI service.
|
|
@@ -32,12 +108,18 @@ export interface IGenerativeAIPromptJob {
|
|
|
32
108
|
*/
|
|
33
109
|
export interface IGenerativeAIContext {
|
|
34
110
|
/**
|
|
35
|
-
* Create
|
|
36
|
-
* @param
|
|
37
|
-
* @
|
|
38
|
-
|
|
111
|
+
* Create an AI job. The job is bounded to the context.
|
|
112
|
+
* @param parameters The parameters of the AI job.
|
|
113
|
+
* @returns The job ready to be run or streamed.
|
|
114
|
+
*/
|
|
115
|
+
createAIJob(parameters: IGenerativeAIPromptParameters): IGenerativeAIPromptJob;
|
|
116
|
+
createAIJob(parameters: IGenerativeAIRatingParameters): IGenerativeAIRatingJob;
|
|
117
|
+
/**
|
|
118
|
+
* Rate a prompt.
|
|
119
|
+
* @param parameters The parameters of the rating job.
|
|
120
|
+
* @returns A promise that resolves with the result.
|
|
39
121
|
*/
|
|
40
|
-
|
|
122
|
+
ratePrompt(parameters: IGenerativeAIRatingParameters): Promise<IGenerativeAIRatingResult>;
|
|
41
123
|
/**
|
|
42
124
|
* Get the data bucket IDs.
|
|
43
125
|
* @returns An array of data bucket IDs.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IJobWorkerConnector, IJobWorkerOptions } from '../job';
|
|
2
|
-
import {
|
|
2
|
+
import { GenerativeAIWorkerConnectorParameters, IGenerativeAIPromptWorkerConnectorParameters, IGenerativeAIWorkerConnectorPromptResult, GenerativeAIWorkerConnectorResult } from './GenerativeAI';
|
|
3
3
|
/**
|
|
4
4
|
* The generative AI model input types.
|
|
5
5
|
* @category AI
|
|
@@ -85,7 +85,7 @@ export interface IGenerativeAIWorkerOptions extends IJobWorkerOptions {
|
|
|
85
85
|
* The generative AI worker connector interface.
|
|
86
86
|
* @category Connector
|
|
87
87
|
*/
|
|
88
|
-
export interface IGenerativeAIWorkerConnector extends IJobWorkerConnector<
|
|
88
|
+
export interface IGenerativeAIWorkerConnector extends IJobWorkerConnector<GenerativeAIWorkerConnectorParameters, GenerativeAIWorkerConnectorResult> {
|
|
89
89
|
/**
|
|
90
90
|
* Initialize the machine learning model.
|
|
91
91
|
* @param workflowId The workflow ID.
|
|
@@ -109,12 +109,14 @@ export interface IGenerativeAIWorkerConnector extends IJobWorkerConnector<IJobPa
|
|
|
109
109
|
* @param options The job options.
|
|
110
110
|
* @returns A promise that resolves with the job result.
|
|
111
111
|
*/
|
|
112
|
-
processJob(parameters:
|
|
112
|
+
processJob(parameters: IGenerativeAIPromptWorkerConnectorParameters, options?: IGenerativeAIWorkerOptions): Promise<IGenerativeAIWorkerConnectorPromptResult>;
|
|
113
|
+
processJob(parameters: GenerativeAIWorkerConnectorParameters, options?: IGenerativeAIWorkerOptions): Promise<GenerativeAIWorkerConnectorResult>;
|
|
113
114
|
/**
|
|
114
115
|
* Stream a job.
|
|
115
116
|
* @param parameters The job parameters.
|
|
116
117
|
* @param options The job options.
|
|
117
118
|
* @returns An async generator that yields the job result.
|
|
118
119
|
*/
|
|
119
|
-
processJobStream(parameters:
|
|
120
|
+
processJobStream(parameters: IGenerativeAIPromptWorkerConnectorParameters, options?: IGenerativeAIWorkerOptions): AsyncGenerator<IGenerativeAIWorkerConnectorPromptResult>;
|
|
121
|
+
processJobStream(parameters: GenerativeAIWorkerConnectorParameters, options?: IGenerativeAIWorkerOptions): AsyncGenerator<GenerativeAIWorkerConnectorResult>;
|
|
120
122
|
}
|
|
@@ -31,6 +31,11 @@ export interface IGraphDatabase extends IDataStream {
|
|
|
31
31
|
* @param to The node to add the edge to.
|
|
32
32
|
*/
|
|
33
33
|
addEdge(from: string, to: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Remove content from the database.
|
|
36
|
+
* @param name The name of the content to remove.
|
|
37
|
+
*/
|
|
38
|
+
remove(name: string): void;
|
|
34
39
|
/**
|
|
35
40
|
* Get the content of the nodes and their neighbors.
|
|
36
41
|
* @param nodes The nodes to get the content of.
|
|
@@ -28,6 +28,11 @@ export interface IGraphDatabaseConnector {
|
|
|
28
28
|
getContent(nodes: string[], maxDepth?: number, contentSize?: number): {
|
|
29
29
|
[key: string]: string[];
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Remove content from the database.
|
|
33
|
+
* @param name The name of the content to remove.
|
|
34
|
+
*/
|
|
35
|
+
remove(name: string): void;
|
|
31
36
|
/**
|
|
32
37
|
* Get the size of the database
|
|
33
38
|
* @returns The size of the database.
|