@crewdle/web-sdk-types 1.0.12 → 1.0.14
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 +89 -0
- package/dist/ai/GenerativeAI.js +16 -0
- package/dist/ai/GenerativeAIContext.d.ts +10 -3
- package/dist/ai/GenerativeAIWorkerConnector.d.ts +10 -3
- package/dist/ai/index.d.ts +1 -0
- package/dist/ai/index.js +1 -0
- package/dist/job/Job.d.ts +58 -43
- package/dist/job/Job.js +17 -7
- package/dist/job/JobDispatcher.d.ts +6 -7
- package/dist/job/JobWorkerConnector.d.ts +8 -3
- package/package.json +1 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { IJobParameters, IJobResult } from '../job';
|
|
2
|
+
/**
|
|
3
|
+
* The AI prompt source Enum
|
|
4
|
+
*/
|
|
5
|
+
export declare enum PromptSource {
|
|
6
|
+
/**
|
|
7
|
+
* The prompt was generated by the AI.
|
|
8
|
+
*/
|
|
9
|
+
AI = "ai",
|
|
10
|
+
/**
|
|
11
|
+
* The prompt was generated by a human.
|
|
12
|
+
*/
|
|
13
|
+
Human = "human"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The AI prompt history Interface
|
|
17
|
+
* Represents the history of a prompt.
|
|
18
|
+
* @ignore
|
|
19
|
+
*/
|
|
20
|
+
export interface IPromptHistory {
|
|
21
|
+
/**
|
|
22
|
+
* The source of the prompt.
|
|
23
|
+
*/
|
|
24
|
+
source: PromptSource;
|
|
25
|
+
/**
|
|
26
|
+
* The prompt.
|
|
27
|
+
*/
|
|
28
|
+
message: string;
|
|
29
|
+
}
|
|
30
|
+
export interface IPromptOptions {
|
|
31
|
+
/**
|
|
32
|
+
* The instructions for the AI job.
|
|
33
|
+
*/
|
|
34
|
+
instructions?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to use RAG for the AI job.
|
|
37
|
+
*/
|
|
38
|
+
useRAG?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The context for the AI job.
|
|
41
|
+
*/
|
|
42
|
+
context?: IPromptHistory[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The AI job parameters Interface
|
|
46
|
+
* Parameters for AI job type.
|
|
47
|
+
* @ignore
|
|
48
|
+
*/
|
|
49
|
+
export interface IJobParametersAI extends IJobParameters {
|
|
50
|
+
/**
|
|
51
|
+
* The prompt for the AI job.
|
|
52
|
+
*/
|
|
53
|
+
prompt: string;
|
|
54
|
+
/**
|
|
55
|
+
* The instructions for the AI job.
|
|
56
|
+
*/
|
|
57
|
+
instructions?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to use RAG for the AI job.
|
|
60
|
+
*/
|
|
61
|
+
useRAG?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The context for the AI job.
|
|
64
|
+
*/
|
|
65
|
+
context?: IPromptHistory[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The AI job result Interface
|
|
69
|
+
* Represents the result of an AI job.
|
|
70
|
+
* @ignore
|
|
71
|
+
*/
|
|
72
|
+
export interface IJobResultAI extends IJobResult {
|
|
73
|
+
/**
|
|
74
|
+
* The output of the AI job.
|
|
75
|
+
*/
|
|
76
|
+
output: string;
|
|
77
|
+
/**
|
|
78
|
+
* The tokens used by the AI job.
|
|
79
|
+
*/
|
|
80
|
+
inputTokens?: number;
|
|
81
|
+
/**
|
|
82
|
+
* The tokens generated by the AI job.
|
|
83
|
+
*/
|
|
84
|
+
outputTokens?: number;
|
|
85
|
+
/**
|
|
86
|
+
* The index of the output, in case of partial results.
|
|
87
|
+
*/
|
|
88
|
+
index?: number;
|
|
89
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AI prompt source Enum
|
|
3
|
+
*/
|
|
4
|
+
export var PromptSource;
|
|
5
|
+
(function (PromptSource) {
|
|
6
|
+
/**
|
|
7
|
+
* The prompt was generated by the AI.
|
|
8
|
+
*/
|
|
9
|
+
PromptSource["AI"] = "ai";
|
|
10
|
+
/**
|
|
11
|
+
* The prompt was generated by a human.
|
|
12
|
+
*/
|
|
13
|
+
PromptSource["Human"] = "human";
|
|
14
|
+
})(PromptSource || (PromptSource = {}));
|
|
15
|
+
;
|
|
16
|
+
;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
+
import { IPromptOptions } from '.';
|
|
1
2
|
/**
|
|
2
3
|
* Represents a context for a Generative AI service.
|
|
3
4
|
* @category AI
|
|
4
5
|
*/
|
|
5
6
|
export interface IGenerativeAIContext {
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Stream the response from the AI service.
|
|
8
9
|
* @param prompt The prompt to start processing.
|
|
9
|
-
* @returns
|
|
10
|
+
* @returns An async generator that yields the response.
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
stream(prompt: string, options?: IPromptOptions): AsyncGenerator<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Process the response from the AI service.
|
|
15
|
+
* @param prompt The prompt to start processing.
|
|
16
|
+
* @returns A promise that resolves with the response.
|
|
17
|
+
*/
|
|
18
|
+
prompt(prompt: string, options?: IPromptOptions): Promise<string>;
|
|
12
19
|
/**
|
|
13
20
|
* Close the Generative AI Context.
|
|
14
21
|
*/
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IJobRequest, IJobWorkerConnector, JobResponse } from '../job';
|
|
2
|
+
import { IJobParametersAI, IJobResultAI } from './GenerativeAI';
|
|
2
3
|
/**
|
|
3
4
|
* The generative AI worker connector interface.
|
|
4
5
|
* @category Connector
|
|
5
6
|
*/
|
|
6
|
-
export interface IGenerativeAIWorkerConnector extends IJobWorkerConnector {
|
|
7
|
+
export interface IGenerativeAIWorkerConnector extends IJobWorkerConnector<IJobParametersAI, IJobResultAI> {
|
|
7
8
|
/**
|
|
8
9
|
* Initialize the machine learning model.
|
|
9
10
|
* @param llmModel The path to the LLM model.
|
|
@@ -26,7 +27,13 @@ export interface IGenerativeAIWorkerConnector extends IJobWorkerConnector {
|
|
|
26
27
|
/**
|
|
27
28
|
* Process a job.
|
|
28
29
|
* @param job The job to process.
|
|
30
|
+
* @returns A promise that resolves with the job result.
|
|
31
|
+
*/
|
|
32
|
+
processJob(job: IJobRequest<IJobParametersAI>): Promise<JobResponse<IJobResultAI>>;
|
|
33
|
+
/**
|
|
34
|
+
* Stream a job.
|
|
35
|
+
* @param job The job to stream.
|
|
29
36
|
* @returns An async generator that yields the job result.
|
|
30
37
|
*/
|
|
31
|
-
|
|
38
|
+
processJobStream(job: IJobRequest<IJobParametersAI>): AsyncGenerator<JobResponse<IJobResultAI>>;
|
|
32
39
|
}
|
package/dist/ai/index.d.ts
CHANGED
package/dist/ai/index.js
CHANGED
package/dist/job/Job.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Base IJobParameters Interface
|
|
3
|
+
* Allows providing parameters specific to the job type.
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export interface IJobParameters {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Job request Interface
|
|
3
10
|
* Represents a job to be executed by the JobService.
|
|
4
11
|
* @ignore
|
|
5
12
|
*/
|
|
6
|
-
export interface
|
|
13
|
+
export interface IJobRequest<T extends IJobParameters> {
|
|
7
14
|
/**
|
|
8
15
|
* The ID of the job.
|
|
9
16
|
*/
|
|
@@ -11,20 +18,30 @@ export interface IJob {
|
|
|
11
18
|
/**
|
|
12
19
|
* The parameters of the job.
|
|
13
20
|
*/
|
|
14
|
-
parameters:
|
|
21
|
+
parameters: T;
|
|
15
22
|
/**
|
|
16
23
|
* The status of the job.
|
|
17
24
|
*/
|
|
18
25
|
status?: JobStatus;
|
|
26
|
+
/**
|
|
27
|
+
* The type of the job.
|
|
28
|
+
*/
|
|
29
|
+
jobType: JobType;
|
|
19
30
|
}
|
|
20
31
|
/**
|
|
21
32
|
* JobType Enum
|
|
22
|
-
*
|
|
33
|
+
* Represents the type of a job.
|
|
23
34
|
* @ignore
|
|
24
35
|
*/
|
|
25
36
|
export declare enum JobType {
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The job is expected to return a Promise with a result.
|
|
39
|
+
*/
|
|
40
|
+
Job = "job",
|
|
41
|
+
/**
|
|
42
|
+
* The job is expected to return a stream iterator with results.
|
|
43
|
+
*/
|
|
44
|
+
JobStream = "job-stream"
|
|
28
45
|
}
|
|
29
46
|
/**
|
|
30
47
|
* JobStatus Enum
|
|
@@ -35,74 +52,72 @@ export declare enum JobStatus {
|
|
|
35
52
|
/**
|
|
36
53
|
* The job is pending.
|
|
37
54
|
*/
|
|
38
|
-
Pending = "
|
|
55
|
+
Pending = "pending",
|
|
39
56
|
/**
|
|
40
57
|
* The job is processing.
|
|
41
58
|
*/
|
|
42
|
-
Processing = "
|
|
59
|
+
Processing = "processing",
|
|
60
|
+
/**
|
|
61
|
+
* The job has partial results.
|
|
62
|
+
*/
|
|
63
|
+
Partial = "partial",
|
|
43
64
|
/**
|
|
44
65
|
* The job is completed.
|
|
45
66
|
*/
|
|
46
|
-
Completed = "
|
|
67
|
+
Completed = "completed",
|
|
47
68
|
/**
|
|
48
69
|
* The job has failed.
|
|
49
70
|
*/
|
|
50
|
-
Failed = "
|
|
71
|
+
Failed = "failed"
|
|
51
72
|
}
|
|
52
73
|
/**
|
|
53
|
-
* Base
|
|
54
|
-
*
|
|
55
|
-
* @ignore
|
|
56
|
-
*/
|
|
57
|
-
export interface IJobParameters {
|
|
58
|
-
jobType: JobType;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* IJobParametersAI Interface
|
|
62
|
-
* Parameters for AI job type.
|
|
74
|
+
* Base job result Interface
|
|
75
|
+
* Represents the result of a job.
|
|
63
76
|
* @ignore
|
|
64
77
|
*/
|
|
65
|
-
export interface
|
|
66
|
-
jobType: JobType.AI;
|
|
67
|
-
prompt: string;
|
|
78
|
+
export interface IJobResult {
|
|
68
79
|
}
|
|
69
80
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @ignore
|
|
73
|
-
*/
|
|
74
|
-
export type JobParameters = IJobParametersAI;
|
|
75
|
-
/**
|
|
76
|
-
* IJobResult Interface
|
|
77
|
-
* Represents the result of a job.
|
|
81
|
+
* Job response Interface
|
|
82
|
+
* Represents the response from a job.
|
|
78
83
|
* @ignore
|
|
79
84
|
*/
|
|
80
|
-
export interface IJobResult {
|
|
85
|
+
export interface IJobResultResponse<T extends IJobResult> {
|
|
81
86
|
/**
|
|
82
87
|
* The ID of the job.
|
|
83
88
|
*/
|
|
84
89
|
id: string;
|
|
85
90
|
/**
|
|
86
|
-
* The status of the job
|
|
91
|
+
* The status of the job.
|
|
87
92
|
*/
|
|
88
|
-
status: JobStatus;
|
|
93
|
+
status: JobStatus.Partial | JobStatus.Completed;
|
|
89
94
|
/**
|
|
90
95
|
* The result of the job.
|
|
91
96
|
*/
|
|
92
|
-
result:
|
|
97
|
+
result: T;
|
|
93
98
|
}
|
|
94
99
|
/**
|
|
95
|
-
*
|
|
96
|
-
* Represents
|
|
100
|
+
* Job failed response Interface
|
|
101
|
+
* Represents a failed job response.
|
|
97
102
|
* @ignore
|
|
98
103
|
*/
|
|
99
|
-
export interface
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
export interface IJobFailedResponse {
|
|
105
|
+
/**
|
|
106
|
+
* The ID of the job.
|
|
107
|
+
*/
|
|
108
|
+
id: string;
|
|
109
|
+
/**
|
|
110
|
+
* The status of the job.
|
|
111
|
+
*/
|
|
112
|
+
status: JobStatus.Failed;
|
|
113
|
+
/**
|
|
114
|
+
* The error message.
|
|
115
|
+
*/
|
|
116
|
+
message: string;
|
|
102
117
|
}
|
|
103
118
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
119
|
+
* Job response type
|
|
120
|
+
* Represents the response type from a job.
|
|
106
121
|
* @ignore
|
|
107
122
|
*/
|
|
108
|
-
export type
|
|
123
|
+
export type JobResponse<T extends IJobResult> = IJobResultResponse<T> | IJobFailedResponse;
|
package/dist/job/Job.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JobType Enum
|
|
3
|
-
*
|
|
3
|
+
* Represents the type of a job.
|
|
4
4
|
* @ignore
|
|
5
5
|
*/
|
|
6
6
|
export var JobType;
|
|
7
7
|
(function (JobType) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The job is expected to return a Promise with a result.
|
|
10
|
+
*/
|
|
11
|
+
JobType["Job"] = "job";
|
|
12
|
+
/**
|
|
13
|
+
* The job is expected to return a stream iterator with results.
|
|
14
|
+
*/
|
|
15
|
+
JobType["JobStream"] = "job-stream";
|
|
10
16
|
})(JobType || (JobType = {}));
|
|
11
17
|
/**
|
|
12
18
|
* JobStatus Enum
|
|
@@ -18,17 +24,21 @@ export var JobStatus;
|
|
|
18
24
|
/**
|
|
19
25
|
* The job is pending.
|
|
20
26
|
*/
|
|
21
|
-
JobStatus["Pending"] = "
|
|
27
|
+
JobStatus["Pending"] = "pending";
|
|
22
28
|
/**
|
|
23
29
|
* The job is processing.
|
|
24
30
|
*/
|
|
25
|
-
JobStatus["Processing"] = "
|
|
31
|
+
JobStatus["Processing"] = "processing";
|
|
32
|
+
/**
|
|
33
|
+
* The job has partial results.
|
|
34
|
+
*/
|
|
35
|
+
JobStatus["Partial"] = "partial";
|
|
26
36
|
/**
|
|
27
37
|
* The job is completed.
|
|
28
38
|
*/
|
|
29
|
-
JobStatus["Completed"] = "
|
|
39
|
+
JobStatus["Completed"] = "completed";
|
|
30
40
|
/**
|
|
31
41
|
* The job has failed.
|
|
32
42
|
*/
|
|
33
|
-
JobStatus["Failed"] = "
|
|
43
|
+
JobStatus["Failed"] = "failed";
|
|
34
44
|
})(JobStatus || (JobStatus = {}));
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
2
|
import { IDataStream } from '../core/stream';
|
|
3
|
-
import {
|
|
3
|
+
import { IJobParameters, IJobRequest, IJobResult, JobResponse } from './Job';
|
|
4
4
|
/**
|
|
5
5
|
* The Job Dispatcher interface.
|
|
6
6
|
* @ignore
|
|
7
7
|
*/
|
|
8
|
-
export interface IJobDispatcher extends IDataStream {
|
|
8
|
+
export interface IJobDispatcher<T extends IJobParameters, U extends IJobResult> extends IDataStream {
|
|
9
9
|
/**
|
|
10
10
|
* Create a new job.
|
|
11
|
-
* @param
|
|
12
|
-
* @param parameters The parameters of the job.
|
|
11
|
+
* @param job The job to create.
|
|
13
12
|
*/
|
|
14
|
-
createJob(job:
|
|
13
|
+
createJob(job: IJobRequest<T>): Promise<Observable<JobResponse<U>>>;
|
|
15
14
|
/**
|
|
16
15
|
* Get a job by ID.
|
|
17
16
|
* @param id The ID of the job to get.
|
|
18
17
|
* @returns The job.
|
|
19
18
|
*/
|
|
20
|
-
getJob(id: string):
|
|
19
|
+
getJob(id: string): IJobRequest<T>;
|
|
21
20
|
/**
|
|
22
21
|
* Get all jobs.
|
|
23
22
|
* @returns All jobs.
|
|
24
23
|
*/
|
|
25
|
-
getJobs():
|
|
24
|
+
getJobs(): IJobRequest<T>[];
|
|
26
25
|
/**
|
|
27
26
|
* Close the Job Dispatcher.
|
|
28
27
|
*/
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IJobParameters, IJobRequest, IJobResult, JobResponse } from './Job';
|
|
2
2
|
/**
|
|
3
3
|
* The Job Worker Connector interface.
|
|
4
4
|
* @ignore
|
|
5
5
|
*/
|
|
6
|
-
export interface IJobWorkerConnector {
|
|
6
|
+
export interface IJobWorkerConnector<T extends IJobParameters, U extends IJobResult> {
|
|
7
7
|
/**
|
|
8
8
|
* Process a job.
|
|
9
9
|
* @param job The job to process.
|
|
10
10
|
*/
|
|
11
|
-
processJob(job:
|
|
11
|
+
processJob(job: IJobRequest<T>): Promise<JobResponse<U>>;
|
|
12
|
+
/**
|
|
13
|
+
* Process a job stream.
|
|
14
|
+
* @param job The job to process.
|
|
15
|
+
*/
|
|
16
|
+
processJobStream(job: IJobRequest<T>): AsyncGenerator<JobResponse<U>>;
|
|
12
17
|
}
|