@qelos/sdk 3.11.4 → 3.11.5
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/chat.d.ts +1 -1
- package/dist/ai/index.d.ts +102 -3
- package/dist/ai/index.js +114 -3
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/rag.d.ts +2 -2
- package/dist/ai/rag.js +1 -1
- package/dist/ai/threads.d.ts +1 -1
- package/package.json +18 -3
- package/src/ai/chat.ts +1 -1
- package/src/ai/index.ts +180 -3
- package/src/ai/rag.ts +2 -2
- package/src/ai/threads.ts +1 -1
- package/dist/ai.d.ts +0 -102
- package/dist/ai.js +0 -115
- package/dist/ai.js.map +0 -1
- package/src/ai.ts +0 -179
package/dist/ai/chat.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseSDK from '../base-sdk';
|
|
2
2
|
import { QelosSDKOptions } from '../types';
|
|
3
|
-
import { IChatCompletionOptions, IChatCompletionResponse, ISSEStreamProcessor } from '
|
|
3
|
+
import { IChatCompletionOptions, IChatCompletionResponse, ISSEStreamProcessor } from '.';
|
|
4
4
|
export default class ChatSDK extends BaseSDK {
|
|
5
5
|
private relativePath;
|
|
6
6
|
constructor(options: QelosSDKOptions);
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,4 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { QelosSDKOptions } from '../types';
|
|
2
|
+
import BaseSDK from '../base-sdk';
|
|
3
|
+
import ThreadsSDK from './threads';
|
|
4
|
+
import ChatSDK from './chat';
|
|
5
|
+
import RagSDK from './rag';
|
|
6
|
+
import { IMessage, IMessageSummary, IThread, IChatCompletionOptions, ISSEStreamProcessor, IChatCompletionResponse, ICreateThreadRequest, ICreateVectorStorageRequest, IUploadContentRequest, IClearStorageRequest, IVectorStore } from './types';
|
|
4
7
|
export * from './types';
|
|
8
|
+
export { IMessage, IMessageSummary, IThread, IChatCompletionOptions, ISSEStreamProcessor, IChatCompletionResponse, ICreateThreadRequest, ICreateVectorStorageRequest, IUploadContentRequest, IClearStorageRequest, IVectorStore };
|
|
9
|
+
/**
|
|
10
|
+
* Qelos AI SDK - Main SDK class with three sub-SDKs
|
|
11
|
+
*
|
|
12
|
+
* This class provides access to AI functionality through three sub-SDKs:
|
|
13
|
+
* - `threads`: Thread CRUD operations for managing conversation threads
|
|
14
|
+
* - `chat`: Chat completion operations (streaming and non-streaming)
|
|
15
|
+
* - `rag`: Vector storage management for Retrieval-Augmented Generation
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const sdk = new QelosSDK({
|
|
20
|
+
* appUrl: 'https://your-qelos-instance.com',
|
|
21
|
+
* fetch: globalThis.fetch,
|
|
22
|
+
* accessToken: 'your-token'
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Create a thread
|
|
26
|
+
* const thread = await sdk.ai.threads.create({ integration: 'id' });
|
|
27
|
+
*
|
|
28
|
+
* // Stream chat
|
|
29
|
+
* const stream = await sdk.ai.chat.stream('id', { messages: [...] });
|
|
30
|
+
* for await (const chunk of sdk.ai.chat.parseSSEStream(stream)) {
|
|
31
|
+
* console.log(chunk);
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* // Upload RAG content
|
|
35
|
+
* await sdk.ai.rag.uploadContent('sourceId', { content: '...' });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export default class QlAI extends BaseSDK {
|
|
39
|
+
/**
|
|
40
|
+
* Threads sub-SDK for managing conversation threads
|
|
41
|
+
*/
|
|
42
|
+
threads: ThreadsSDK;
|
|
43
|
+
/**
|
|
44
|
+
* Chat sub-SDK for chat completion operations
|
|
45
|
+
*/
|
|
46
|
+
chat: ChatSDK;
|
|
47
|
+
/**
|
|
48
|
+
* RAG sub-SDK for vector storage management
|
|
49
|
+
*/
|
|
50
|
+
rag: RagSDK;
|
|
51
|
+
/**
|
|
52
|
+
* Initialize the AI SDK with sub-SDKs
|
|
53
|
+
*
|
|
54
|
+
* @param options - SDK configuration options
|
|
55
|
+
*/
|
|
56
|
+
constructor(options: QelosSDKOptions);
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use sdk.threads.create() instead
|
|
59
|
+
*/
|
|
60
|
+
createThread(data: ICreateThreadRequest): Promise<IThread>;
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use sdk.threads.getOne() instead
|
|
63
|
+
*/
|
|
64
|
+
getThread(threadId: string): Promise<IThread>;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Use sdk.threads.list() instead
|
|
67
|
+
*/
|
|
68
|
+
listThreads(options?: {
|
|
69
|
+
integration?: string;
|
|
70
|
+
limit?: number;
|
|
71
|
+
page?: number;
|
|
72
|
+
sort?: string;
|
|
73
|
+
user?: string;
|
|
74
|
+
workspace?: string;
|
|
75
|
+
[key: string]: string | number;
|
|
76
|
+
}): Promise<IThread[]>;
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated Use sdk.threads.delete() instead
|
|
79
|
+
*/
|
|
80
|
+
deleteThread(threadId: string): Promise<{
|
|
81
|
+
success: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Use sdk.chat.chat() instead
|
|
85
|
+
*/
|
|
86
|
+
chatCompletion(integrationId: string, options: IChatCompletionOptions): Promise<IChatCompletionResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use sdk.chat.chatInThread() instead
|
|
89
|
+
*/
|
|
90
|
+
chatCompletionInThread(integrationId: string, threadId: string, options: IChatCompletionOptions): Promise<IChatCompletionResponse>;
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use sdk.chat.stream() instead
|
|
93
|
+
*/
|
|
94
|
+
streamChat(integrationId: string, options: IChatCompletionOptions): Promise<ReadableStream<Uint8Array>>;
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated Use sdk.chat.streamInThread() instead
|
|
97
|
+
*/
|
|
98
|
+
streamChatInThread(integrationId: string, threadId: string, options: IChatCompletionOptions): Promise<ReadableStream<Uint8Array>>;
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated Use sdk.chat.parseSSEStream() instead
|
|
101
|
+
*/
|
|
102
|
+
parseSSEStream(stream: ReadableStream<Uint8Array>): ISSEStreamProcessor;
|
|
103
|
+
}
|
package/dist/ai/index.js
CHANGED
|
@@ -1,5 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import BaseSDK from '../base-sdk';
|
|
2
|
+
import ThreadsSDK from './threads';
|
|
3
|
+
import ChatSDK from './chat';
|
|
4
|
+
import RagSDK from './rag';
|
|
4
5
|
export * from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Qelos AI SDK - Main SDK class with three sub-SDKs
|
|
8
|
+
*
|
|
9
|
+
* This class provides access to AI functionality through three sub-SDKs:
|
|
10
|
+
* - `threads`: Thread CRUD operations for managing conversation threads
|
|
11
|
+
* - `chat`: Chat completion operations (streaming and non-streaming)
|
|
12
|
+
* - `rag`: Vector storage management for Retrieval-Augmented Generation
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const sdk = new QelosSDK({
|
|
17
|
+
* appUrl: 'https://your-qelos-instance.com',
|
|
18
|
+
* fetch: globalThis.fetch,
|
|
19
|
+
* accessToken: 'your-token'
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Create a thread
|
|
23
|
+
* const thread = await sdk.ai.threads.create({ integration: 'id' });
|
|
24
|
+
*
|
|
25
|
+
* // Stream chat
|
|
26
|
+
* const stream = await sdk.ai.chat.stream('id', { messages: [...] });
|
|
27
|
+
* for await (const chunk of sdk.ai.chat.parseSSEStream(stream)) {
|
|
28
|
+
* console.log(chunk);
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* // Upload RAG content
|
|
32
|
+
* await sdk.ai.rag.uploadContent('sourceId', { content: '...' });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
// Main AI SDK with sub-SDKs
|
|
36
|
+
export default class QlAI extends BaseSDK {
|
|
37
|
+
/**
|
|
38
|
+
* Threads sub-SDK for managing conversation threads
|
|
39
|
+
*/
|
|
40
|
+
threads;
|
|
41
|
+
/**
|
|
42
|
+
* Chat sub-SDK for chat completion operations
|
|
43
|
+
*/
|
|
44
|
+
chat;
|
|
45
|
+
/**
|
|
46
|
+
* RAG sub-SDK for vector storage management
|
|
47
|
+
*/
|
|
48
|
+
rag;
|
|
49
|
+
/**
|
|
50
|
+
* Initialize the AI SDK with sub-SDKs
|
|
51
|
+
*
|
|
52
|
+
* @param options - SDK configuration options
|
|
53
|
+
*/
|
|
54
|
+
constructor(options) {
|
|
55
|
+
super(options);
|
|
56
|
+
this.threads = new ThreadsSDK(options);
|
|
57
|
+
this.chat = new ChatSDK(options);
|
|
58
|
+
this.rag = new RagSDK(options);
|
|
59
|
+
}
|
|
60
|
+
// Legacy methods for backward compatibility
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use sdk.threads.create() instead
|
|
63
|
+
*/
|
|
64
|
+
createThread(data) {
|
|
65
|
+
return this.threads.create(data);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated Use sdk.threads.getOne() instead
|
|
69
|
+
*/
|
|
70
|
+
getThread(threadId) {
|
|
71
|
+
return this.threads.getOne(threadId);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated Use sdk.threads.list() instead
|
|
75
|
+
*/
|
|
76
|
+
listThreads(options) {
|
|
77
|
+
return this.threads.list(options);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Use sdk.threads.delete() instead
|
|
81
|
+
*/
|
|
82
|
+
deleteThread(threadId) {
|
|
83
|
+
return this.threads.delete(threadId);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @deprecated Use sdk.chat.chat() instead
|
|
87
|
+
*/
|
|
88
|
+
chatCompletion(integrationId, options) {
|
|
89
|
+
return this.chat.chat(integrationId, options);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use sdk.chat.chatInThread() instead
|
|
93
|
+
*/
|
|
94
|
+
chatCompletionInThread(integrationId, threadId, options) {
|
|
95
|
+
return this.chat.chatInThread(integrationId, threadId, options);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated Use sdk.chat.stream() instead
|
|
99
|
+
*/
|
|
100
|
+
async streamChat(integrationId, options) {
|
|
101
|
+
return this.chat.stream(integrationId, options);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated Use sdk.chat.streamInThread() instead
|
|
105
|
+
*/
|
|
106
|
+
async streamChatInThread(integrationId, threadId, options) {
|
|
107
|
+
return this.chat.streamInThread(integrationId, threadId, options);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated Use sdk.chat.parseSSEStream() instead
|
|
111
|
+
*/
|
|
112
|
+
parseSSEStream(stream) {
|
|
113
|
+
return this.chat.parseSSEStream(stream);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
5
116
|
//# sourceMappingURL=index.js.map
|
package/dist/ai/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,OAAO,MAAM,QAAQ,CAAC;AAC7B,OAAO,MAAM,MAAM,OAAO,CAAC;AAe3B,cAAc,SAAS,CAAC;AAiBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,4BAA4B;AAC5B,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC;;OAEG;IACI,OAAO,CAAa;IAE3B;;OAEG;IACI,IAAI,CAAU;IAErB;;OAEG;IACI,GAAG,CAAS;IAEnB;;;;OAIG;IACH,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,4CAA4C;IAE5C;;OAEG;IACH,YAAY,CAAC,IAA0B;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAQX;QACC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,QAAgB;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,cAAc,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/ai/rag.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BaseSDK from '../base-sdk';
|
|
2
2
|
import { QelosSDKOptions } from '../types';
|
|
3
|
-
import { ICreateVectorStorageRequest, IUploadContentRequest, IClearStorageRequest, IVectorStore } from '
|
|
4
|
-
export default class
|
|
3
|
+
import { ICreateVectorStorageRequest, IUploadContentRequest, IClearStorageRequest, IVectorStore } from '.';
|
|
4
|
+
export default class RagSDK extends BaseSDK {
|
|
5
5
|
private relativePath;
|
|
6
6
|
constructor(options: QelosSDKOptions);
|
|
7
7
|
/**
|
package/dist/ai/rag.js
CHANGED
package/dist/ai/threads.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseSDK from '../base-sdk';
|
|
2
2
|
import { QelosSDKOptions } from '../types';
|
|
3
|
-
import { IThread, ICreateThreadRequest } from '
|
|
3
|
+
import { IThread, ICreateThreadRequest } from '.';
|
|
4
4
|
export default class ThreadsSDK extends BaseSDK {
|
|
5
5
|
private relativePath;
|
|
6
6
|
constructor(options: QelosSDKOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qelos/sdk",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.5",
|
|
4
4
|
"description": "SDK for Qelos API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"administrator/*": [
|
|
13
13
|
"./dist/administrator/*.d.ts"
|
|
14
14
|
],
|
|
15
|
+
"ai/*": [
|
|
16
|
+
"./dist/ai/*.d.ts"
|
|
17
|
+
],
|
|
15
18
|
"workspaces": [
|
|
16
19
|
"./dist/workspaces.d.ts"
|
|
17
20
|
],
|
|
@@ -45,6 +48,18 @@
|
|
|
45
48
|
"require": "./dist/administrator/*.js",
|
|
46
49
|
"default": "./dist/administrator/*.js"
|
|
47
50
|
},
|
|
51
|
+
"./ai": {
|
|
52
|
+
"types": "./dist/ai/index.d.ts",
|
|
53
|
+
"import": "./dist/ai/index.js",
|
|
54
|
+
"require": "./dist/ai/index.js",
|
|
55
|
+
"default": "./dist/ai/index.js"
|
|
56
|
+
},
|
|
57
|
+
"./ai/*": {
|
|
58
|
+
"types": "./dist/ai/*.d.ts",
|
|
59
|
+
"import": "./dist/ai/*.js",
|
|
60
|
+
"require": "./dist/ai/*.js",
|
|
61
|
+
"default": "./dist/ai/*.js"
|
|
62
|
+
},
|
|
48
63
|
"./workspaces": {
|
|
49
64
|
"types": "./dist/workspaces.d.ts",
|
|
50
65
|
"import": "./dist/workspaces.js",
|
|
@@ -87,10 +102,10 @@
|
|
|
87
102
|
"access": "public"
|
|
88
103
|
},
|
|
89
104
|
"dependencies": {
|
|
90
|
-
"@qelos/global-types": "^3.
|
|
105
|
+
"@qelos/global-types": "^3.11.4"
|
|
91
106
|
},
|
|
92
107
|
"devDependencies": {
|
|
93
|
-
"tsx": "^4.
|
|
108
|
+
"tsx": "^4.21.0",
|
|
94
109
|
"typescript": "^4.9.5"
|
|
95
110
|
},
|
|
96
111
|
"gitHead": "13468bc51557291935b96b1aeaa837b8b52861e8",
|
package/src/ai/chat.ts
CHANGED
package/src/ai/index.ts
CHANGED
|
@@ -1,4 +1,181 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { QelosSDKOptions } from '../types';
|
|
2
|
+
import BaseSDK from '../base-sdk';
|
|
3
|
+
import ThreadsSDK from './threads';
|
|
4
|
+
import ChatSDK from './chat';
|
|
5
|
+
import RagSDK from './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 './types';
|
|
19
|
+
|
|
4
20
|
export * from './types';
|
|
21
|
+
|
|
22
|
+
// Re-export types for backward compatibility
|
|
23
|
+
export {
|
|
24
|
+
IMessage,
|
|
25
|
+
IMessageSummary,
|
|
26
|
+
IThread,
|
|
27
|
+
IChatCompletionOptions,
|
|
28
|
+
ISSEStreamProcessor,
|
|
29
|
+
IChatCompletionResponse,
|
|
30
|
+
ICreateThreadRequest,
|
|
31
|
+
ICreateVectorStorageRequest,
|
|
32
|
+
IUploadContentRequest,
|
|
33
|
+
IClearStorageRequest,
|
|
34
|
+
IVectorStore
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Qelos AI SDK - Main SDK class with three sub-SDKs
|
|
39
|
+
*
|
|
40
|
+
* This class provides access to AI functionality through three sub-SDKs:
|
|
41
|
+
* - `threads`: Thread CRUD operations for managing conversation threads
|
|
42
|
+
* - `chat`: Chat completion operations (streaming and non-streaming)
|
|
43
|
+
* - `rag`: Vector storage management for Retrieval-Augmented Generation
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const sdk = new QelosSDK({
|
|
48
|
+
* appUrl: 'https://your-qelos-instance.com',
|
|
49
|
+
* fetch: globalThis.fetch,
|
|
50
|
+
* accessToken: 'your-token'
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // Create a thread
|
|
54
|
+
* const thread = await sdk.ai.threads.create({ integration: 'id' });
|
|
55
|
+
*
|
|
56
|
+
* // Stream chat
|
|
57
|
+
* const stream = await sdk.ai.chat.stream('id', { messages: [...] });
|
|
58
|
+
* for await (const chunk of sdk.ai.chat.parseSSEStream(stream)) {
|
|
59
|
+
* console.log(chunk);
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* // Upload RAG content
|
|
63
|
+
* await sdk.ai.rag.uploadContent('sourceId', { content: '...' });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
// Main AI SDK with sub-SDKs
|
|
67
|
+
export default class QlAI extends BaseSDK {
|
|
68
|
+
/**
|
|
69
|
+
* Threads sub-SDK for managing conversation threads
|
|
70
|
+
*/
|
|
71
|
+
public threads: ThreadsSDK;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Chat sub-SDK for chat completion operations
|
|
75
|
+
*/
|
|
76
|
+
public chat: ChatSDK;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* RAG sub-SDK for vector storage management
|
|
80
|
+
*/
|
|
81
|
+
public rag: RagSDK;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Initialize the AI SDK with sub-SDKs
|
|
85
|
+
*
|
|
86
|
+
* @param options - SDK configuration options
|
|
87
|
+
*/
|
|
88
|
+
constructor(options: QelosSDKOptions) {
|
|
89
|
+
super(options);
|
|
90
|
+
this.threads = new ThreadsSDK(options);
|
|
91
|
+
this.chat = new ChatSDK(options);
|
|
92
|
+
this.rag = new RagSDK(options);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Legacy methods for backward compatibility
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated Use sdk.threads.create() instead
|
|
99
|
+
*/
|
|
100
|
+
createThread(data: ICreateThreadRequest): Promise<IThread> {
|
|
101
|
+
return this.threads.create(data);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated Use sdk.threads.getOne() instead
|
|
106
|
+
*/
|
|
107
|
+
getThread(threadId: string): Promise<IThread> {
|
|
108
|
+
return this.threads.getOne(threadId);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @deprecated Use sdk.threads.list() instead
|
|
113
|
+
*/
|
|
114
|
+
listThreads(options?: {
|
|
115
|
+
integration?: string;
|
|
116
|
+
limit?: number;
|
|
117
|
+
page?: number;
|
|
118
|
+
sort?: string;
|
|
119
|
+
user?: string;
|
|
120
|
+
workspace?: string;
|
|
121
|
+
[key: string]: string | number;
|
|
122
|
+
}): Promise<IThread[]> {
|
|
123
|
+
return this.threads.list(options);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @deprecated Use sdk.threads.delete() instead
|
|
128
|
+
*/
|
|
129
|
+
deleteThread(threadId: string): Promise<{ success: boolean }> {
|
|
130
|
+
return this.threads.delete(threadId);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Use sdk.chat.chat() instead
|
|
135
|
+
*/
|
|
136
|
+
chatCompletion(
|
|
137
|
+
integrationId: string,
|
|
138
|
+
options: IChatCompletionOptions
|
|
139
|
+
): Promise<IChatCompletionResponse> {
|
|
140
|
+
return this.chat.chat(integrationId, options);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Use sdk.chat.chatInThread() instead
|
|
145
|
+
*/
|
|
146
|
+
chatCompletionInThread(
|
|
147
|
+
integrationId: string,
|
|
148
|
+
threadId: string,
|
|
149
|
+
options: IChatCompletionOptions
|
|
150
|
+
): Promise<IChatCompletionResponse> {
|
|
151
|
+
return this.chat.chatInThread(integrationId, threadId, options);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Use sdk.chat.stream() instead
|
|
156
|
+
*/
|
|
157
|
+
async streamChat(
|
|
158
|
+
integrationId: string,
|
|
159
|
+
options: IChatCompletionOptions
|
|
160
|
+
): Promise<ReadableStream<Uint8Array>> {
|
|
161
|
+
return this.chat.stream(integrationId, options);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Use sdk.chat.streamInThread() instead
|
|
166
|
+
*/
|
|
167
|
+
async streamChatInThread(
|
|
168
|
+
integrationId: string,
|
|
169
|
+
threadId: string,
|
|
170
|
+
options: IChatCompletionOptions
|
|
171
|
+
): Promise<ReadableStream<Uint8Array>> {
|
|
172
|
+
return this.chat.streamInThread(integrationId, threadId, options);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated Use sdk.chat.parseSSEStream() instead
|
|
177
|
+
*/
|
|
178
|
+
parseSSEStream(stream: ReadableStream<Uint8Array>): ISSEStreamProcessor {
|
|
179
|
+
return this.chat.parseSSEStream(stream);
|
|
180
|
+
}
|
|
181
|
+
}
|
package/src/ai/rag.ts
CHANGED
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
IUploadContentRequest,
|
|
6
6
|
IClearStorageRequest,
|
|
7
7
|
IVectorStore
|
|
8
|
-
} from '
|
|
8
|
+
} from '.';
|
|
9
9
|
|
|
10
|
-
export default class
|
|
10
|
+
export default class RagSDK extends BaseSDK {
|
|
11
11
|
private relativePath = '/api/ai';
|
|
12
12
|
|
|
13
13
|
constructor(options: QelosSDKOptions) {
|
package/src/ai/threads.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseSDK from '../base-sdk';
|
|
2
2
|
import { QelosSDKOptions } from '../types';
|
|
3
|
-
import { IThread, ICreateThreadRequest } from '
|
|
3
|
+
import { IThread, ICreateThreadRequest } from '.';
|
|
4
4
|
|
|
5
5
|
export default class ThreadsSDK extends BaseSDK {
|
|
6
6
|
private relativePath = '/api/ai';
|
package/dist/ai.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
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/dist/ai.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,MAAM,MAAM,UAAU,CAAC;AA8B9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,4BAA4B;AAC5B,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC;;OAEG;IACI,OAAO,CAAa;IAE3B;;OAEG;IACI,IAAI,CAAU;IAErB;;OAEG;IACI,GAAG,CAAS;IAEnB;;;;OAIG;IACH,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,4CAA4C;IAE5C;;OAEG;IACH,YAAY,CAAC,IAA0B;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAQX;QACC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,QAAgB;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,cAAc,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/src/ai.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
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
|
-
}
|