chatifai 1.0.22 → 1.0.24

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;
@@ -394,7 +400,7 @@ export declare const ChunkSchema: Schema<any, import("mongoose").Model<any, any,
394
400
  } & {
395
401
  __v: number;
396
402
  }>;
397
- export declare const QuerySchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
403
+ export declare const PreDefinedQuerySchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
398
404
  versionKey: false;
399
405
  toJSON: {
400
406
  virtuals: true;
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.QuerySchema = exports.ChunkSchema = exports.ContextSchema = exports.AgentSchema = exports.UserSchema = exports.OrganizationSchema = void 0;
17
+ 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 },
@@ -143,7 +145,7 @@ exports.ChunkSchema = new mongoose_1.Schema({
143
145
  id: true,
144
146
  // encryptionType: 'csfle',
145
147
  });
146
- exports.QuerySchema = new mongoose_1.Schema({
148
+ exports.PreDefinedQuerySchema = new mongoose_1.Schema({
147
149
  organization_id: { type: String },
148
150
  title: { type: String, minlength: 1, maxlength: 100 },
149
151
  query: { type: String, required: true },
package/dist/types.d.ts CHANGED
@@ -199,40 +199,11 @@ export declare const zodAgentSchema: z.ZodObject<{
199
199
  message_count_limit?: number | undefined;
200
200
  is_editable?: boolean | undefined;
201
201
  }>;
202
- export declare const zodQuerySchema: z.ZodObject<{
203
- _id: z.ZodOptional<z.ZodString>;
204
- organization_id: z.ZodOptional<z.ZodString>;
205
- title: z.ZodOptional<z.ZodString>;
206
- query: z.ZodString;
207
- context_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
208
- status: z.ZodDefault<z.ZodEnum<["active", "inactive", "archived"]>>;
209
- users_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
210
- created_at: z.ZodOptional<z.ZodNumber>;
211
- updated_at: z.ZodOptional<z.ZodNumber>;
212
- }, "strip", z.ZodTypeAny, {
213
- status: "active" | "inactive" | "archived";
214
- query: string;
215
- _id?: string | undefined;
216
- title?: string | undefined;
217
- created_at?: number | undefined;
218
- updated_at?: number | undefined;
219
- organization_id?: string | undefined;
220
- context_ids?: string[] | undefined;
221
- users_ids?: string[] | undefined;
222
- }, {
223
- query: string;
224
- _id?: string | undefined;
225
- title?: string | undefined;
226
- status?: "active" | "inactive" | "archived" | undefined;
227
- created_at?: number | undefined;
228
- updated_at?: number | undefined;
229
- organization_id?: string | undefined;
230
- context_ids?: string[] | undefined;
231
- users_ids?: string[] | undefined;
232
- }>;
233
202
  export declare const zodChunkSchema: z.ZodObject<{
234
203
  _id: z.ZodOptional<z.ZodString>;
235
204
  chunk_id: z.ZodOptional<z.ZodString>;
205
+ chunk_id_before: z.ZodOptional<z.ZodString>;
206
+ chunk_id_after: z.ZodOptional<z.ZodString>;
236
207
  organization_id: z.ZodString;
237
208
  context_id: z.ZodString;
238
209
  text: z.ZodString;
@@ -300,6 +271,8 @@ export declare const zodChunkSchema: z.ZodObject<{
300
271
  created_at?: number | undefined;
301
272
  updated_at?: number | undefined;
302
273
  chunk_id?: string | undefined;
274
+ chunk_id_before?: string | undefined;
275
+ chunk_id_after?: string | undefined;
303
276
  }, {
304
277
  type: string;
305
278
  organization_id: string;
@@ -326,6 +299,8 @@ export declare const zodChunkSchema: z.ZodObject<{
326
299
  created_at?: number | undefined;
327
300
  updated_at?: number | undefined;
328
301
  chunk_id?: string | undefined;
302
+ chunk_id_before?: string | undefined;
303
+ chunk_id_after?: string | undefined;
329
304
  }>;
330
305
  export declare const zodFullTextSchema: z.ZodObject<{
331
306
  _id: z.ZodOptional<z.ZodString>;
@@ -343,6 +318,59 @@ export declare const zodFullTextSchema: z.ZodObject<{
343
318
  full_text: string;
344
319
  _id?: string | undefined;
345
320
  }>;
321
+ export declare const zodPreDefinedQuerySchema: z.ZodObject<{
322
+ _id: z.ZodOptional<z.ZodString>;
323
+ organization_id: z.ZodOptional<z.ZodString>;
324
+ title: z.ZodOptional<z.ZodString>;
325
+ query: z.ZodString;
326
+ context_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
327
+ status: z.ZodDefault<z.ZodEnum<["active", "inactive", "archived"]>>;
328
+ users_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
329
+ created_at: z.ZodOptional<z.ZodNumber>;
330
+ updated_at: z.ZodOptional<z.ZodNumber>;
331
+ }, "strip", z.ZodTypeAny, {
332
+ status: "active" | "inactive" | "archived";
333
+ query: string;
334
+ _id?: string | undefined;
335
+ title?: string | undefined;
336
+ created_at?: number | undefined;
337
+ updated_at?: number | undefined;
338
+ organization_id?: string | undefined;
339
+ context_ids?: string[] | undefined;
340
+ users_ids?: string[] | undefined;
341
+ }, {
342
+ query: string;
343
+ _id?: string | undefined;
344
+ title?: string | undefined;
345
+ status?: "active" | "inactive" | "archived" | undefined;
346
+ created_at?: number | undefined;
347
+ updated_at?: number | undefined;
348
+ organization_id?: string | undefined;
349
+ context_ids?: string[] | undefined;
350
+ users_ids?: string[] | undefined;
351
+ }>;
352
+ export declare const zodQuerySchema: z.ZodObject<{
353
+ thread_id: z.ZodOptional<z.ZodString>;
354
+ context_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
355
+ organization_id: z.ZodString;
356
+ user_id: z.ZodString;
357
+ query: z.ZodString;
358
+ timestamp: z.ZodNumber;
359
+ }, "strip", z.ZodTypeAny, {
360
+ organization_id: string;
361
+ query: string;
362
+ user_id: string;
363
+ timestamp: number;
364
+ context_ids?: string[] | undefined;
365
+ thread_id?: string | undefined;
366
+ }, {
367
+ organization_id: string;
368
+ query: string;
369
+ user_id: string;
370
+ timestamp: number;
371
+ context_ids?: string[] | undefined;
372
+ thread_id?: string | undefined;
373
+ }>;
346
374
  export type EventAttributeType = {
347
375
  http_request: {
348
376
  client_ip?: string;
@@ -350,12 +378,8 @@ export type EventAttributeType = {
350
378
  };
351
379
  };
352
380
  /**
353
- * {
354
- context_id: context._id,
355
- organization_id: context.organization_id,
356
- data: context,
357
- timestamp: Date.now(),
358
- },
381
+ * Used for queue message bodies
382
+ * Used in context processing queue
359
383
  */
360
384
  export type QueueMessageBodyType<T> = {
361
385
  organization_id: string;
@@ -367,10 +391,11 @@ export type UserType = z.infer<typeof zodUserSchema>;
367
391
  export type AgentType = z.infer<typeof zodAgentSchema>;
368
392
  export type ContextType = z.infer<typeof zodContextSchema>;
369
393
  export type ChunkType = z.infer<typeof zodChunkSchema>;
370
- export type QueryType = z.infer<typeof zodQuerySchema>;
394
+ export type PreDefinedQueryType = z.infer<typeof zodPreDefinedQuerySchema>;
371
395
  export type ModelType = (typeof modelsList)[number];
372
396
  export type UserRoleType = (typeof userRoles)[number];
373
397
  export type FullFileTextType = z.infer<typeof zodFullTextSchema>;
398
+ export type QueryType = z.infer<typeof zodQuerySchema>;
374
399
  export declare enum FileType {
375
400
  PDF = "application/pdf",
376
401
  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.zodFullTextSchema = exports.zodChunkSchema = exports.zodQuerySchema = exports.zodAgentSchema = exports.zodContextSchema = exports.zodUserSchema = exports.zodOrganizationSchema = exports.userRoles = exports.modelsList = void 0;
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;
4
4
  const zod_1 = require("zod");
5
5
  exports.modelsList = [
6
6
  'gemini-2.5-flash-lite',
@@ -84,20 +84,11 @@ exports.zodAgentSchema = zod_1.z.object({
84
84
  created_at: zod_1.z.number().optional(),
85
85
  updated_at: zod_1.z.number().optional(),
86
86
  });
87
- exports.zodQuerySchema = zod_1.z.object({
88
- _id: zod_1.z.string().optional(),
89
- organization_id: zod_1.z.string().optional(),
90
- title: zod_1.z.string().min(1).max(100).optional(),
91
- query: zod_1.z.string().min(1),
92
- context_ids: zod_1.z.array(zod_1.z.string()).optional(),
93
- status: zod_1.z.enum(['active', 'inactive', 'archived']).default('active'),
94
- users_ids: zod_1.z.array(zod_1.z.string()).optional(),
95
- created_at: zod_1.z.number().optional(),
96
- updated_at: zod_1.z.number().optional(),
97
- });
98
87
  exports.zodChunkSchema = zod_1.z.object({
99
88
  _id: zod_1.z.string().optional(),
100
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(),
101
92
  organization_id: zod_1.z.string(),
102
93
  context_id: zod_1.z.string(),
103
94
  text: zod_1.z.string(),
@@ -128,6 +119,25 @@ exports.zodFullTextSchema = zod_1.z.object({
128
119
  context_id: zod_1.z.string(),
129
120
  full_text: zod_1.z.string(),
130
121
  });
122
+ exports.zodPreDefinedQuerySchema = zod_1.z.object({
123
+ _id: zod_1.z.string().optional(),
124
+ organization_id: zod_1.z.string().optional(),
125
+ title: zod_1.z.string().min(1).max(100).optional(),
126
+ query: zod_1.z.string().min(1),
127
+ context_ids: zod_1.z.array(zod_1.z.string()).optional(),
128
+ status: zod_1.z.enum(['active', 'inactive', 'archived']).default('active'),
129
+ users_ids: zod_1.z.array(zod_1.z.string()).optional(),
130
+ created_at: zod_1.z.number().optional(),
131
+ updated_at: zod_1.z.number().optional(),
132
+ });
133
+ exports.zodQuerySchema = zod_1.z.object({
134
+ thread_id: zod_1.z.string().optional(),
135
+ context_ids: zod_1.z.array(zod_1.z.string()).optional(),
136
+ organization_id: zod_1.z.string(),
137
+ user_id: zod_1.z.string(),
138
+ query: zod_1.z.string().min(1),
139
+ timestamp: zod_1.z.number(),
140
+ });
131
141
  var FileType;
132
142
  (function (FileType) {
133
143
  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 },
@@ -148,7 +150,7 @@ export const ChunkSchema = new Schema(
148
150
  }
149
151
  );
150
152
 
151
- export const QuerySchema = new Schema(
153
+ export const PreDefinedQuerySchema = new Schema(
152
154
  {
153
155
  organization_id: { type: String },
154
156
  title: { type: String, minlength: 1, maxlength: 100 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatifai",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
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
@@ -88,21 +88,12 @@ export const zodAgentSchema = z.object({
88
88
  updated_at: z.number().optional(),
89
89
  });
90
90
 
91
- export const zodQuerySchema = z.object({
92
- _id: z.string().optional(),
93
- organization_id: z.string().optional(),
94
- title: z.string().min(1).max(100).optional(),
95
- query: z.string().min(1),
96
- context_ids: z.array(z.string()).optional(),
97
- status: z.enum(['active', 'inactive', 'archived']).default('active'),
98
- users_ids: z.array(z.string()).optional(),
99
- created_at: z.number().optional(),
100
- updated_at: z.number().optional(),
101
- });
102
91
 
103
92
  export const zodChunkSchema = z.object({
104
93
  _id: z.string().optional(),
105
94
  chunk_id: z.string().optional(),
95
+ chunk_id_before: z.string().optional(),
96
+ chunk_id_after: z.string().optional(),
106
97
  organization_id: z.string(),
107
98
  context_id: z.string(),
108
99
  text: z.string(),
@@ -135,6 +126,27 @@ export const zodFullTextSchema = z.object({
135
126
  full_text: z.string(),
136
127
  });
137
128
 
129
+ export const zodPreDefinedQuerySchema = z.object({
130
+ _id: z.string().optional(),
131
+ organization_id: z.string().optional(),
132
+ title: z.string().min(1).max(100).optional(),
133
+ query: z.string().min(1),
134
+ context_ids: z.array(z.string()).optional(),
135
+ status: z.enum(['active', 'inactive', 'archived']).default('active'),
136
+ users_ids: z.array(z.string()).optional(),
137
+ created_at: z.number().optional(),
138
+ updated_at: z.number().optional(),
139
+ });
140
+
141
+ export const zodQuerySchema = z.object({
142
+ thread_id: z.string().optional(), // If there is not thread id provided, a new thread will be created
143
+ context_ids: z.array(z.string()).optional(), // Run on all organization files unless specific file ids are provided
144
+ organization_id: z.string(), // Will be used to fetch the agent, contexts, chunks, etc.
145
+ user_id: z.string(),
146
+ query: z.string().min(1),
147
+ timestamp: z.number(),
148
+ })
149
+
138
150
  export type EventAttributeType = {
139
151
  http_request: {
140
152
  client_ip?: string;
@@ -143,12 +155,8 @@ export type EventAttributeType = {
143
155
  };
144
156
 
145
157
  /**
146
- * {
147
- context_id: context._id,
148
- organization_id: context.organization_id,
149
- data: context,
150
- timestamp: Date.now(),
151
- },
158
+ * Used for queue message bodies
159
+ * Used in context processing queue
152
160
  */
153
161
  export type QueueMessageBodyType<T> = {
154
162
  organization_id: string;
@@ -161,10 +169,11 @@ export type UserType = z.infer<typeof zodUserSchema>;
161
169
  export type AgentType = z.infer<typeof zodAgentSchema>;
162
170
  export type ContextType = z.infer<typeof zodContextSchema>;
163
171
  export type ChunkType = z.infer<typeof zodChunkSchema>;
164
- export type QueryType = z.infer<typeof zodQuerySchema>;
172
+ export type PreDefinedQueryType = z.infer<typeof zodPreDefinedQuerySchema>;
165
173
  export type ModelType = (typeof modelsList)[number];
166
174
  export type UserRoleType = (typeof userRoles)[number];
167
175
  export type FullFileTextType = z.infer<typeof zodFullTextSchema>;
176
+ export type QueryType = z.infer<typeof zodQuerySchema>;
168
177
 
169
178
  export enum FileType {
170
179
  PDF = 'application/pdf',