@ragbits/api-client 1.3.0 → 1.4.0-dev.202512021005

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.
@@ -5,23 +5,6 @@
5
5
  */
6
6
  import type { RJSFSchema } from '@rjsf/utils';
7
7
  export type TypeFrom<T> = T[keyof T];
8
- /**
9
- * Represents the ChatResponseType enum
10
- */
11
- export declare const ChatResponseType: {
12
- readonly Text: "text";
13
- readonly Reference: "reference";
14
- readonly StateUpdate: "state_update";
15
- readonly MessageId: "message_id";
16
- readonly ConversationId: "conversation_id";
17
- readonly LiveUpdate: "live_update";
18
- readonly FollowupMessages: "followup_messages";
19
- readonly Image: "image";
20
- readonly ChunkedContent: "chunked_content";
21
- readonly ClearMessage: "clear_message";
22
- readonly Usage: "usage";
23
- };
24
- export type ChatResponseType = TypeFrom<typeof ChatResponseType>;
25
8
  /**
26
9
  * Represents the FeedbackType enum
27
10
  */
@@ -47,6 +30,18 @@ export declare const MessageRole: {
47
30
  readonly System: "system";
48
31
  };
49
32
  export type MessageRole = TypeFrom<typeof MessageRole>;
33
+ /**
34
+ * Represents the TaskStatus enum
35
+ */
36
+ export declare const TaskStatus: {
37
+ readonly Pending: "pending";
38
+ readonly InProgress: "in_progress";
39
+ readonly Completed: "completed";
40
+ readonly Failed: "failed";
41
+ readonly Cancelled: "cancelled";
42
+ readonly Retrying: "retrying";
43
+ };
44
+ export type TaskStatus = TypeFrom<typeof TaskStatus>;
50
45
  /**
51
46
  * Represents the AuthType enum
52
47
  */
@@ -99,6 +94,12 @@ export interface LiveUpdateContent {
99
94
  export interface Message {
100
95
  role: MessageRole;
101
96
  content: string;
97
+ /**
98
+ * Extra information about the message
99
+ */
100
+ extra: {
101
+ [k: string]: unknown;
102
+ } | null;
102
103
  }
103
104
  /**
104
105
  * Represents a document used as reference for the response.
@@ -147,6 +148,66 @@ export interface MessageUsage {
147
148
  completion_tokens: number;
148
149
  total_tokens: number;
149
150
  }
151
+ /**
152
+ * Simple task representation.
153
+ */
154
+ export interface Task {
155
+ id: string;
156
+ description: string;
157
+ /**
158
+ * Task status options.
159
+ */
160
+ status: 'pending' | 'in_progress' | 'completed' | 'failed' | 'cancelled' | 'retrying';
161
+ order: number;
162
+ summary: string | null;
163
+ parent_id: string | null;
164
+ full_response: string | null;
165
+ dependencies: string[];
166
+ }
167
+ /**
168
+ * Text content wrapper.
169
+ */
170
+ export interface TextContent {
171
+ text: string;
172
+ }
173
+ /**
174
+ * Message ID content wrapper.
175
+ */
176
+ export interface MessageIdContent {
177
+ message_id: string;
178
+ }
179
+ /**
180
+ * Conversation ID content wrapper.
181
+ */
182
+ export interface ConversationIdContent {
183
+ conversation_id: string;
184
+ }
185
+ /**
186
+ * Conversation summary content wrapper.
187
+ */
188
+ export interface ConversationSummaryContent {
189
+ summary: string;
190
+ }
191
+ /**
192
+ * Followup messages content wrapper.
193
+ */
194
+ export interface FollowupMessagesContent {
195
+ messages: string[];
196
+ }
197
+ /**
198
+ * Usage statistics content wrapper.
199
+ */
200
+ export interface UsageContent {
201
+ usage: {
202
+ [k: string]: MessageUsage;
203
+ };
204
+ }
205
+ /**
206
+ * Todo item content wrapper.
207
+ */
208
+ export interface TodoItemContent {
209
+ task: Task;
210
+ }
150
211
  /**
151
212
  * Customization for the header section of the UI.
152
213
  */
@@ -263,7 +324,7 @@ export interface ChatRequest {
263
324
  };
264
325
  }
265
326
  /**
266
- * Request body for feedback submission
327
+ * Request body for feedback submission.
267
328
  */
