@qelos/sdk 3.11.3 → 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.
@@ -0,0 +1,29 @@
1
+ import BaseSDK from '../base-sdk';
2
+ import { QelosSDKOptions } from '../types';
3
+ import { IChatCompletionOptions, IChatCompletionResponse, ISSEStreamProcessor } from '.';
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
+ }
@@ -1,47 +1,15 @@
1
- import BaseSDK from './base-sdk';
2
- export default class QlAI extends BaseSDK {
1
+ import BaseSDK from '../base-sdk';
2
+ export default class ChatSDK extends BaseSDK {
3
3
  relativePath = '/api/ai';
4
4
  constructor(options) {
5
5
  super(options);
6
6
  }
7
- // Thread CRUD Operations
8
- /**
9
- * Create a new thread
10
- */
11
- createThread(data) {
12
- return this.callJsonApi(this.relativePath + '/threads', {
13
- method: 'POST',
14
- headers: { 'content-type': 'application/json' },
15
- body: JSON.stringify(data)
16
- });
17
- }
18
- /**
19
- * Get a specific thread by ID
20
- */
21
- getThread(threadId) {
22
- return this.callJsonApi(`${this.relativePath}/threads/${threadId}${this.getQueryParams({})}`);
23
- }
24
- /**
25
- * List threads with optional filters
26
- */
27
- listThreads(options) {
28
- const queryParams = this.getQueryParams(options);
29
- return this.callJsonApi(`${this.relativePath}/threads${queryParams}`);
30
- }
31
- /**
32
- * Delete a thread
33
- */
34
- deleteThread(threadId) {
35
- return this.callJsonApi(`${this.relativePath}/threads/${threadId}${this.getQueryParams({})}`, {
36
- method: 'DELETE'
37
- });
38
- }
39
- // Chat Completion Operations
40
7
  /**
41
8
  * Create a chat completion without a thread
42
9
  */
43
10
  chat(integrationId, options) {
44
- return this.callJsonApi(`${this.relativePath}/${integrationId}/chat-completion${this.getQueryParams({})}`, {
11
+ const queryParams = this.getQueryParams(options.queryParams || {});
12
+ return this.callJsonApi(`${this.relativePath}/${integrationId}/chat-completion${queryParams}`, {
45
13
  method: 'POST',
46
14
  headers: { 'content-type': 'application/json' },
47
15
  body: JSON.stringify(options)
@@ -51,7 +19,8 @@ export default class QlAI extends BaseSDK {
51
19
  * Create a chat completion with a thread
52
20
  */
53
21
  chatInThread(integrationId, threadId, options) {
54
- return this.callJsonApi(`${this.relativePath}/${integrationId}/chat-completion/${threadId}${this.getQueryParams({})}`, {
22
+ const queryParams = this.getQueryParams(options.queryParams || {});
23
+ return this.callJsonApi(`${this.relativePath}/${integrationId}/chat-completion/${threadId}${queryParams}`, {
55
24
  method: 'POST',
56
25
  headers: { 'content-type': 'application/json' },
57
26
  body: JSON.stringify(options)
@@ -61,8 +30,9 @@ export default class QlAI extends BaseSDK {
61
30
  * Create a streaming chat completion without a thread
62
31
  * Returns a ReadableStream for Server-Sent Events
63
32
  */
64
- async streamChat(integrationId, options) {
65
- const response = await this.callApi(`${this.relativePath}/${integrationId}/chat-completion${this.getQueryParams({ stream: true })}`, {
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}`, {
66
36
  method: 'POST',
67
37
  headers: {
68
38
  'content-type': 'application/json',
@@ -79,8 +49,9 @@ export default class QlAI extends BaseSDK {
79
49
  * Create a streaming chat completion with a thread
80
50
  * Returns a ReadableStream for Server-Sent Events
81
51
  */
82
- async streamChatInThread(integrationId, threadId, options) {
83
- const response = await this.callApi(`${this.relativePath}/${integrationId}/chat-completion/${threadId}${this.getQueryParams({ stream: true })}`, {
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}`, {
84
55
  method: 'POST',
85
56
  headers: {
86
57
  'content-type': 'application/json',
@@ -172,4 +143,4 @@ export default class QlAI extends BaseSDK {
172
143
  return processor;
173
144
  }
174
145
  }
175
- //# sourceMappingURL=ai.js.map
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,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BAAuB;wBAEnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;4BACxB,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;gCAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gCAC3B,IAAI,IAAI,KAAK,QAAQ,EAAE;oCACrB,OAAO;iCACR;gCAED,IAAI;oCACF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oCAChC,MAAM,MAAM,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"}
@@ -0,0 +1,103 @@
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';
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
+ }
@@ -0,0 +1,116 @@
1
+ import BaseSDK from '../base-sdk';
2
+ import ThreadsSDK from './threads';
3
+ import ChatSDK from './chat';
4
+ import RagSDK from './rag';
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
+ }
116
+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;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"}
@@ -0,0 +1,33 @@
1
+ import BaseSDK from '../base-sdk';
2
+ import { QelosSDKOptions } from '../types';
3
+ import { ICreateVectorStorageRequest, IUploadContentRequest, IClearStorageRequest, IVectorStore } from '.';
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
+ }
37
+ }
38
+ //# sourceMappingURL=rag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rag.js","sourceRoot":"","sources":["../../src/ai/rag.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,aAAa,CAAC;AASlC,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,OAAO;IACjC,YAAY,GAAG,SAAS,CAAC;IAEjC,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,aAAa,CACX,QAAgB,EAChB,IAAiC;QAMjC,OAAO,IAAI,CAAC,WAAW,CAAM,GAAG,IAAI,CAAC,YAAY,YAAY,QAAQ,WAAW,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE;YACzG,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,aAAa,CACX,QAAgB,EAChB,IAA2B;QAO3B,OAAO,IAAI,CAAC,WAAW,CAAM,GAAG,IAAI,CAAC,YAAY,YAAY,QAAQ,kBAAkB,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE;YAChH,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,YAAY,CACV,QAAgB,EAChB,IAA0B;QAO1B,OAAO,IAAI,CAAC,WAAW,CAAM,GAAG,IAAI,CAAC,YAAY,YAAY,QAAQ,iBAAiB,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE;YAC/G,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;CACF"}
@@ -0,0 +1,33 @@
1
+ import BaseSDK from '../base-sdk';
2
+ import { QelosSDKOptions } from '../types';
3
+ import { IThread, ICreateThreadRequest } from '.';
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
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":""}