@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/src/ai.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
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 {
|
|
7
|
+
IMessage,
|
|
8
|
+
IMessageSummary,
|
|
9
|
+
IThread,
|
|
10
|
+
IChatCompletionOptions,
|
|
11
|
+
ISSEStreamProcessor,
|
|
12
|
+
IChatCompletionResponse,
|
|
13
|
+
ICreateThreadRequest,
|
|
14
|
+
ICreateVectorStorageRequest,
|
|
15
|
+
IUploadContentRequest,
|
|
16
|
+
IClearStorageRequest,
|
|
17
|
+
IVectorStore
|
|
18
|
+
} from './ai/types';
|
|
19
|
+
|
|
20
|
+
// Re-export types for backward compatibility
|
|
21
|
+
export {
|
|
22
|
+
IMessage,
|
|
23
|
+
IMessageSummary,
|
|
24
|
+
IThread,
|
|
25
|
+
IChatCompletionOptions,
|
|
26
|
+
ISSEStreamProcessor,
|
|
27
|
+
IChatCompletionResponse,
|
|
28
|
+
ICreateThreadRequest,
|
|
29
|
+
ICreateVectorStorageRequest,
|
|
30
|
+
IUploadContentRequest,
|
|
31
|
+
IClearStorageRequest,
|
|
32
|
+
IVectorStore
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Qelos AI SDK - Main SDK class with three sub-SDKs
|
|
37
|
+
*
|
|
38
|
+
* This class provides access to AI functionality through three sub-SDKs:
|
|
39
|
+
* - `threads`: Thread CRUD operations for managing conversation threads
|
|
40
|
+
* - `chat`: Chat completion operations (streaming and non-streaming)
|
|
41
|
+
* - `rag`: Vector storage management for Retrieval-Augmented Generation
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const sdk = new QelosSDK({
|
|
46
|
+
* appUrl: 'https://your-qelos-instance.com',
|
|
47
|
+
* fetch: globalThis.fetch,
|
|
48
|
+
* accessToken: 'your-token'
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Create a thread
|
|
52
|
+
* const thread = await sdk.ai.threads.create({ integration: 'id' });
|
|
53
|
+
*
|
|
54
|
+
* // Stream chat
|
|
55
|
+
* const stream = await sdk.ai.chat.stream('id', { messages: [...] });
|
|
56
|
+
* for await (const chunk of sdk.ai.chat.parseSSEStream(stream)) {
|
|
57
|
+
* console.log(chunk);
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* // Upload RAG content
|
|
61
|
+
* await sdk.ai.rag.uploadContent('sourceId', { content: '...' });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
// Main AI SDK with sub-SDKs
|
|
65
|
+
export default class QlAI extends BaseSDK {
|
|
66
|
+
/**
|
|
67
|
+
* Threads sub-SDK for managing conversation threads
|
|
68
|
+
*/
|
|
69
|
+
public threads: ThreadsSDK;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Chat sub-SDK for chat completion operations
|
|
73
|
+
*/
|
|
74
|
+
public chat: ChatSDK;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* RAG sub-SDK for vector storage management
|
|
78
|
+
*/
|
|
79
|
+
public rag: RAGSDK;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Initialize the AI SDK with sub-SDKs
|
|
83
|
+
*
|
|
84
|
+
* @param options - SDK configuration options
|
|
85
|
+
*/
|
|
86
|
+
constructor(options: QelosSDKOptions) {
|
|
87
|
+
super(options);
|
|
88
|
+
this.threads = new ThreadsSDK(options);
|
|
89
|
+
this.chat = new ChatSDK(options);
|
|
90
|
+
this.rag = new RAGSDK(options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Legacy methods for backward compatibility
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated Use sdk.threads.create() instead
|
|
97
|
+
*/
|
|
98
|
+
createThread(data: ICreateThreadRequest): Promise<IThread> {
|
|
99
|
+
return this.threads.create(data);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @deprecated Use sdk.threads.getOne() instead
|
|
104
|
+
*/
|
|
105
|
+
getThread(threadId: string): Promise<IThread> {
|
|
106
|
+
return this.threads.getOne(threadId);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated Use sdk.threads.list() instead
|
|
111
|
+
*/
|
|
112
|
+
listThreads(options?: {
|
|
113
|
+
integration?: string;
|
|
114
|
+
limit?: number;
|
|
115
|
+
page?: number;
|
|
116
|
+
sort?: string;
|
|
117
|
+
user?: string;
|
|
118
|
+
workspace?: string;
|
|
119
|
+
[key: string]: string | number;
|
|
120
|
+
}): Promise<IThread[]> {
|
|
121
|
+
return this.threads.list(options);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated Use sdk.threads.delete() instead
|
|
126
|
+
*/
|
|
127
|
+
deleteThread(threadId: string): Promise<{ success: boolean }> {
|
|
128
|
+
return this.threads.delete(threadId);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated Use sdk.chat.chat() instead
|
|
133
|
+
*/
|
|
134
|
+
chatCompletion(
|
|
135
|
+
integrationId: string,
|
|
136
|
+
options: IChatCompletionOptions
|
|
137
|
+
): Promise<IChatCompletionResponse> {
|
|
138
|
+
return this.chat.chat(integrationId, options);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated Use sdk.chat.chatInThread() instead
|
|
143
|
+
*/
|
|
144
|
+
chatCompletionInThread(
|
|
145
|
+
integrationId: string,
|
|
146
|
+
threadId: string,
|
|
147
|
+
options: IChatCompletionOptions
|
|
148
|
+
): Promise<IChatCompletionResponse> {
|
|
149
|
+
return this.chat.chatInThread(integrationId, threadId, options);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @deprecated Use sdk.chat.stream() instead
|
|
154
|
+
*/
|
|
155
|
+
async streamChat(
|
|
156
|
+
integrationId: string,
|
|
157
|
+
options: IChatCompletionOptions
|
|
158
|
+
): Promise<ReadableStream<Uint8Array>> {
|
|
159
|
+
return this.chat.stream(integrationId, options);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @deprecated Use sdk.chat.streamInThread() instead
|
|
164
|
+
*/
|
|
165
|
+
async streamChatInThread(
|
|
166
|
+
integrationId: string,
|
|
167
|
+
threadId: string,
|
|
168
|
+
options: IChatCompletionOptions
|
|
169
|
+
): Promise<ReadableStream<Uint8Array>> {
|
|
170
|
+
return this.chat.streamInThread(integrationId, threadId, options);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated Use sdk.chat.parseSSEStream() instead
|
|
175
|
+
*/
|
|
176
|
+
parseSSEStream(stream: ReadableStream<Uint8Array>): ISSEStreamProcessor {
|
|
177
|
+
return this.chat.parseSSEStream(stream);
|
|
178
|
+
}
|
|
179
|
+
}
|
package/src/blueprints.ts
CHANGED
|
@@ -41,4 +41,9 @@ export default class QlBlueprints extends BaseSDK {
|
|
|
41
41
|
const qs = this.getQueryParams(query);
|
|
42
42
|
return this.callJsonApi<{ count: number }>(`${this.relativePath}/${blueprintKey}/charts/count${qs}`);
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
getSum(blueprintKey: string, sumProperty: string, groupByProperty?: string, query?: Record<string, any>) {
|
|
46
|
+
const qs = this.getQueryParams({ ...query, sum: sumProperty, ...(groupByProperty && { groupBy: groupByProperty }) });
|
|
47
|
+
return this.callJsonApi<{ groups?: Array<{ group: any; sum: number }>; sum: number }>(`${this.relativePath}/${blueprintKey}/charts/sum${qs}`);
|
|
48
|
+
}
|
|
44
49
|
}
|
package/src/index.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
|
|
|
10
12
|
const noExtraHeadersUrls = new Set(['/api/token/refresh', '/api/signin', '/api/signup'])
|
|
11
13
|
|
|
@@ -18,6 +20,8 @@ export default class QelosSDK extends BaseSDK {
|
|
|
18
20
|
workspaces: QlWorkspaces;
|
|
19
21
|
invites: QlInvites;
|
|
20
22
|
blueprints: QlBlueprints;
|
|
23
|
+
ai: QlAI;
|
|
24
|
+
lambdas: QlLambdas;
|
|
21
25
|
|
|
22
26
|
constructor(private options: QelosSDKOptions) {
|
|
23
27
|
super(options);
|
|
@@ -27,6 +31,8 @@ export default class QelosSDK extends BaseSDK {
|
|
|
27
31
|
this.workspaces = new QlWorkspaces(this.options);
|
|
28
32
|
this.invites = new QlInvites(this.options);
|
|
29
33
|
this.blueprints = new QlBlueprints(this.options);
|
|
34
|
+
this.ai = new QlAI(this.options);
|
|
35
|
+
this.lambdas = new QlLambdas(this.options);
|
|
30
36
|
|
|
31
37
|
const isBrowser = globalThis.navigator && globalThis.window && globalThis.document
|
|
32
38
|
|
|
@@ -59,5 +65,4 @@ export default class QelosSDK extends BaseSDK {
|
|
|
59
65
|
removeCustomHeader(key: string) {
|
|
60
66
|
delete this.#customHeaders[key];
|
|
61
67
|
}
|
|
62
|
-
|
|
63
|
-
}
|
|
68
|
+
}
|
package/src/lambdas.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import BaseSDK from "./base-sdk";
|
|
2
|
+
import { QelosSDKOptions } from "./types";
|
|
3
|
+
|
|
4
|
+
export default class QlLambdas extends BaseSDK {
|
|
5
|
+
private relativePath = '/api/webhooks';
|
|
6
|
+
|
|
7
|
+
constructor(private options: QelosSDKOptions) {
|
|
8
|
+
super(options)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
execute(integrationId: string, data?: RequestInit) {
|
|
12
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, data);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get(integrationId: string, data?: RequestInit) {
|
|
16
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, data);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
post(integrationId: string, data?: RequestInit) {
|
|
20
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
body: data?.body ? JSON.stringify(data?.body) : undefined,
|
|
23
|
+
headers: { 'content-type': 'application/json' },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
put(integrationId: string, data?: RequestInit) {
|
|
28
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
|
|
29
|
+
method: 'PUT',
|
|
30
|
+
body: data?.body ? JSON.stringify(data?.body) : undefined,
|
|
31
|
+
headers: { 'content-type': 'application/json' },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
delete(integrationId: string, data?: RequestInit) {
|
|
36
|
+
return this.callJsonApi(`${this.relativePath}/${integrationId}`, {
|
|
37
|
+
...data,
|
|
38
|
+
method: 'DELETE',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|