@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
package/dist/ai.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { QelosSDKOptions } from './types';
|
|
2
|
+
import BaseSDK from './base-sdk';
|
|
3
|
+
import ThreadsSDK from './ai/threads';
|
|
4
|
+
import ChatSDK from './ai/chat';
|
|
5
|
+
import RAGSDK from './ai/rag';
|
|
6
|
+
import { IMessage, IMessageSummary, IThread, IChatCompletionOptions, ISSEStreamProcessor, IChatCompletionResponse, ICreateThreadRequest, ICreateVectorStorageRequest, IUploadContentRequest, IClearStorageRequest, IVectorStore } from './ai/types';
|
|
7
|
+
export { IMessage, IMessageSummary, IThread, IChatCompletionOptions, ISSEStreamProcessor, IChatCompletionResponse, ICreateThreadRequest, ICreateVectorStorageRequest, IUploadContentRequest, IClearStorageRequest, IVectorStore };
|
|
8
|
+
/**
|
|
9
|
+
* Qelos AI SDK - Main SDK class with three sub-SDKs
|
|
10
|
+
*
|
|
11
|
+
* This class provides access to AI functionality through three sub-SDKs:
|
|
12
|
+
* - `threads`: Thread CRUD operations for managing conversation threads
|
|
13
|
+
* - `chat`: Chat completion operations (streaming and non-streaming)
|
|
14
|
+
* - `rag`: Vector storage management for Retrieval-Augmented Generation
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const sdk = new QelosSDK({
|
|
19
|
+
* appUrl: 'https://your-qelos-instance.com',
|
|
20
|
+
* fetch: globalThis.fetch,
|
|
21
|
+
* accessToken: 'your-token'
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Create a thread
|
|
25
|
+
* const thread = await sdk.ai.threads.create({ integration: 'id' });
|
|
26
|
+
*
|
|
27
|
+
* // Stream chat
|
|
28
|
+
* const stream = await sdk.ai.chat.stream('id', { messages: [...] });
|
|
29
|
+
* for await (const chunk of sdk.ai.chat.parseSSEStream(stream)) {
|
|
30
|
+
* console.log(chunk);
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* // Upload RAG content
|
|
34
|
+
* await sdk.ai.rag.uploadContent('sourceId', { content: '...' });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export default class QlAI extends BaseSDK {
|
|
38
|
+
/**
|
|
39
|
+
* Threads sub-SDK for managing conversation threads
|
|
40
|
+
*/
|
|
41
|
+
threads: ThreadsSDK;
|
|
42
|
+
/**
|
|
43
|
+
* Chat sub-SDK for chat completion operations
|
|
44
|
+
*/
|
|
45
|
+
chat: ChatSDK;
|
|
46
|
+
/**
|
|
47
|
+
* RAG sub-SDK for vector storage management
|
|
48
|
+
*/
|
|
49
|
+
rag: RAGSDK;
|
|
50
|
+
/**
|
|
51
|
+
* Initialize the AI SDK with sub-SDKs
|
|
52
|
+
*
|
|
53
|
+
* @param options - SDK configuration options
|
|
54
|
+
*/
|
|
55
|
+
constructor(options: QelosSDKOptions);
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use sdk.threads.create() instead
|
|
58
|
+
*/
|
|
59
|
+
createThread(data: ICreateThreadRequest): Promise<IThread>;
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use sdk.threads.getOne() instead
|
|
62
|
+
*/
|
|
63
|
+
getThread(threadId: string): Promise<IThread>;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated Use sdk.threads.list() instead
|
|
66
|
+
*/
|
|
67
|
+
listThreads(options?: {
|
|
68
|
+
integration?: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
page?: number;
|
|
71
|
+
sort?: string;
|
|
72
|
+
user?: string;
|
|
73
|
+
workspace?: string;
|
|
74
|
+
[key: string]: string | number;
|
|
75
|
+
}): Promise<IThread[]>;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use sdk.threads.delete() instead
|
|
78
|
+
*/
|
|
79
|
+
deleteThread(threadId: string): Promise<{
|
|
80
|
+
success: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Use sdk.chat.chat() instead
|
|
84
|
+
*/
|
|
85
|
+
chatCompletion(integrationId: string, options: IChatCompletionOptions): Promise<IChatCompletionResponse>;
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use sdk.chat.chatInThread() instead
|
|
88
|
+
*/
|
|
89
|
+
chatCompletionInThread(integrationId: string, threadId: string, options: IChatCompletionOptions): Promise<IChatCompletionResponse>;
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use sdk.chat.stream() instead
|
|
92
|
+
*/
|
|
93
|
+
streamChat(integrationId: string, options: IChatCompletionOptions): Promise<ReadableStream<Uint8Array>>;
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated Use sdk.chat.streamInThread() instead
|
|
96
|
+
*/
|
|
97
|
+
streamChatInThread(integrationId: string, threadId: string, options: IChatCompletionOptions): Promise<ReadableStream<Uint8Array>>;
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated Use sdk.chat.parseSSEStream() instead
|
|
100
|
+
*/
|
|
101
|
+
parseSSEStream(stream: ReadableStream<Uint8Array>): ISSEStreamProcessor;
|
|
102
|
+
}
|
package/dist/ai.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import BaseSDK from './base-sdk';
|
|
2
|
+
import ThreadsSDK from './ai/threads';
|
|
3
|
+
import ChatSDK from './ai/chat';
|
|
4
|
+
import RAGSDK from './ai/rag';
|
|
5
|
+
/**
|
|
6
|
+
* Qelos AI SDK - Main SDK class with three sub-SDKs
|
|
7
|
+
*
|
|
8
|
+
* This class provides access to AI functionality through three sub-SDKs:
|
|
9
|
+
* - `threads`: Thread CRUD operations for managing conversation threads
|
|
10
|
+
* - `chat`: Chat completion operations (streaming and non-streaming)
|
|
11
|
+
* - `rag`: Vector storage management for Retrieval-Augmented Generation
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const sdk = new QelosSDK({
|
|
16
|
+
* appUrl: 'https://your-qelos-instance.com',
|
|
17
|
+
* fetch: globalThis.fetch,
|
|
18
|
+
* accessToken: 'your-token'
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Create a thread
|
|
22
|
+
* const thread = await sdk.ai.threads.create({ integration: 'id' });
|
|
23
|
+
*
|
|
24
|
+
* // Stream chat
|
|
25
|
+
* const stream = await sdk.ai.chat.stream('id', { messages: [...] });
|
|
26
|
+
* for await (const chunk of sdk.ai.chat.parseSSEStream(stream)) {
|
|
27
|
+
* console.log(chunk);
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* // Upload RAG content
|
|
31
|
+
* await sdk.ai.rag.uploadContent('sourceId', { content: '...' });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
// Main AI SDK with sub-SDKs
|
|
35
|
+
export default class QlAI extends BaseSDK {
|
|
36
|
+
/**
|
|
37
|
+
* Threads sub-SDK for managing conversation threads
|
|
38
|
+
*/
|
|
39
|
+
threads;
|
|
40
|
+
/**
|
|
41
|
+
* Chat sub-SDK for chat completion operations
|
|
42
|
+
*/
|
|
43
|
+
chat;
|
|
44
|
+
/**
|
|
45
|
+
* RAG sub-SDK for vector storage management
|
|
46
|
+
*/
|
|
47
|
+
rag;
|
|
48
|
+
/**
|
|
49
|
+
* Initialize the AI SDK with sub-SDKs
|
|
50
|
+
*
|
|
51
|
+
* @param options - SDK configuration options
|
|
52
|
+
*/
|
|
53
|
+
constructor(options) {
|
|
54
|
+
super(options);
|
|
55
|
+
this.threads = new ThreadsSDK(options);
|
|
56
|
+
this.chat = new ChatSDK(options);
|
|
57
|
+
this.rag = new RAGSDK(options);
|
|
58
|
+
}
|
|
59
|
+
// Legacy methods for backward compatibility
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use sdk.threads.create() instead
|
|
62
|
+
*/
|
|
63
|
+
createThread(data) {
|
|
64
|
+
return this.threads.create(data);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated Use sdk.threads.getOne() instead
|
|
68
|
+
*/
|
|
69
|
+
getThread(threadId) {
|
|
70
|
+
return this.threads.getOne(threadId);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated Use sdk.threads.list() instead
|
|
74
|
+
*/
|
|
75
|
+
listThreads(options) {
|
|
76
|
+
return this.threads.list(options);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated Use sdk.threads.delete() instead
|
|
80
|
+
*/
|
|
81
|
+
deleteThread(threadId) {
|
|
82
|
+
return this.threads.delete(threadId);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Use sdk.chat.chat() instead
|
|
86
|
+
*/
|
|
87
|
+
chatCompletion(integrationId, options) {
|
|
88
|
+
return this.chat.chat(integrationId, options);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use sdk.chat.chatInThread() instead
|
|
92
|
+
*/
|
|
93
|
+
chatCompletionInThread(integrationId, threadId, options) {
|
|
94
|
+
return this.chat.chatInThread(integrationId, threadId, options);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated Use sdk.chat.stream() instead
|
|
98
|
+
*/
|
|
99
|
+
async streamChat(integrationId, options) {
|
|
100
|
+
return this.chat.stream(integrationId, options);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @deprecated Use sdk.chat.streamInThread() instead
|
|
104
|
+
*/
|
|
105
|
+
async streamChatInThread(integrationId, threadId, options) {
|
|
106
|
+
return this.chat.streamInThread(integrationId, threadId, options);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated Use sdk.chat.parseSSEStream() instead
|
|
110
|
+
*/
|
|
111
|
+
parseSSEStream(stream) {
|
|
112
|
+
return this.chat.parseSSEStream(stream);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=ai.js.map
|
package/d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,CACZ,aAAqB,EACrB,OAA+B;QAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,sBAAsB,CACpB,aAAqB,EACrB,QAAgB,EAChB,OAA+B;QAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CACd,aAAqB,EACrB,OAA+B;QAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CACtB,aAAqB,EACrB,QAAgB,EAChB,OAA+B;QAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,MAAkC;QAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
package/dist/blueprints.d.ts
CHANGED
|
@@ -15,4 +15,11 @@ export default class QlBlueprints extends BaseSDK {
|
|
|
15
15
|
getCount(blueprintKey: string, query?: Record<string, any>): Promise<{
|
|
16
16
|
count: number;
|
|
17
17
|
}>;
|
|
18
|
+
getSum(blueprintKey: string, sumProperty: string, groupByProperty?: string, query?: Record<string, any>): Promise<{
|
|
19
|
+
groups?: Array<{
|
|
20
|
+
group: any;
|
|
21
|
+
sum: number;
|
|
22
|
+
}>;
|
|
23
|
+
sum: number;
|
|
24
|
+
}>;
|
|
18
25
|
}
|
package/dist/blueprints.js
CHANGED
|
@@ -32,5 +32,9 @@ export default class QlBlueprints extends BaseSDK {
|
|
|
32
32
|
const qs = this.getQueryParams(query);
|
|
33
33
|
return this.callJsonApi(`${this.relativePath}/${blueprintKey}/charts/count${qs}`);
|
|
34
34
|
}
|
|
35
|
+
getSum(blueprintKey, sumProperty, groupByProperty, query) {
|
|
36
|
+
const qs = this.getQueryParams({ ...query, sum: sumProperty, ...(groupByProperty && { groupBy: groupByProperty }) });
|
|
37
|
+
return this.callJsonApi(`${this.relativePath}/${blueprintKey}/charts/sum${qs}`);
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
//# sourceMappingURL=blueprints.js.map
|
package/dist/blueprints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blueprints.js","sourceRoot":"","sources":["../src/blueprints.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAK3B;IAJZ,YAAY,GAAG,iBAAiB,CAAC;IAEzC,SAAS,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEnD,YAAoB,OAAwB;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;QADI,YAAO,GAAP,OAAO,CAAiB;IAE5C,CAAC;IAED,YAAY,CAAC,GAAW;QACtB,OAAO,IAAI,CAAC,WAAW,CAAa,GAAG,IAAI,CAAC,YAAY,IAAI,GAAG,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,WAAW,CAAe,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3D,CAAC;IAED,UAAU,CAAU,YAAoB;QACtC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACrC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,mBAAmB,CAAI,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;SAC1F;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,C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W,EAAE,GAAG,CAAC,eAAe,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC;QACrH,OAAO,IAAI,CAAC,WAAW,CAA+D,GAAG,IAAI,CAAC,YAAY,IAAI,YAAY,cAAc,EAAE,EAAE,CAAC,CAAC;IAChJ,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import QlAuthentication from './authentication';
|
|
|
6
6
|
import QlWorkspaces from './workspaces';
|
|
7
7
|
import QlInvites from './invites';
|
|
8
8
|
import QlBlueprints from './blueprints';
|
|
9
|
+
import QlAI from './ai';
|
|
10
|
+
import QlLambdas from './lambdas';
|
|
9
11
|
export default class QelosSDK extends BaseSDK {
|
|
10
12
|
#private;
|
|
11
13
|
private options;
|
|
@@ -15,6 +17,8 @@ export default class QelosSDK extends BaseSDK {
|
|
|
15
17
|
workspaces: QlWorkspaces;
|
|
16
18
|
invites: QlInvites;
|
|
17
19
|
blueprints: QlBlueprints;
|
|
20
|
+
ai: QlAI;
|
|
21
|
+
lambdas: QlLambdas;
|
|
18
22
|
constructor(options: QelosSDKOptions);
|
|
19
23
|
setCustomHeader(key: string, value: string): void;
|
|
20
24
|
removeCustomHeader(key: string): void;
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@ import QlAuthentication from './authentication';
|
|
|
5
5
|
import QlWorkspaces from './workspaces';
|
|
6
6
|
import QlInvites from './invites';
|
|
7
7
|
import QlBlueprints from './blueprints';
|
|
8
|
+
import QlAI from './ai';
|
|
9
|
+
import QlLambdas from './lambdas';
|
|
8
10
|
const noExtraHeadersUrls = new Set(['/api/token/refresh', '/api/signin', '/api/signup']);
|
|
9
11
|
export default class QelosSDK extends BaseSDK {
|
|
10
12
|
options;
|
|
@@ -15,6 +17,8 @@ export default class QelosSDK extends BaseSDK {
|
|
|
15
17
|
workspaces;
|
|
16
18
|
invites;
|
|
17
19
|
blueprints;
|
|
20
|
+
ai;
|
|
21
|
+
lambdas;
|
|
18
22
|
constructor(options) {
|
|
19
23
|
super(options);
|
|
20
24
|
this.options = options;
|
|
@@ -24,6 +28,8 @@ export default class QelosSDK extends BaseSDK {
|
|
|
24
28
|
this.workspaces = new QlWorkspaces(this.options);
|
|
25
29
|
this.invites = new QlInvites(this.options);
|
|
26
30
|
this.blueprints = new QlBlueprints(this.options);
|
|
31
|
+
this.ai = new QlAI(this.options);
|
|
32
|
+
this.lambdas = new QlLambdas(this.options);
|
|
27
33
|
const isBrowser = globalThis.navigator && globalThis.window && globalThis.document;
|
|
28
34
|
if (!options.getAccessToken) {
|
|
29
35
|
options.getAccessToken = () => this.authentication.accessToken;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,mBAAmB,MAAM,kBAAkB,CAAC;AACnD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,YAAY,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,mBAAmB,MAAM,kBAAkB,CAAC;AACnD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAA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AAW,CAAC;SAChE;QAED,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;YACzB,OAAO,CAAC,YAAY,GAAG,KAAK,EAAE,WAAmB,EAAE,YAAsB,EAAE,EAAE;gBAC3E,IAAI,SAAS,IAAI,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;oBACpD,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;iBACnC;gBACD,IAAI,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;gBACzD,IAAI,CAAC,KAAK,EAAE;oBACV,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;oBACzC,KAAK,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;iBAClC;gBACD,IAAI,KAAK,EAAE;oBACT,OAAO,EAAE,aAAa,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;iBACpE;gBACD,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;YACnC,CAAC,CAAA;SACF;IACH,CAAC;IAED,eAAe,CAAC,GAAW,EAAE,KAAa;QACxC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnC,CAAC;IAED,kBAAkB,CAAC,GAAW;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseSDK from "./base-sdk";
|
|
2
|
+
import { QelosSDKOptions } from "./types";
|
|
3
|
+
export default class QlLambdas extends BaseSDK {
|
|
4
|
+
private options;
|
|
5
|
+
private relativePath;
|
|
6
|
+
constructor(options: QelosSDKOptions);
|
|
7
|
+
execute(integrationId: string, data?: RequestInit): Promise<unknown>;
|
|
8
|
+
get(integrationId: string, data?: RequestInit): Promise<unknown>;
|
|
9
|
+
post(integrationId: string, data?: RequestInit): Promise<unknown>;
|
|
10
|
+
put(integrationId: string, data?: RequestInit): Promise<unknown>;
|
|
11
|
+
delete(integrationId: string, data?: RequestInit): Promise<unknown>;
|
|
12
|
+
}
|
package/dist/lambdas.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import BaseSDK from "./base-sdk";
|
|
2
|
+
export default class QlLambdas extends BaseSDK {
|
|
3
|
+
options;
|
|
4
|
+
relativePath = '/api/webhooks';
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super(options);
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
execute(integrationId, data) {
|
|
10
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, data);
|
|
11
|
+
}
|
|
12
|
+
get(integrationId, data) {
|
|
13
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, data);
|
|
14
|
+
}
|
|
15
|
+
post(integrationId, data) {
|
|
16
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
body: data?.body ? JSON.stringify(data?.body) : undefined,
|
|
19
|
+
headers: { 'content-type': 'application/json' },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
put(integrationId, data) {
|
|
23
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
|
|
24
|
+
method: 'PUT',
|
|
25
|
+
body: data?.body ? JSON.stringify(data?.body) : undefined,
|
|
26
|
+
headers: { 'content-type': 'application/json' },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
delete(integrationId, data) {
|
|
30
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
|
|
31
|
+
...data,
|
|
32
|
+
method: 'DELETE',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=lambdas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambdas.js","sourceRoot":"","sources":["../src/lambdas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D,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,aAAqB,EAAE,IAAkB;QAC9C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE,EAAE;YAC/D,GAAG,IAAI;YACP,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// Example usage of the new Qelos AI SDK with sub-SDKs
|
|
2
|
+
|
|
3
|
+
import QelosSDK from '../src';
|
|
4
|
+
// Alternatively, you can import specific sub-SDKs:
|
|
5
|
+
// import { ThreadsSDK, ChatSDK, RAGSDK } from '../src/ai';
|
|
6
|
+
|
|
7
|
+
// Initialize the SDK
|
|
8
|
+
const sdk = new QelosSDK({
|
|
9
|
+
appUrl: 'https://your-qelos-instance.com',
|
|
10
|
+
fetch: globalThis.fetch || require('node-fetch'),
|
|
11
|
+
accessToken: 'your-access-token'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// ===== THREADS SUB-SDK =====
|
|
15
|
+
async function threadExamples() {
|
|
16
|
+
// Create a new thread
|
|
17
|
+
const thread = await sdk.ai.threads.create({
|
|
18
|
+
integration: 'integration-id',
|
|
19
|
+
title: 'Customer Support Chat'
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Get a specific thread
|
|
23
|
+
const retrievedThread = await sdk.ai.threads.getOne(thread._id!);
|
|
24
|
+
|
|
25
|
+
// List threads with filters
|
|
26
|
+
const threads = await sdk.ai.threads.list({
|
|
27
|
+
integration: 'integration-id',
|
|
28
|
+
limit: 10,
|
|
29
|
+
page: 1
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Delete a thread
|
|
33
|
+
await sdk.ai.threads.delete(thread._id!);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ===== CHAT SUB-SDK =====
|
|
37
|
+
async function chatExamples() {
|
|
38
|
+
const integrationId = 'your-integration-id';
|
|
39
|
+
const messages = [
|
|
40
|
+
{ role: 'user', content: 'Hello, how can you help me?' }
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
// Non-streaming chat
|
|
44
|
+
const response = await sdk.ai.chat.chat(integrationId, {
|
|
45
|
+
messages,
|
|
46
|
+
model: 'gpt-4',
|
|
47
|
+
temperature: 0.7,
|
|
48
|
+
queryParams: { bypassAdmin: true } // Optional query params
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
console.log(response.choices[0].message.content);
|
|
52
|
+
|
|
53
|
+
// Streaming chat
|
|
54
|
+
const stream = await sdk.ai.chat.stream(integrationId, {
|
|
55
|
+
messages,
|
|
56
|
+
stream: true
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Parse the SSE stream
|
|
60
|
+
const processor = sdk.ai.chat.parseSSEStream(stream);
|
|
61
|
+
for await (const chunk of processor) {
|
|
62
|
+
if (chunk.choices?.[0]?.delta?.content) {
|
|
63
|
+
console.log(chunk.choices[0].delta.content);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Chat in a thread
|
|
68
|
+
const threadId = 'thread-id';
|
|
69
|
+
const threadResponse = await sdk.ai.chat.chatInThread(integrationId, threadId, {
|
|
70
|
+
messages
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Streaming chat in a thread
|
|
74
|
+
const threadStream = await sdk.ai.chat.streamInThread(integrationId, threadId, {
|
|
75
|
+
messages,
|
|
76
|
+
stream: true
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
for await (const chunk of sdk.ai.chat.parseSSEStream(threadStream)) {
|
|
80
|
+
console.log(chunk);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ===== RAG SUB-SDK =====
|
|
85
|
+
async function ragExamples() {
|
|
86
|
+
const sourceId = 'your-ai-source-id';
|
|
87
|
+
|
|
88
|
+
// Create vector storage
|
|
89
|
+
const storage = await sdk.ai.rag.createStorage(sourceId, {
|
|
90
|
+
integrationId: 'integration-id',
|
|
91
|
+
scope: 'thread', // 'thread' | 'user' | 'workspace' | 'tenant'
|
|
92
|
+
subjectId: 'thread-id', // Required for non-tenant scopes
|
|
93
|
+
expirationAfterDays: 30
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Upload content to storage
|
|
97
|
+
const uploadResult = await sdk.ai.rag.uploadContent(sourceId, {
|
|
98
|
+
integrationId: 'integration-id',
|
|
99
|
+
content: 'This is the content to be indexed for RAG.',
|
|
100
|
+
fileName: 'document.txt',
|
|
101
|
+
metadata: { type: 'documentation', category: 'help' }
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Upload JSON content
|
|
105
|
+
const jsonUpload = await sdk.ai.rag.uploadContent(sourceId, {
|
|
106
|
+
integrationId: 'integration-id',
|
|
107
|
+
content: { title: 'Product Info', description: '...' },
|
|
108
|
+
fileName: 'product-info.json'
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Clear specific files
|
|
112
|
+
const clearResult = await sdk.ai.rag.clearStorage(sourceId, {
|
|
113
|
+
integrationId: 'integration-id',
|
|
114
|
+
fileIds: [uploadResult.fileId]
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Clear all files (if no fileIds provided)
|
|
118
|
+
await sdk.ai.rag.clearStorage(sourceId, {
|
|
119
|
+
integrationId: 'integrationId'
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Get vector stores (internal API - server-side only)
|
|
123
|
+
const stores = await sdk.ai.rag.getVectorStores({
|
|
124
|
+
scope: 'thread',
|
|
125
|
+
subjectId: 'thread-id'
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ===== COMBINED EXAMPLE =====
|
|
130
|
+
async function combinedExample() {
|
|
131
|
+
// 1. Create a thread
|
|
132
|
+
const thread = await sdk.ai.threads.create({
|
|
133
|
+
integration: 'integration-id',
|
|
134
|
+
title: 'RAG-enabled Chat'
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// 2. Upload knowledge base content
|
|
138
|
+
await sdk.ai.rag.uploadContent('source-id', {
|
|
139
|
+
integrationId: 'integration-id',
|
|
140
|
+
content: 'Your knowledge base content here...',
|
|
141
|
+
fileName: 'knowledge-base.txt'
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// 3. Chat with RAG
|
|
145
|
+
const stream = await sdk.ai.chat.streamInThread(
|
|
146
|
+
'integration-id',
|
|
147
|
+
thread._id!,
|
|
148
|
+
{
|
|
149
|
+
messages: [
|
|
150
|
+
{ role: 'user', content: 'What do you know about the topic?' }
|
|
151
|
+
],
|
|
152
|
+
stream: true
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// 4. Process the response
|
|
157
|
+
for await (const chunk of sdk.ai.chat.parseSSEStream(stream)) {
|
|
158
|
+
if (chunk.choices?.[0]?.delta?.content) {
|
|
159
|
+
console.log(chunk.choices[0].delta.content);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Export for reference
|
|
165
|
+
export {
|
|
166
|
+
threadExamples,
|
|
167
|
+
chatExamples,
|
|
168
|
+
ragExamples,
|
|
169
|
+
combinedExample
|
|
170
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import BaseSDK from "../base-sdk";
|
|
2
|
+
import { QelosSDKOptions } from "../types";
|
|
3
|
+
|
|
4
|
+
export default class QlManageLambdas extends BaseSDK {
|
|
5
|
+
private relativePath = '/api/lambdas';
|
|
6
|
+
|
|
7
|
+
constructor(private options: QelosSDKOptions) {
|
|
8
|
+
super(options)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public getList(sourceId: string) {
|
|
12
|
+
return this.callJsonApi(`${this.relativePath}/${sourceId}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public getLambda(sourceId: string, functionName: string) {
|
|
16
|
+
return this.callJsonApi(`${this.relativePath}/${sourceId}/${functionName}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public create(sourceId: string, data: any) {
|
|
20
|
+
return this.callJsonApi(`${this.relativePath}/${sourceId}`, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
body: JSON.stringify(data),
|
|
23
|
+
headers: { 'content-type': 'application/json' },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public update(sourceId: string, functionName: string, data: any) {
|
|
28
|
+
return this.callJsonApi(`${this.relativePath}/${sourceId}/${functionName}`, {
|
|
29
|
+
method: 'PUT',
|
|
30
|
+
body: JSON.stringify(data),
|
|
31
|
+
headers: { 'content-type': 'application/json' },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public remove(sourceId: string, functionName: string) {
|
|
36
|
+
return this.callApi(`${this.relativePath}/${sourceId}/${functionName}`, { method: 'DELETE' });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -10,9 +10,12 @@ 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
|
|
|
14
16
|
|
|
15
17
|
export default class QelosAdministratorSDK<T = any> extends QelosSDK {
|
|
18
|
+
manageLambdas: QlManageLambdas;
|
|
16
19
|
users: QlUsers<T>;
|
|
17
20
|
manageConfigurations: QlManageConfigurations;
|
|
18
21
|
manageBlueprints: QlManageBlueprints;
|
|
@@ -23,9 +26,11 @@ export default class QelosAdministratorSDK<T = any> extends QelosSDK {
|
|
|
23
26
|
integrationSources: QlIntegrationSources;
|
|
24
27
|
managePlugins: QlManagePlugins;
|
|
25
28
|
components: QlComponents;
|
|
29
|
+
integrations: QlIntegrations;
|
|
26
30
|
|
|
27
31
|
constructor(options: QelosSDKOptions) {
|
|
28
32
|
super(options);
|
|
33
|
+
this.manageLambdas = new QlManageLambdas(options);
|
|
29
34
|
this.users = new QlUsers<T>(options);
|
|
30
35
|
this.manageConfigurations = new QlManageConfigurations(options);
|
|
31
36
|
this.manageBlueprints = new QlManageBlueprints(options);
|
|
@@ -36,6 +41,7 @@ export default class QelosAdministratorSDK<T = any> extends QelosSDK {
|
|
|
36
41
|
this.integrationSources = new QlIntegrationSources(options);
|
|
37
42
|
this.managePlugins = new QlManagePlugins(options);
|
|
38
43
|
this.components = new QlComponents(options);
|
|
44
|
+
this.integrations = new QlIntegrations(options);
|
|
39
45
|
|
|
40
46
|
if (!options.extraQueryParams) {
|
|
41
47
|
options.extraQueryParams = () => ({
|
|
@@ -55,4 +61,4 @@ export default class QelosAdministratorSDK<T = any> extends QelosSDK {
|
|
|
55
61
|
this.removeCustomHeader('x-impersonate-user');
|
|
56
62
|
this.removeCustomHeader('x-impersonate-workspace');
|
|
57
63
|
}
|
|
58
|
-
}
|
|
64
|
+
}
|