@qelos/sdk 3.11.2 → 3.11.4
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/administrator/admin-lambdas.d.ts +12 -0
- package/dist/administrator/admin-lambdas.js +33 -0
- package/dist/administrator/admin-lambdas.js.map +1 -0
- package/dist/administrator/index.d.ts +4 -0
- package/dist/administrator/index.js +6 -0
- package/dist/administrator/index.js.map +1 -1
- package/dist/administrator/integrations.d.ts +35 -0
- package/dist/administrator/integrations.js +33 -0
- package/dist/administrator/integrations.js.map +1 -0
- package/dist/ai/chat.d.ts +29 -0
- package/dist/ai/chat.js +146 -0
- package/dist/ai/chat.js.map +1 -0
- package/dist/ai/index.d.ts +4 -0
- package/dist/ai/index.js +5 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/rag.d.ts +33 -0
- package/dist/ai/rag.js +38 -0
- package/dist/ai/rag.js.map +1 -0
- package/dist/ai/threads.d.ts +33 -0
- package/dist/ai/threads.js +39 -0
- package/dist/ai/threads.js.map +1 -0
- package/dist/ai/types.d.ts +91 -0
- package/dist/ai/types.js +2 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/ai.d.ts +102 -0
- package/dist/ai.js +115 -0
- package/dist/ai.js.map +1 -0
- package/dist/blueprints.d.ts +7 -0
- package/dist/blueprints.js +4 -0
- package/dist/blueprints.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/lambdas.d.ts +12 -0
- package/dist/lambdas.js +36 -0
- package/dist/lambdas.js.map +1 -0
- package/examples/ai-sdk-usage.ts +170 -0
- package/package.json +1 -1
- package/src/administrator/admin-lambdas.ts +38 -0
- package/src/administrator/index.ts +7 -1
- package/src/administrator/integrations.ts +65 -0
- package/src/ai/chat.ts +187 -0
- package/src/ai/index.ts +4 -0
- package/src/ai/rag.ts +72 -0
- package/src/ai/threads.ts +56 -0
- package/src/ai/types.ts +101 -0
- package/src/ai-sdk-migration-guide.md +172 -0
- package/src/ai.ts +179 -0
- package/src/blueprints.ts +5 -0
- package/src/index.ts +7 -2
- package/src/lambdas.ts +41 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseSDK from "../base-sdk";
|
|
2
|
+
import { QelosSDKOptions } from "../types";
|
|
3
|
+
export default class QlManageLambdas extends BaseSDK {
|
|
4
|
+
private options;
|
|
5
|
+
private relativePath;
|
|
6
|
+
constructor(options: QelosSDKOptions);
|
|
7
|
+
getList(sourceId: string): Promise<unknown>;
|
|
8
|
+
getLambda(sourceId: string, functionName: string): Promise<unknown>;
|
|
9
|
+
create(sourceId: string, data: any): Promise<unknown>;
|
|
10
|
+
update(sourceId: string, functionName: string, data: any): Promise<unknown>;
|
|
11
|
+
remove(sourceId: string, functionName: string): Promise<Response>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import BaseSDK from "../base-sdk";
|
|
2
|
+
export default class QlManageLambdas extends BaseSDK {
|
|
3
|
+
options;
|
|
4
|
+
relativePath = '/api/lambdas';
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super(options);
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
getList(sourceId) {
|
|
10
|
+
return this.callJsonApi(`${this.relativePath}/${sourceId}`);
|
|
11
|
+
}
|
|
12
|
+
getLambda(sourceId, functionName) {
|
|
13
|
+
return this.callJsonApi(`${this.relativePath}/${sourceId}/${functionName}`);
|
|
14
|
+
}
|
|
15
|
+
create(sourceId, data) {
|
|
16
|
+
return this.callJsonApi(`${this.relativePath}/${sourceId}`, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
body: JSON.stringify(data),
|
|
19
|
+
headers: { 'content-type': 'application/json' },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
update(sourceId, functionName, data) {
|
|
23
|
+
return this.callJsonApi(`${this.relativePath}/${sourceId}/${functionName}`, {
|
|
24
|
+
method: 'PUT',
|
|
25
|
+
body: JSON.stringify(data),
|
|
26
|
+
headers: { 'content-type': 'application/json' },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
remove(sourceId, functionName) {
|
|
30
|
+
return this.callApi(`${this.relativePath}/${sourceId}/${functionName}`, { method: 'DELETE' });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=admin-lambdas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-lambdas.js","sourceRoot":"","sources":["../../src/administrator/admin-lambdas.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,aAAa,CAAC;AAGlC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAG5B;IAFZ,YAAY,GAAG,cAAc,CAAC;IAEtC,YAAoB,OAAwB;QACxC,KAAK,CAAC,OAAO,CAAC,CAAA;QADE,YAAO,GAAP,OAAO,CAAiB;IAE5C,CAAC;IAEM,OAAO,CAAC,QAAgB;QAC3B,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,QAAQ,EAAE,CAAC,CAAC;IAChE,CAAC;IAEM,SAAS,CAAC,QAAgB,EAAE,YAAoB;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,QAAQ,IAAI,YAAY,EAAE,CAAC,CAAC;IAChF,CAAC;IAEM,MAAM,CAAC,QAAgB,EAAE,IAAS;QACrC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,QAAQ,EAAE,EAAE;YACxD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC1B,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAClD,CAAC,CAAC;IACP,CAAC;IAEM,MAAM,CAAC,QAAgB,EAAE,YAAoB,EAAE,IAAS;QAC3D,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,QAAQ,IAAI,YAAY,EAAE,EAAE;YACxE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC1B,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAClD,CAAC,CAAC;IACP,CAAC;IAEM,MAAM,CAAC,QAAgB,EAAE,YAAoB;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,QAAQ,IAAI,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClG,CAAC;CACJ"}
|
|
@@ -10,7 +10,10 @@ import { QlRoles } from './roles';
|
|
|
10
10
|
import QlIntegrationSources from './integration-sources';
|
|
11
11
|
import QlManagePlugins from './manage-plugins';
|
|
12
12
|
import QlComponents from './components';
|
|
13
|
+
import QlIntegrations from './integrations';
|
|
14
|
+
import QlManageLambdas from './admin-lambdas';
|
|
13
15
|
export default class QelosAdministratorSDK<T = any> extends QelosSDK {
|
|
16
|
+
manageLambdas: QlManageLambdas;
|
|
14
17
|
users: QlUsers<T>;
|
|
15
18
|
manageConfigurations: QlManageConfigurations;
|
|
16
19
|
manageBlueprints: QlManageBlueprints;
|
|
@@ -21,6 +24,7 @@ export default class QelosAdministratorSDK<T = any> extends QelosSDK {
|
|
|
21
24
|
integrationSources: QlIntegrationSources;
|
|
22
25
|
managePlugins: QlManagePlugins;
|
|
23
26
|
components: QlComponents;
|
|
27
|
+
integrations: QlIntegrations;
|
|
24
28
|
constructor(options: QelosSDKOptions);
|
|
25
29
|
impersonateUser(userId: string, workspaceId?: string): void;
|
|
26
30
|
clearImpersonation(): void;
|
|
@@ -9,7 +9,10 @@ import { QlRoles } from './roles';
|
|
|
9
9
|
import QlIntegrationSources from './integration-sources';
|
|
10
10
|
import QlManagePlugins from './manage-plugins';
|
|
11
11
|
import QlComponents from './components';
|
|
12
|
+
import QlIntegrations from './integrations';
|
|
13
|
+
import QlManageLambdas from './admin-lambdas';
|
|
12
14
|
export default class QelosAdministratorSDK extends QelosSDK {
|
|
15
|
+
manageLambdas;
|
|
13
16
|
users;
|
|
14
17
|
manageConfigurations;
|
|
15
18
|
manageBlueprints;
|
|
@@ -20,8 +23,10 @@ export default class QelosAdministratorSDK extends QelosSDK {
|
|
|
20
23
|
integrationSources;
|
|
21
24
|
managePlugins;
|
|
22
25
|
components;
|
|
26
|
+
integrations;
|
|
23
27
|
constructor(options) {
|
|
24
28
|
super(options);
|
|
29
|
+
this.manageLambdas = new QlManageLambdas(options);
|
|
25
30
|
this.users = new QlUsers(options);
|
|
26
31
|
this.manageConfigurations = new QlManageConfigurations(options);
|
|
27
32
|
this.manageBlueprints = new QlManageBlueprints(options);
|
|
@@ -32,6 +37,7 @@ export default class QelosAdministratorSDK extends QelosSDK {
|
|
|
32
37
|
this.integrationSources = new QlIntegrationSources(options);
|
|
33
38
|
this.managePlugins = new QlManagePlugins(options);
|
|
34
39
|
this.components = new QlComponents(options);
|
|
40
|
+
this.integrations = new QlIntegrations(options);
|
|
35
41
|
if (!options.extraQueryParams) {
|
|
36
42
|
options.extraQueryParams = () => ({
|
|
37
43
|
bypassAdmin: 'true'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/administrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,sBAAsB,MAAM,yBAAyB,CAAC;AAC7D,OAAO,iBAAiB,MAAM,cAAc,CAAC;AAC7C,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,oBAAoB,MAAM,uBAAuB,CAA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/global-types';
|
|
4
|
+
export default class QlIntegrations extends BaseSDK {
|
|
5
|
+
private options;
|
|
6
|
+
private relativePath;
|
|
7
|
+
constructor(options: QelosSDKOptions);
|
|
8
|
+
getIntegration(integrationId: string, extra?: RequestExtra): Promise<IIntegration>;
|
|
9
|
+
getList(query?: {
|
|
10
|
+
plugin?: string;
|
|
11
|
+
user?: string;
|
|
12
|
+
'trigger.source'?: string;
|
|
13
|
+
'target.source'?: string;
|
|
14
|
+
'trigger.kind'?: string;
|
|
15
|
+
'target.kind'?: string;
|
|
16
|
+
kind?: string;
|
|
17
|
+
source?: string;
|
|
18
|
+
active?: boolean;
|
|
19
|
+
id?: string;
|
|
20
|
+
_id?: string;
|
|
21
|
+
}, extra?: RequestExtra): Promise<IIntegration[]>;
|
|
22
|
+
remove(integrationId: string): Promise<any>;
|
|
23
|
+
update(integrationId: string, changes: {
|
|
24
|
+
active?: boolean;
|
|
25
|
+
trigger?: any;
|
|
26
|
+
target?: any;
|
|
27
|
+
dataManipulation?: any;
|
|
28
|
+
}): Promise<IIntegration>;
|
|
29
|
+
create(integration: {
|
|
30
|
+
trigger: any;
|
|
31
|
+
target: any;
|
|
32
|
+
dataManipulation?: any;
|
|
33
|
+
active?: boolean;
|
|
34
|
+
}): Promise<IIntegration>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import BaseSDK from '../base-sdk';
|
|
2
|
+
export default class QlIntegrations extends BaseSDK {
|
|
3
|
+
options;
|
|
4
|
+
relativePath = '/api/integrations';
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super(options);
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
getIntegration(integrationId, extra) {
|
|
10
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, extra);
|
|
11
|
+
}
|
|
12
|
+
getList(query, extra) {
|
|
13
|
+
return this.callJsonApi(this.relativePath + this.getQueryParams(query), extra);
|
|
14
|
+
}
|
|
15
|
+
remove(integrationId) {
|
|
16
|
+
return this.callApi(`${this.relativePath}/${integrationId}`, { method: 'delete' });
|
|
17
|
+
}
|
|
18
|
+
update(integrationId, changes) {
|
|
19
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
|
|
20
|
+
method: 'put',
|
|
21
|
+
headers: { 'content-type': 'application/json' },
|
|
22
|
+
body: JSON.stringify(changes)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
create(integration) {
|
|
26
|
+
return this.callJsonApi(this.relativePath, {
|
|
27
|
+
method: 'post',
|
|
28
|
+
headers: { 'content-type': 'application/json' },
|
|
29
|
+
body: JSON.stringify(integration)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=integrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/administrator/integrations.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,aAAa,CAAC;AAGlC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IAG7B;IAFZ,YAAY,GAAG,mBAAmB,CAAC;IAE3C,YAAoB,OAAwB;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;QADI,YAAO,GAAP,OAAO,CAAiB;IAE5C,CAAC;IAED,cAAc,CAAC,aAAqB,EAAE,KAAoB;QACxD,OAAO,IAAI,CAAC,WAAW,CAAe,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE,KAAK,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,CAAC,KAYP,EAAE,KAAoB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAiB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IACjG,CAAC;IAED,MAAM,CAAC,aAAqB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,MAAM,CAAC,aAAqB,EAAE,OAK7B;QACC,OAAO,IAAI,CAAC,WAAW,CACrB,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EACvC;YACE,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC9B,CACF,CAAA;IACH,CAAC;IAED,MAAM,CAAC,WAKN;QACC,OAAO,IAAI,CAAC,WAAW,CAAe,IAAI,CAAC,YAAY,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;SAClC,CAAC,CAAA;IACJ,CAAC;CAEF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import BaseSDK from '../base-sdk';
|
|
2
|
+
import { QelosSDKOptions } from '../types';
|
|
3
|
+
import { IChatCompletionOptions, IChatCompletionResponse, ISSEStreamProcessor } from '../ai';
|
|
4
|
+
export default class ChatSDK extends BaseSDK {
|
|
5
|
+
private relativePath;
|
|
6
|
+
constructor(options: QelosSDKOptions);
|
|
7
|
+
/**
|
|
8
|
+
* Create a chat completion without a thread
|
|
9
|
+
*/
|
|
10
|
+
chat(integrationId: string, options: IChatCompletionOptions): Promise<IChatCompletionResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Create a chat completion with a thread
|
|
13
|
+
*/
|
|
14
|
+
chatInThread(integrationId: string, threadId: string, options: IChatCompletionOptions): Promise<IChatCompletionResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Create a streaming chat completion without a thread
|
|
17
|
+
* Returns a ReadableStream for Server-Sent Events
|
|
18
|
+
*/
|
|
19
|
+
stream(integrationId: string, options: IChatCompletionOptions): Promise<ReadableStream<Uint8Array>>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a streaming chat completion with a thread
|
|
22
|
+
* Returns a ReadableStream for Server-Sent Events
|
|
23
|
+
*/
|
|
24
|
+
streamInThread(integrationId: string, threadId: string, options: IChatCompletionOptions): Promise<ReadableStream<Uint8Array>>;
|
|
25
|
+
/**
|
|
26
|
+
* Helper method to parse Server-Sent Events stream
|
|
27
|
+
*/
|
|
28
|
+
parseSSEStream(stream: ReadableStream<Uint8Array>): ISSEStreamProcessor;
|
|
29
|
+
}
|
package/dist/ai/chat.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import BaseSDK from '../base-sdk';
|
|
2
|
+
export default class ChatSDK extends BaseSDK {
|
|
3
|
+
relativePath = '/api/ai';
|
|
4
|
+
constructor(options) {
|
|
5
|
+
super(options);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create a chat completion without a thread
|
|
9
|
+
*/
|
|
10
|
+
chat(integrationId, options) {
|
|
11
|
+
const queryParams = this.getQueryParams(options.queryParams || {});
|
|
12
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}/chat-completion${queryParams}`, {
|
|
13
|
+
method: 'POST',
|
|
14
|
+
headers: { 'content-type': 'application/json' },
|
|
15
|
+
body: JSON.stringify(options)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a chat completion with a thread
|
|
20
|
+
*/
|
|
21
|
+
chatInThread(integrationId, threadId, options) {
|
|
22
|
+
const queryParams = this.getQueryParams(options.queryParams || {});
|
|
23
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}/chat-completion/${threadId}${queryParams}`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: { 'content-type': 'application/json' },
|
|
26
|
+
body: JSON.stringify(options)
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a streaming chat completion without a thread
|
|
31
|
+
* Returns a ReadableStream for Server-Sent Events
|
|
32
|
+
*/
|
|
33
|
+
async stream(integrationId, options) {
|
|
34
|
+
const queryParams = this.getQueryParams({ ...options.queryParams, stream: true });
|
|
35
|
+
const response = await this.callApi(`${this.relativePath}/${integrationId}/chat-completion${queryParams}`, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: {
|
|
38
|
+
'content-type': 'application/json',
|
|
39
|
+
'accept': 'text/event-stream'
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify({ ...options, stream: true })
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
45
|
+
}
|
|
46
|
+
return response.body;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a streaming chat completion with a thread
|
|
50
|
+
* Returns a ReadableStream for Server-Sent Events
|
|
51
|
+
*/
|
|
52
|
+
async streamInThread(integrationId, threadId, options) {
|
|
53
|
+
const queryParams = this.getQueryParams({ ...options.queryParams, stream: true });
|
|
54
|
+
const response = await this.callApi(`${this.relativePath}/${integrationId}/chat-completion/${threadId}${queryParams}`, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: {
|
|
57
|
+
'content-type': 'application/json',
|
|
58
|
+
'accept': 'text/event-stream'
|
|
59
|
+
},
|
|
60
|
+
body: JSON.stringify({ ...options, stream: true })
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
64
|
+
}
|
|
65
|
+
return response.body;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Helper method to parse Server-Sent Events stream
|
|
69
|
+
*/
|
|
70
|
+
parseSSEStream(stream) {
|
|
71
|
+
const processStream = async (onData) => {
|
|
72
|
+
const reader = stream.getReader();
|
|
73
|
+
const decoder = new TextDecoder();
|
|
74
|
+
let buffer = "";
|
|
75
|
+
try {
|
|
76
|
+
while (true) {
|
|
77
|
+
const { done, value } = await reader.read();
|
|
78
|
+
if (done)
|
|
79
|
+
break;
|
|
80
|
+
buffer += decoder.decode(value, { stream: true });
|
|
81
|
+
let lines = buffer.split(/\r?\n/);
|
|
82
|
+
buffer = lines.pop() || ""; // Keep incomplete line
|
|
83
|
+
for (const line of lines) {
|
|
84
|
+
if (line.startsWith('data: ')) {
|
|
85
|
+
const data = line.slice(6);
|
|
86
|
+
if (data === '[DONE]')
|
|
87
|
+
return;
|
|
88
|
+
try {
|
|
89
|
+
const parsed = JSON.parse(data);
|
|
90
|
+
const shouldContinue = onData(parsed);
|
|
91
|
+
if (shouldContinue === false) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
// Skip invalid JSON
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
reader.releaseLock();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const processor = {
|
|
107
|
+
async *[Symbol.asyncIterator]() {
|
|
108
|
+
const reader = stream.getReader();
|
|
109
|
+
const decoder = new TextDecoder();
|
|
110
|
+
let buffer = "";
|
|
111
|
+
try {
|
|
112
|
+
while (true) {
|
|
113
|
+
const { done, value } = await reader.read();
|
|
114
|
+
if (done) {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
buffer += decoder.decode(value, { stream: true });
|
|
118
|
+
let lines = buffer.split(/\r?\n/);
|
|
119
|
+
buffer = lines.pop() || ""; // Keep incomplete line
|
|
120
|
+
for (const line of lines) {
|
|
121
|
+
if (line.startsWith('data: ')) {
|
|
122
|
+
const data = line.slice(6);
|
|
123
|
+
if (data === '[DONE]') {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const parsed = JSON.parse(data);
|
|
128
|
+
yield parsed;
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
//
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
reader.releaseLock();
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
processManually: processStream
|
|
142
|
+
};
|
|
143
|
+
return processor;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/ai/chat.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,aAAa,CAAC;AAQlC,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IAClC,YAAY,GAAG,SAAS,CAAC;IAEjC,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAI,CACF,aAAqB,EACrB,OAA+B;QAE/B,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,WAAW,CAA0B,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,mBAAmB,WAAW,EAAE,EAAE;YACtH,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC9B,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,YAAY,CACV,aAAqB,EACrB,QAAgB,EAChB,OAA+B;QAE/B,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,WAAW,CACrB,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,oBAAoB,QAAQ,GAAG,WAAW,EAAE,EACjF;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,c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AAM,CAAC;iCACd;gCAAC,OAAO,CAAC,EAAE;oCACV,EAAE;iCACH;6BACF;yBACF;qBACF;iBACF;wBAAS;oBACR,MAAM,CAAC,WAAW,EAAE,CAAC;iBACtB;YACH,CAAC;YAED,eAAe,EAAE,aAAa;SAC/B,CAAC;QAEF,OAAO,SAAgC,CAAC;IAC1C,CAAC;CACF"}
|
package/dist/ai/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,cAAc,SAAS,CAAC"}
|
package/dist/ai/rag.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import BaseSDK from '../base-sdk';
|
|
2
|
+
import { QelosSDKOptions } from '../types';
|
|
3
|
+
import { ICreateVectorStorageRequest, IUploadContentRequest, IClearStorageRequest, IVectorStore } from '../ai';
|
|
4
|
+
export default class RAGSDK extends BaseSDK {
|
|
5
|
+
private relativePath;
|
|
6
|
+
constructor(options: QelosSDKOptions);
|
|
7
|
+
/**
|
|
8
|
+
* Create a vector storage for RAG
|
|
9
|
+
*/
|
|
10
|
+
createStorage(sourceId: string, data: ICreateVectorStorageRequest): Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
message: string;
|
|
13
|
+
vectorStore: IVectorStore;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Upload content to vector storage
|
|
17
|
+
*/
|
|
18
|
+
uploadContent(sourceId: string, data: IUploadContentRequest): Promise<{
|
|
19
|
+
success: boolean;
|
|
20
|
+
message: string;
|
|
21
|
+
fileId: string;
|
|
22
|
+
vectorStoreId: string;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Clear files from vector storage
|
|
26
|
+
*/
|
|
27
|
+
clearStorage(sourceId: string, data: IClearStorageRequest): Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
clearedCount: number;
|
|
31
|
+
vectorStoreId: string;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
package/dist/ai/rag.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import BaseSDK from '../base-sdk';
|
|
2
|
+
export default class RAGSDK extends BaseSDK {
|
|
3
|
+
relativePath = '/api/ai';
|
|
4
|
+
constructor(options) {
|
|
5
|
+
super(options);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create a vector storage for RAG
|
|
9
|
+
*/
|
|
10
|
+
createStorage(sourceId, data) {
|
|
11
|
+
return this.callJsonApi(`${this.relativePath}/sources/${sourceId}/storage${this.getQueryParams({})}`, {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
headers: { 'content-type': 'application/json' },
|
|
14
|
+
body: JSON.stringify(data)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Upload content to vector storage
|
|
19
|
+
*/
|
|
20
|
+
uploadContent(sourceId, data) {
|
|
21
|
+
return this.callJsonApi(`${this.relativePath}/sources/${sourceId}/storage/upload${this.getQueryParams({})}`, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: { 'content-type': 'application/json' },
|
|
24
|
+
body: JSON.stringify(data)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Clear files from vector storage
|
|
29
|
+
*/
|
|
30
|
+
clearStorage(sourceId, data) {
|
|
31
|
+
return this.callJsonApi(`${this.relativePath}/sources/${sourceId}/storage/clear${this.getQueryParams({})}`, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { 'content-type': 'application/json' },
|
|
34
|
+
body: JSON.stringify(data)
|
|
35
|
+
});
|
|
36
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E,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import BaseSDK from '../base-sdk';
|
|
2
|
+
import { QelosSDKOptions } from '../types';
|
|
3
|
+
import { IThread, ICreateThreadRequest } from '../ai';
|
|
4
|
+
export default class ThreadsSDK extends BaseSDK {
|
|
5
|
+
private relativePath;
|
|
6
|
+
constructor(options: QelosSDKOptions);
|
|
7
|
+
/**
|
|
8
|
+
* Create a new thread
|
|
9
|
+
*/
|
|
10
|
+
create(data: ICreateThreadRequest): Promise<IThread>;
|
|
11
|
+
/**
|
|
12
|
+
* Get a specific thread by ID
|
|
13
|
+
*/
|
|
14
|
+
getOne(threadId: string): Promise<IThread>;
|
|
15
|
+
/**
|
|
16
|
+
* List threads with optional filters
|
|
17
|
+
*/
|
|
18
|
+
list(options?: {
|
|
19
|
+
integration?: string;
|
|
20
|
+
limit?: number;
|
|
21
|
+
page?: number;
|
|
22
|
+
sort?: string;
|
|
23
|
+
user?: string;
|
|
24
|
+
workspace?: string;
|
|
25
|
+
[key: string]: string | number;
|
|
26
|
+
}): Promise<IThread[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Delete a thread
|
|
29
|
+
*/
|
|
30
|
+
delete(threadId: string): Promise<{
|
|
31
|
+
success: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import BaseSDK from '../base-sdk';
|
|
2
|
+
export default class ThreadsSDK extends BaseSDK {
|
|
3
|
+
relativePath = '/api/ai';
|
|
4
|
+
constructor(options) {
|
|
5
|
+
super(options);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create a new thread
|
|
9
|
+
*/
|
|
10
|
+
create(data) {
|
|
11
|
+
return this.callJsonApi(this.relativePath + '/threads', {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
headers: { 'content-type': 'application/json' },
|
|
14
|
+
body: JSON.stringify(data)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get a specific thread by ID
|
|
19
|
+
*/
|
|
20
|
+
getOne(threadId) {
|
|
21
|
+
return this.callJsonApi(`${this.relativePath}/threads/${threadId}${this.getQueryParams({})}`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* List threads with optional filters
|
|
25
|
+
*/
|
|
26
|
+
list(options) {
|
|
27
|
+
const queryParams = this.getQueryParams(options);
|
|
28
|
+
return this.callJsonApi(`${this.relativePath}/threads${queryParams}`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Delete a thread
|
|
32
|
+
*/
|
|
33
|
+
delete(threadId) {
|
|
34
|
+
return this.callJsonApi(`${this.relativePath}/threads/${threadId}${this.getQueryParams({})}`, {
|
|
35
|
+
method: 'DELETE'
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=threads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../src/ai/threads.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,aAAa,CAAC;AAIlC,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IACrC,YAAY,GAAG,SAAS,CAAC;IAEjC,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAA0B;QAC/B,OAAO,IAAI,CAAC,WAAW,CAAU,IAAI,CAAC,YAAY,GAAG,UAAU,EAAE;YAC/D,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAgB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAU,GAAG,IAAI,CAAC,YAAY,YAAY,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACzG,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAQJ;QACC,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,WAAW,CACrB,GAAG,IAAI,CAAC,YAAY,WAAW,WAAW,EAAE,CAC7C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAgB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAuB,GAAG,IAAI,CAAC,YAAY,YAAY,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE;YAClH,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export interface IMessage {
|
|
2
|
+
role: string;
|
|
3
|
+
content: string;
|
|
4
|
+
timestamp?: Date | string;
|
|
5
|
+
tool_calls?: any[];
|
|
6
|
+
name?: string;
|
|
7
|
+
tool_call_id?: string;
|
|
8
|
+
function_call?: any;
|
|
9
|
+
message_id?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IMessageSummary {
|
|
12
|
+
fromIndex: number;
|
|
13
|
+
toIndex: number;
|
|
14
|
+
summary: string;
|
|
15
|
+
}
|
|
16
|
+
export interface IThread {
|
|
17
|
+
_id?: string;
|
|
18
|
+
integration: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
messages: IMessage[];
|
|
21
|
+
messageSummaries: IMessageSummary[];
|
|
22
|
+
created?: Date;
|
|
23
|
+
updated?: Date;
|
|
24
|
+
user?: string;
|
|
25
|
+
workspace?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface IChatCompletionOptions {
|
|
28
|
+
messages: IMessage[];
|
|
29
|
+
model?: string;
|
|
30
|
+
temperature?: number;
|
|
31
|
+
top_p?: number;
|
|
32
|
+
frequency_penalty?: number;
|
|
33
|
+
presence_penalty?: number;
|
|
34
|
+
stop?: string | string[];
|
|
35
|
+
max_tokens?: number;
|
|
36
|
+
response_format?: any;
|
|
37
|
+
context?: Record<string, any>;
|
|
38
|
+
stream?: boolean;
|
|
39
|
+
queryParams?: Record<string, any>;
|
|
40
|
+
}
|
|
41
|
+
export interface ISSEStreamProcessor extends AsyncIterable<any> {
|
|
42
|
+
processManually(onData: (data: any) => void | boolean): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export interface IChatCompletionResponse {
|
|
45
|
+
id: string;
|
|
46
|
+
object: string;
|
|
47
|
+
created: number;
|
|
48
|
+
model: string;
|
|
49
|
+
choices: Array<{
|
|
50
|
+
index: number;
|
|
51
|
+
message: IMessage;
|
|
52
|
+
finish_reason: string;
|
|
53
|
+
}>;
|
|
54
|
+
usage?: {
|
|
55
|
+
prompt_tokens: number;
|
|
56
|
+
completion_tokens: number;
|
|
57
|
+
total_tokens: number;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export interface ICreateThreadRequest {
|
|
61
|
+
integration: string;
|
|
62
|
+
title?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ICreateVectorStorageRequest {
|
|
65
|
+
integrationId: string;
|
|
66
|
+
scope: 'thread' | 'user' | 'workspace' | 'tenant';
|
|
67
|
+
subjectId?: string;
|
|
68
|
+
expirationAfterDays?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface IUploadContentRequest {
|
|
71
|
+
integrationId?: string;
|
|
72
|
+
vectorStoreId?: string;
|
|
73
|
+
content: string | object;
|
|
74
|
+
fileName?: string;
|
|
75
|
+
metadata?: Record<string, any>;
|
|
76
|
+
}
|
|
77
|
+
export interface IClearStorageRequest {
|
|
78
|
+
integrationId?: string;
|
|
79
|
+
vectorStoreId?: string;
|
|
80
|
+
fileIds?: string[];
|
|
81
|
+
}
|
|
82
|
+
export interface IVectorStore {
|
|
83
|
+
_id: string;
|
|
84
|
+
scope: string;
|
|
85
|
+
subjectId?: string;
|
|
86
|
+
tenant: string;
|
|
87
|
+
agent: string;
|
|
88
|
+
externalId: string;
|
|
89
|
+
expirationAfterDays?: number;
|
|
90
|
+
created: Date;
|
|
91
|
+
}
|
package/dist/ai/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":""}
|