chatifai 1.0.23 → 1.0.25

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/index.d.ts CHANGED
@@ -322,6 +322,8 @@ export declare const ChunkSchema: Schema<any, import("mongoose").Model<any, any,
322
322
  created_at?: number | null | undefined;
323
323
  updated_at?: number | null | undefined;
324
324
  chunk_id?: string | null | undefined;
325
+ chunk_id_before?: string | null | undefined;
326
+ chunk_id_after?: string | null | undefined;
325
327
  embeddings_meta_data?: {
326
328
  model: string;
327
329
  dimensions: number;
@@ -350,6 +352,8 @@ export declare const ChunkSchema: Schema<any, import("mongoose").Model<any, any,
350
352
  created_at?: number | null | undefined;
351
353
  updated_at?: number | null | undefined;
352
354
  chunk_id?: string | null | undefined;
355
+ chunk_id_before?: string | null | undefined;
356
+ chunk_id_after?: string | null | undefined;
353
357
  embeddings_meta_data?: {
354
358
  model: string;
355
359
  dimensions: number;
@@ -378,6 +382,8 @@ export declare const ChunkSchema: Schema<any, import("mongoose").Model<any, any,
378
382
  created_at?: number | null | undefined;
379
383
  updated_at?: number | null | undefined;
380
384
  chunk_id?: string | null | undefined;
385
+ chunk_id_before?: string | null | undefined;
386
+ chunk_id_after?: string | null | undefined;
381
387
  embeddings_meta_data?: {
382
388
  model: string;
383
389
  dimensions: number;
@@ -481,3 +487,108 @@ export declare const FullFileTextSchema: Schema<any, import("mongoose").Model<an
481
487
  } & {
482
488
  __v: number;
483
489
  }>;
490
+ export declare const ThreadSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
491
+ versionKey: false;
492
+ toJSON: {
493
+ virtuals: true;
494
+ };
495
+ toObject: {
496
+ virtuals: true;
497
+ };
498
+ timestamps: true;
499
+ id: true;
500
+ }, {
501
+ createdAt: NativeDate;
502
+ updatedAt: NativeDate;
503
+ } & {
504
+ organization_id: string;
505
+ user_id: string;
506
+ agent_id: string;
507
+ messages_count: number;
508
+ title?: string | null | undefined;
509
+ created_at?: number | null | undefined;
510
+ updated_at?: number | null | undefined;
511
+ description?: string | null | undefined;
512
+ query_id?: string | null | undefined;
513
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
514
+ createdAt: NativeDate;
515
+ updatedAt: NativeDate;
516
+ } & {
517
+ organization_id: string;
518
+ user_id: string;
519
+ agent_id: string;
520
+ messages_count: number;
521
+ title?: string | null | undefined;
522
+ created_at?: number | null | undefined;
523
+ updated_at?: number | null | undefined;
524
+ description?: string | null | undefined;
525
+ query_id?: string | null | undefined;
526
+ }>, {}> & import("mongoose").FlatRecord<{
527
+ createdAt: NativeDate;
528
+ updatedAt: NativeDate;
529
+ } & {
530
+ organization_id: string;
531
+ user_id: string;
532
+ agent_id: string;
533
+ messages_count: number;
534
+ title?: string | null | undefined;
535
+ created_at?: number | null | undefined;
536
+ updated_at?: number | null | undefined;
537
+ description?: string | null | undefined;
538
+ query_id?: string | null | undefined;
539
+ }> & {
540
+ _id: import("mongoose").Types.ObjectId;
541
+ } & {
542
+ __v: number;
543
+ }>;
544
+ export declare const MessageSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
545
+ versionKey: false;
546
+ toJSON: {
547
+ virtuals: true;
548
+ };
549
+ toObject: {
550
+ virtuals: true;
551
+ };
552
+ timestamps: true;
553
+ id: true;
554
+ }, {
555
+ createdAt: NativeDate;
556
+ updatedAt: NativeDate;
557
+ } & {
558
+ organization_id: string;
559
+ thread_id: string;
560
+ role: "user" | "agent" | "system";
561
+ content: string;
562
+ created_at?: number | null | undefined;
563
+ updated_at?: number | null | undefined;
564
+ user_id?: string | null | undefined;
565
+ agent_id?: string | null | undefined;
566
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
567
+ createdAt: NativeDate;
568
+ updatedAt: NativeDate;
569
+ } & {
570
+ organization_id: string;
571
+ thread_id: string;
572
+ role: "user" | "agent" | "system";
573
+ content: string;
574
+ created_at?: number | null | undefined;
575
+ updated_at?: number | null | undefined;
576
+ user_id?: string | null | undefined;
577
+ agent_id?: string | null | undefined;
578
+ }>, {}> & import("mongoose").FlatRecord<{
579
+ createdAt: NativeDate;
580
+ updatedAt: NativeDate;
581
+ } & {
582
+ organization_id: string;
583
+ thread_id: string;
584
+ role: "user" | "agent" | "system";
585
+ content: string;
586
+ created_at?: number | null | undefined;
587
+ updated_at?: number | null | undefined;
588
+ user_id?: string | null | undefined;
589
+ agent_id?: string | null | undefined;
590
+ }> & {
591
+ _id: import("mongoose").Types.ObjectId;
592
+ } & {
593
+ __v: number;
594
+ }>;
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.FullFileTextSchema = exports.PreDefinedQuerySchema = exports.ChunkSchema = exports.ContextSchema = exports.AgentSchema = exports.UserSchema = exports.OrganizationSchema = void 0;
17
+ exports.MessageSchema = exports.ThreadSchema = exports.FullFileTextSchema = exports.PreDefinedQuerySchema = exports.ChunkSchema = exports.ContextSchema = exports.AgentSchema = exports.UserSchema = exports.OrganizationSchema = void 0;
18
18
  // Export types for consumers