268
329
  export interface FeedbackRequest {
269
330
  /**
@@ -378,7 +439,7 @@ export interface User {
378
439
  */
379
440
  export interface TextChatResponse {
380
441
  type: 'text';
381
- content: string;
442
+ content: TextContent;
382
443
  }
383
444
  export interface ReferenceChatResponse {
384
445
  type: 'reference';
@@ -386,11 +447,11 @@ export interface ReferenceChatResponse {
386
447
  }
387
448
  export interface MessageIdChatResponse {
388
449
  type: 'message_id';
389
- content: string;
450
+ content: MessageIdContent;
390
451
  }
391
452
  export interface ConversationIdChatResponse {
392
453
  type: 'conversation_id';
393
- content: string;
454
+ content: ConversationIdContent;
394
455
  }
395
456
  export interface StateUpdateChatResponse {
396
457
  type: 'state_update';
@@ -402,19 +463,27 @@ export interface LiveUpdateChatResponse {
402
463
  }
403
464
  export interface FollowupMessagesChatResponse {
404
465
  type: 'followup_messages';
405
- content: string[];
466
+ content: FollowupMessagesContent;
406
467
  }
407
468
  export interface ImageChatResponse {
408
469
  type: 'image';
409
470
  content: Image;
410
471
  }
411
- export interface ClearMessageResponse {
412
- type: 'clear_message';
413
- content: never;
414
- }
415
472
  export interface MessageUsageChatResponse {
416
473
  type: 'usage';
417
- content: Record<string, MessageUsage>;
474
+ content: UsageContent;
475
+ }
476
+ export interface ClearMessageChatResponse {
477
+ type: 'clear_message';
478
+ content: unknown;
479
+ }
480
+ export interface TodoItemChatResonse {
481
+ type: 'todo_item';
482
+ content: TodoItemContent;
483
+ }
484
+ export interface ConversationSummaryResponse {
485
+ type: 'conversation_summary';
486
+ content: ConversationSummaryContent;
418
487
  }
419
488
  export interface ChunkedChatResponse {
420
489
  type: 'chunked_content';
@@ -423,4 +492,4 @@ export interface ChunkedChatResponse {
423
492
  /**
424
493
  * Typed chat response union
425
494
  */
426
- export type ChatResponse = TextChatResponse | ReferenceChatResponse | MessageIdChatResponse | ConversationIdChatResponse | StateUpdateChatResponse | LiveUpdateChatResponse | FollowupMessagesChatResponse | ImageChatResponse | ClearMessageResponse | MessageUsageChatResponse;
495
+ export type ChatResponse = TextChatResponse | ReferenceChatResponse | MessageIdChatResponse | ConversationIdChatResponse | StateUpdateChatResponse | LiveUpdateChatResponse | FollowupMessagesChatResponse | ImageChatResponse | MessageUsageChatResponse | ClearMessageChatResponse | TodoItemChatResonse | ConversationSummaryResponse;
package/dist/index.cjs CHANGED
@@ -21,28 +21,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AuthType: () => AuthType,
24
- ChatResponseType: () => ChatResponseType,
25
24
  FeedbackType: () => FeedbackType,
26
25
  LiveUpdateType: () => LiveUpdateType,
27
26
  MessageRole: () => MessageRole,
28
- RagbitsClient: () => RagbitsClient
27
+ RagbitsClient: () => RagbitsClient,
28
+ TaskStatus: () => TaskStatus
29
29
  });
30
30
  module.exports = __toCommonJS(index_exports);
31
31
 
32
32
  // src/autogen.types.ts
33
- var ChatResponseType = {
34
- Text: "text",
35
- Reference: "reference",
36
- StateUpdate: "state_update",
37
- MessageId: "message_id",
38
- ConversationId: "conversation_id",
39
- LiveUpdate: "live_update",
40
- FollowupMessages: "followup_messages",
41
- Image: "image",
42
- ChunkedContent: "chunked_content",
43
- ClearMessage: "clear_message",
44
- Usage: "usage"
45
- };
46
33
  var FeedbackType = {
47
34
  Like: "like",
48
35
  Dislike: "dislike"
@@ -56,6 +43,14 @@ var MessageRole = {
56
43
  Assistant: "assistant",
57
44
  System: "system"
58
45
  };
46
+ var TaskStatus = {
47
+ Pending: "pending",
48
+ InProgress: "in_progress",
49
+ Completed: "completed",
50
+ Failed: "failed",
51
+ Cancelled: "cancelled",
52
+ Retrying: "retrying"
53
+ };
59
54
  var AuthType = {
60
55
  Credentials: "credentials"
61
56
  };
@@ -179,11 +174,14 @@ var RagbitsClient = class {
179
174
  const parsedData = JSON.parse(
180
175
  jsonString
181
176
  );
182
- if (parsedData.type === ChatResponseType.ChunkedContent) {
177
+ if (parsedData.type === "chunked_content") {
183
178
  this.handleChunkedContent(parsedData, callbacks);
184
179
  continue;
185
180
  }
186
181
  await callbacks.onMessage(parsedData);
182
+ await new Promise(
183
+ (resolve) => setTimeout(resolve, 0)
184
+ );
187
185
  } catch (parseError) {
188
186
  console.error("Error parsing JSON:", parseError);
189
187
  await callbacks.onError(
@@ -292,9 +290,9 @@ var RagbitsClient = class {
292
290
  console.error("\u274C Invalid base64 data: ", e);
293
291
  await callbacks.onError(new Error("Error reading stream"));
294
292
  }
295
- if (contentType === ChatResponseType.Image) {
293
+ if (contentType === "image") {
296
294
  const completeImageResponse = {
297
- type: ChatResponseType.Image,
295
+ type: "image",
298
296
  content: {
299
297
  id,
300
298
  url: `${imageInfo.mimeType},${completeBase64}`
@@ -308,9 +306,9 @@ var RagbitsClient = class {
308
306
  // Annotate the CommonJS export names for ESM import in node:
309
307
  0 && (module.exports = {
310
308
  AuthType,
311
- ChatResponseType,
312
309
  FeedbackType,
313
310
  LiveUpdateType,
314
311
  MessageRole,
315
- RagbitsClient
312
+ RagbitsClient,
313
+ TaskStatus
316
314
  });
package/dist/index.js CHANGED
@@ -1,17 +1,4 @@
1
1
  // src/autogen.types.ts
2
- var ChatResponseType = {
3
- Text: "text",
4
- Reference: "reference",
5
- StateUpdate: "state_update",
6
- MessageId: "message_id",
7
- ConversationId: "conversation_id",
8
- LiveUpdate: "live_update",
9
- FollowupMessages: "followup_messages",
10
- Image: "image",
11
- ChunkedContent: "chunked_content",
12
- ClearMessage: "clear_message",
13
- Usage: "usage"
14
- };
15
2
  var FeedbackType = {
16
3
  Like: "like",
17
4
  Dislike: "dislike"
@@ -25,6 +12,14 @@ var MessageRole = {
25
12
  Assistant: "assistant",
26
13
  System: "system"
27
14
  };
15
+ var TaskStatus = {
16
+ Pending: "pending",
17
+ InProgress: "in_progress",
18
+ Completed: "completed",
19
+ Failed: "failed",
20
+ Cancelled: "cancelled",
21
+ Retrying: "retrying"
22
+ };
28
23
  var AuthType = {
29
24
  Credentials: "credentials"
30
25
  };
@@ -148,11 +143,14 @@ var RagbitsClient = class {
148
143
  const parsedData = JSON.parse(
149
144
  jsonString
150
145
  );
151
- if (parsedData.type === ChatResponseType.ChunkedContent) {
146
+ if (parsedData.type === "chunked_content") {
152
147
  this.handleChunkedContent(parsedData, callbacks);
153
148
  continue;
154
149
  }
155
150
  await callbacks.onMessage(parsedData);
151
+ await new Promise(
152
+ (resolve) => setTimeout(resolve, 0)
153
+ );
156
154
  } catch (parseError) {
157
155
  console.error("Error parsing JSON:", parseError);
158
156
  await callbacks.onError(
@@ -261,9 +259,9 @@ var RagbitsClient = class {
261
259
  console.error("\u274C Invalid base64 data: ", e);
262
260
  await callbacks.onError(new Error("Error reading stream"));
263
261
  }
264
- if (contentType === ChatResponseType.Image) {
262
+ if (contentType === "image") {
265
263
  const completeImageResponse = {
266
- type: ChatResponseType.Image,
264
+ type: "image",
267
265
  content: {
268
266
  id,
269
267
  url: `${imageInfo.mimeType},${completeBase64}`
@@ -276,9 +274,9 @@ var RagbitsClient = class {
276
274
  };
277
275
  export {
278
276
  AuthType,
279
- ChatResponseType,
280
277
  FeedbackType,
281
278
  LiveUpdateType,
282
279
  MessageRole,
283
- RagbitsClient
280
+ RagbitsClient,
281
+ TaskStatus
284
282
  };
package/dist/types.d.ts CHANGED
@@ -33,6 +33,7 @@ export interface BaseApiEndpoints {
33
33
  '/api/feedback': EndpointDefinition<FeedbackRequest, FeedbackResponse>;
34
34
  '/api/auth/login': EndpointDefinition<LoginRequest, LoginResponse>;
35
35
  '/api/auth/logout': EndpointDefinition<LogoutRequest, GenericResponse>;
36
+ '/api/theme': EndpointDefinition<never, string>;
36
37
  }
37
38
  /**
38
39
  * Streaming API endpoint definitions with their request/stream response types
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@ragbits/api-client",
3
- "version": "1.3.0",
3
+ "version": "1.4.0-dev.202512021005",
4
4
  "description": "JavaScript client for the Ragbits API",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/deepsense-ai/ragbits"
8
- },
8
+ },
9
9
  "main": "dist/index.cjs",
10
10
  "module": "dist/index.js",
11
11
  "types": "dist/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "@rjsf/utils": "^5.24.12",
41
41
  "@testing-library/jest-dom": "^6.4.0",
42
42
  "@types/node": "^20.0.0",
43
- "@vitest/coverage-v8": "^1.6.0",
43
+ "@vitest/coverage-v8": "^4.0.7",
44
44
  "eslint": "^9.17.0",
45
45
  "globals": "^15.14.0",
46
46
  "msw": "^2.0.0",
@@ -48,6 +48,6 @@
48
48
  "tsup": "^8.0.0",
49
49
  "typescript": "^5.0.0",
50
50
  "typescript-eslint": "^8.18.2",
51
- "vitest": "^1.6.0"
51
+ "vitest": "^4.0.7"
52
52
  }
53
53
  }