19
19
  __exportStar(require("./types"), exports);
20
20
  const mongoose_1 = require("mongoose");
@@ -112,6 +112,8 @@ exports.ContextSchema = new mongoose_1.Schema({
112
112
  });
113
113
  exports.ChunkSchema = new mongoose_1.Schema({
114
114
  chunk_id: { type: String },
115
+ chunk_id_before: { type: String },
116
+ chunk_id_after: { type: String },
115
117
  organization_id: { type: String, required: true },
116
118
  context_id: { type: String, required: true },
117
119
  text: { type: String, required: true },
@@ -177,3 +179,38 @@ exports.FullFileTextSchema = new mongoose_1.Schema({
177
179
  id: true,
178
180
  // encryptionType: 'csfle',
179
181
  });
182
+ exports.ThreadSchema = new mongoose_1.Schema({
183
+ organization_id: { type: String, required: true },
184
+ user_id: { type: String, required: true },
185
+ agent_id: { type: String, required: true },
186
+ title: { type: String, minlength: 1, maxlength: 200 },
187
+ description: { type: String },
188
+ query_id: { type: String },
189
+ messages_count: { type: Number, default: 0 },
190
+ created_at: { type: Number },
191
+ updated_at: { type: Number },
192
+ }, {
193
+ versionKey: false,
194
+ toJSON: { virtuals: true },
195
+ toObject: { virtuals: true },
196
+ timestamps: true,
197
+ id: true,
198
+ // encryptionType: 'csfle',
199
+ });
200
+ exports.MessageSchema = new mongoose_1.Schema({
201
+ thread_id: { type: String, required: true },
202
+ organization_id: { type: String, required: true },
203
+ user_id: { type: String },
204
+ agent_id: { type: String },
205
+ content: { type: String, required: true },
206
+ role: { type: String, enum: ['user', 'agent', 'system'], required: true },
207
+ created_at: { type: Number },
208
+ updated_at: { type: Number },
209
+ }, {
210
+ versionKey: false,
211
+ toJSON: { virtuals: true },
212
+ toObject: { virtuals: true },
213
+ timestamps: true,
214
+ id: true,
215
+ // encryptionType: 'csfle',
216
+ });
package/dist/types.d.ts CHANGED
@@ -202,6 +202,8 @@ export declare const zodAgentSchema: z.ZodObject<{
202
202
  export declare const zodChunkSchema: z.ZodObject<{
203
203
  _id: z.ZodOptional<z.ZodString>;
204
204
  chunk_id: z.ZodOptional<z.ZodString>;
205
+ chunk_id_before: z.ZodOptional<z.ZodString>;
206
+ chunk_id_after: z.ZodOptional<z.ZodString>;
205
207
  organization_id: z.ZodString;
206
208
  context_id: z.ZodString;
207
209
  text: z.ZodString;
@@ -269,6 +271,8 @@ export declare const zodChunkSchema: z.ZodObject<{
269
271
  created_at?: number | undefined;
270
272
  updated_at?: number | undefined;
271
273
  chunk_id?: string | undefined;
274
+ chunk_id_before?: string | undefined;
275
+ chunk_id_after?: string | undefined;
272
276
  }, {
273
277
  type: string;
274
278
  organization_id: string;
@@ -295,6 +299,8 @@ export declare const zodChunkSchema: z.ZodObject<{
295
299
  created_at?: number | undefined;
296
300
  updated_at?: number | undefined;
297
301
  chunk_id?: string | undefined;
302
+ chunk_id_before?: string | undefined;
303
+ chunk_id_after?: string | undefined;
298
304
  }>;
299
305
  export declare const zodFullTextSchema: z.ZodObject<{
300
306
  _id: z.ZodOptional<z.ZodString>;
@@ -349,6 +355,7 @@ export declare const zodQuerySchema: z.ZodObject<{
349
355
  organization_id: z.ZodString;
350
356
  user_id: z.ZodString;
351
357
  query: z.ZodString;
358
+ pre_defined_query_id: z.ZodOptional<z.ZodString>;
352
359
  timestamp: z.ZodNumber;
353
360
  }, "strip", z.ZodTypeAny, {
354
361
  organization_id: string;
@@ -357,6 +364,7 @@ export declare const zodQuerySchema: z.ZodObject<{
357
364
  timestamp: number;
358
365
  context_ids?: string[] | undefined;
359
366
  thread_id?: string | undefined;
367
+ pre_defined_query_id?: string | undefined;
360
368
  }, {
361
369
  organization_id: string;
362
370
  query: string;
@@ -364,6 +372,72 @@ export declare const zodQuerySchema: z.ZodObject<{
364
372
  timestamp: number;
365
373
  context_ids?: string[] | undefined;
366
374
  thread_id?: string | undefined;
375
+ pre_defined_query_id?: string | undefined;
376
+ }>;
377
+ export declare const zodThreadSchema: z.ZodObject<{
378
+ _id: z.ZodOptional<z.ZodString>;
379
+ organization_id: z.ZodString;
380
+ user_id: z.ZodString;
381
+ agent_id: z.ZodOptional<z.ZodString>;
382
+ title: z.ZodOptional<z.ZodString>;
383
+ description: z.ZodOptional<z.ZodString>;
384
+ created_at: z.ZodOptional<z.ZodNumber>;
385
+ updated_at: z.ZodOptional<z.ZodNumber>;
386
+ query_id: z.ZodOptional<z.ZodString>;
387
+ messages_count: z.ZodOptional<z.ZodNumber>;
388
+ }, "strip", z.ZodTypeAny, {
389
+ organization_id: string;
390
+ user_id: string;
391
+ _id?: string | undefined;
392
+ title?: string | undefined;
393
+ created_at?: number | undefined;
394
+ updated_at?: number | undefined;
395
+ description?: string | undefined;
396
+ agent_id?: string | undefined;
397
+ query_id?: string | undefined;
398
+ messages_count?: number | undefined;
399
+ }, {
400
+ organization_id: string;
401
+ user_id: string;
402
+ _id?: string | undefined;
403
+ title?: string | undefined;
404
+ created_at?: number | undefined;
405
+ updated_at?: number | undefined;
406
+ description?: string | undefined;
407
+ agent_id?: string | undefined;
408
+ query_id?: string | undefined;
409
+ messages_count?: number | undefined;
410
+ }>;
411
+ export declare const zodMessageSchema: z.ZodObject<{
412
+ _id: z.ZodOptional<z.ZodString>;
413
+ thread_id: z.ZodString;
414
+ organization_id: z.ZodString;
415
+ user_id: z.ZodOptional<z.ZodString>;
416
+ agent_id: z.ZodOptional<z.ZodString>;
417
+ role: z.ZodEnum<["user", "agent", "system"]>;
418
+ content: z.ZodString;
419
+ created_at: z.ZodOptional<z.ZodNumber>;
420
+ updated_at: z.ZodOptional<z.ZodNumber>;
421
+ }, "strip", z.ZodTypeAny, {
422
+ organization_id: string;
423
+ thread_id: string;
424
+ role: "user" | "agent" | "system";
425
+ content: string;
426
+ _id?: string | undefined;
427
+ created_at?: number | undefined;
428
+ updated_at?: number | undefined;
429
+ user_id?: string | undefined;
430
+ agent_id?: string | undefined;
431
+ }, {
432
+ organization_id: string;
433
+ thread_id: string;
434
+ role: "user" | "agent" | "system";
435
+ content: string;
436
+ _id?: string | undefined;
437
+ created_at?: number | undefined;
438
+ updated_at?: number | undefined;
439
+ user_id?: string | undefined;
440
+ agent_id?: string | undefined;
367
441
  }>;
368
442
  export type EventAttributeType = {
369
443
  http_request: {
@@ -390,6 +464,8 @@ export type ModelType = (typeof modelsList)[number];
390
464
  export type UserRoleType = (typeof userRoles)[number];
391
465
  export type FullFileTextType = z.infer<typeof zodFullTextSchema>;
392
466
  export type QueryType = z.infer<typeof zodQuerySchema>;
467
+ export type ThreadType = z.infer<typeof zodThreadSchema>;
468
+ export type MessageType = z.infer<typeof zodMessageSchema>;
393
469
  export declare enum FileType {
394
470
  PDF = "application/pdf",
395
471
  WORD = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
package/dist/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueuesList = exports.FileType = exports.zodQuerySchema = exports.zodPreDefinedQuerySchema = exports.zodFullTextSchema = exports.zodChunkSchema = exports.zodAgentSchema = exports.zodContextSchema = exports.zodUserSchema = exports.zodOrganizationSchema = exports.userRoles = exports.modelsList = void 0;
3
+ exports.QueuesList = exports.FileType = exports.zodMessageSchema = exports.zodThreadSchema = exports.zodQuerySchema = exports.zodPreDefinedQuerySchema = exports.zodFullTextSchema = exports.zodChunkSchema = exports.zodAgentSchema = exports.zodContextSchema = exports.zodUserSchema = exports.zodOrganizationSchema = exports.userRoles = exports.modelsList = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.modelsList = [
6
6
  'gemini-2.5-flash-lite',
@@ -87,6 +87,8 @@ exports.zodAgentSchema = zod_1.z.object({
87
87
  exports.zodChunkSchema = zod_1.z.object({
88
88
  _id: zod_1.z.string().optional(),
89
89
  chunk_id: zod_1.z.string().optional(),
90
+ chunk_id_before: zod_1.z.string().optional(),
91
+ chunk_id_after: zod_1.z.string().optional(),
90
92
  organization_id: zod_1.z.string(),
91
93
  context_id: zod_1.z.string(),
92
94
  text: zod_1.z.string(),
@@ -128,14 +130,39 @@ exports.zodPreDefinedQuerySchema = zod_1.z.object({
128
130
  created_at: zod_1.z.number().optional(),
129
131
  updated_at: zod_1.z.number().optional(),
130
132
  });
133
+ // Zod schema for handling user queries
131
134
  exports.zodQuerySchema = zod_1.z.object({
132
135
  thread_id: zod_1.z.string().optional(),
133
136
  context_ids: zod_1.z.array(zod_1.z.string()).optional(),
134
137
  organization_id: zod_1.z.string(),
135
138
  user_id: zod_1.z.string(),
136
139
  query: zod_1.z.string().min(1),
140
+ pre_defined_query_id: zod_1.z.string().optional(),
137
141
  timestamp: zod_1.z.number(),
138
142
  });
143
+ exports.zodThreadSchema = zod_1.z.object({
144
+ _id: zod_1.z.string().optional(),
145
+ organization_id: zod_1.z.string(),
146
+ user_id: zod_1.z.string(),
147
+ agent_id: zod_1.z.string().optional(),
148
+ title: zod_1.z.string().min(1).max(200).optional(),
149
+ description: zod_1.z.string().optional(),
150
+ created_at: zod_1.z.number().optional(),
151
+ updated_at: zod_1.z.number().optional(),
152
+ query_id: zod_1.z.string().optional(),
153
+ messages_count: zod_1.z.number().optional(),
154
+ });
155
+ exports.zodMessageSchema = zod_1.z.object({
156
+ _id: zod_1.z.string().optional(),
157
+ thread_id: zod_1.z.string(),
158
+ organization_id: zod_1.z.string(),
159
+ user_id: zod_1.z.string().optional(),
160
+ agent_id: zod_1.z.string().optional(),
161
+ role: zod_1.z.enum(['user', 'agent', 'system']),
162
+ content: zod_1.z.string(),
163
+ created_at: zod_1.z.number().optional(),
164
+ updated_at: zod_1.z.number().optional(),
165
+ });
139
166
  var FileType;
140
167
  (function (FileType) {
141
168
  FileType["PDF"] = "application/pdf";
package/index.ts CHANGED
@@ -114,6 +114,8 @@ export const ContextSchema = new Schema(
114
114
  export const ChunkSchema = new Schema(
115
115
  {
116
116
  chunk_id: { type: String },
117
+ chunk_id_before: { type: String },
118
+ chunk_id_after: { type: String },
117
119
  organization_id: { type: String, required: true },
118
120
  context_id: { type: String, required: true },
119
121
  text: { type: String, required: true },
@@ -188,4 +190,47 @@ export const FullFileTextSchema = new Schema(
188
190
  id: true,
189
191
  // encryptionType: 'csfle',
190
192
  }
193
+ );
194
+
195
+ export const ThreadSchema = new Schema(
196
+ {
197
+ organization_id: { type: String, required: true },
198
+ user_id: { type: String, required: true },
199
+ agent_id: { type: String, required: true },
200
+ title: { type: String, minlength: 1, maxlength: 200 },
201
+ description: { type: String },
202
+ query_id: { type: String },
203
+ messages_count: { type: Number, default: 0 },
204
+ created_at: { type: Number },
205
+ updated_at: { type: Number },
206
+ },
207
+ {
208
+ versionKey: false,
209
+ toJSON: { virtuals: true },
210
+ toObject: { virtuals: true },
211
+ timestamps: true,
212
+ id: true,
213
+ // encryptionType: 'csfle',
214
+ }
215
+ );
216
+
217
+ export const MessageSchema = new Schema(
218
+ {
219
+ thread_id: { type: String, required: true },
220
+ organization_id: { type: String, required: true },
221
+ user_id: { type: String },
222
+ agent_id: { type: String },
223
+ content: { type: String, required: true },
224
+ role: { type: String, enum: ['user', 'agent', 'system'], required: true },
225
+ created_at: { type: Number },
226
+ updated_at: { type: Number },
227
+ },
228
+ {
229
+ versionKey: false,
230
+ toJSON: { virtuals: true },
231
+ toObject: { virtuals: true },
232
+ timestamps: true,
233
+ id: true,
234
+ // encryptionType: 'csfle',
235
+ }
191
236
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatifai",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "SDK for interacting with the Chatifai API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/types.ts CHANGED
@@ -92,6 +92,8 @@ export const zodAgentSchema = z.object({
92
92
  export const zodChunkSchema = z.object({
93
93
  _id: z.string().optional(),
94
94
  chunk_id: z.string().optional(),
95
+ chunk_id_before: z.string().optional(),
96
+ chunk_id_after: z.string().optional(),
95
97
  organization_id: z.string(),
96
98
  context_id: z.string(),
97
99
  text: z.string(),
@@ -136,15 +138,42 @@ export const zodPreDefinedQuerySchema = z.object({
136
138
  updated_at: z.number().optional(),
137
139
  });
138
140
 
141
+ // Zod schema for handling user queries
139
142
  export const zodQuerySchema = z.object({
140
143
  thread_id: z.string().optional(), // If there is not thread id provided, a new thread will be created
141
144
  context_ids: z.array(z.string()).optional(), // Run on all organization files unless specific file ids are provided
142
145
  organization_id: z.string(), // Will be used to fetch the agent, contexts, chunks, etc.
143
146
  user_id: z.string(),
144
147
  query: z.string().min(1),
148
+ pre_defined_query_id: z.string().optional(),
145
149
  timestamp: z.number(),
146
150
  })
147
151
 
152
+ export const zodThreadSchema = z.object({
153
+ _id: z.string().optional(),
154
+ organization_id: z.string(),
155
+ user_id: z.string(),
156
+ agent_id: z.string().optional(),
157
+ title: z.string().min(1).max(200).optional(),
158
+ description: z.string().optional(),
159
+ created_at: z.number().optional(),
160
+ updated_at: z.number().optional(),
161
+ query_id: z.string().optional(),
162
+ messages_count: z.number().optional(),
163
+ });
164
+
165
+ export const zodMessageSchema = z.object({
166
+ _id: z.string().optional(),
167
+ thread_id: z.string(),
168
+ organization_id: z.string(),
169
+ user_id: z.string().optional(), // If user_id is not provided, it means the message is from the agent
170
+ agent_id: z.string().optional(),
171
+ role: z.enum(['user', 'agent', 'system']),
172
+ content: z.string(),
173
+ created_at: z.number().optional(),
174
+ updated_at: z.number().optional(),
175
+ });
176
+
148
177
  export type EventAttributeType = {
149
178
  http_request: {
150
179
  client_ip?: string;
@@ -172,6 +201,8 @@ export type ModelType = (typeof modelsList)[number];
172
201
  export type UserRoleType = (typeof userRoles)[number];
173
202
  export type FullFileTextType = z.infer<typeof zodFullTextSchema>;
174
203
  export type QueryType = z.infer<typeof zodQuerySchema>;
204
+ export type ThreadType = z.infer<typeof zodThreadSchema>;
205
+ export type MessageType = z.infer<typeof zodMessageSchema>;
175
206
 
176
207
  export enum FileType {
177
208
  PDF = 'application/pdf',