chatifai 1.0.24 → 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 +105 -0
- package/dist/index.js +36 -1
- package/dist/types.d.ts +70 -0
- package/dist/types.js +26 -1
- package/index.ts +43 -0
- package/package.json +1 -1
- package/types.ts +29 -0
package/dist/index.d.ts
CHANGED
|
@@ -487,3 +487,108 @@ export declare const FullFileTextSchema: Schema<any, import("mongoose").Model<an
|
|
|
487
487
|
} & {
|
|
488
488
|
__v: number;
|
|
489
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");
|
|
@@ -179,3 +179,38 @@ exports.FullFileTextSchema = new mongoose_1.Schema({
|
|
|
179
179
|
id: true,
|
|
180
180
|
// encryptionType: 'csfle',
|
|
181
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
|
@@ -355,6 +355,7 @@ export declare const zodQuerySchema: z.ZodObject<{
|
|
|
355
355
|
organization_id: z.ZodString;
|
|
356
356
|
user_id: z.ZodString;
|
|
357
357
|
query: z.ZodString;
|
|
358
|
+
pre_defined_query_id: z.ZodOptional<z.ZodString>;
|
|
358
359
|
timestamp: z.ZodNumber;
|
|
359
360
|
}, "strip", z.ZodTypeAny, {
|
|
360
361
|
organization_id: string;
|
|
@@ -363,6 +364,7 @@ export declare const zodQuerySchema: z.ZodObject<{
|
|
|
363
364
|
timestamp: number;
|
|
364
365
|
context_ids?: string[] | undefined;
|
|
365
366
|
thread_id?: string | undefined;
|
|
367
|
+
pre_defined_query_id?: string | undefined;
|
|
366
368
|
}, {
|
|
367
369
|
organization_id: string;
|
|
368
370
|
query: string;
|
|
@@ -370,6 +372,72 @@ export declare const zodQuerySchema: z.ZodObject<{
|
|
|
370
372
|
timestamp: number;
|
|
371
373
|
context_ids?: string[] | undefined;
|
|
372
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;
|
|
373
441
|
}>;
|
|
374
442
|
export type EventAttributeType = {
|
|
375
443
|
http_request: {
|
|
@@ -396,6 +464,8 @@ export type ModelType = (typeof modelsList)[number];
|
|
|
396
464
|
export type UserRoleType = (typeof userRoles)[number];
|
|
397
465
|
export type FullFileTextType = z.infer<typeof zodFullTextSchema>;
|
|
398
466
|
export type QueryType = z.infer<typeof zodQuerySchema>;
|
|
467
|
+
export type ThreadType = z.infer<typeof zodThreadSchema>;
|
|
468
|
+
export type MessageType = z.infer<typeof zodMessageSchema>;
|
|
399
469
|
export declare enum FileType {
|
|
400
470
|
PDF = "application/pdf",
|
|
401
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',
|
|
@@ -130,14 +130,39 @@ exports.zodPreDefinedQuerySchema = zod_1.z.object({
|
|
|
130
130
|
created_at: zod_1.z.number().optional(),
|
|
131
131
|
updated_at: zod_1.z.number().optional(),
|
|
132
132
|
});
|
|
133
|
+
// Zod schema for handling user queries
|
|
133
134
|
exports.zodQuerySchema = zod_1.z.object({
|
|
134
135
|
thread_id: zod_1.z.string().optional(),
|
|
135
136
|
context_ids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
136
137
|
organization_id: zod_1.z.string(),
|
|
137
138
|
user_id: zod_1.z.string(),
|
|
138
139
|
query: zod_1.z.string().min(1),
|
|
140
|
+
pre_defined_query_id: zod_1.z.string().optional(),
|
|
139
141
|
timestamp: zod_1.z.number(),
|
|
140
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
|
+
});
|
|
141
166
|
var FileType;
|
|
142
167
|
(function (FileType) {
|
|
143
168
|
FileType["PDF"] = "application/pdf";
|
package/index.ts
CHANGED
|
@@ -190,4 +190,47 @@ export const FullFileTextSchema = new Schema(
|
|
|
190
190
|
id: true,
|
|
191
191
|
// encryptionType: 'csfle',
|
|
192
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
|
+
}
|
|
193
236
|
);
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -138,15 +138,42 @@ export const zodPreDefinedQuerySchema = z.object({
|
|
|
138
138
|
updated_at: z.number().optional(),
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
+
// Zod schema for handling user queries
|
|
141
142
|
export const zodQuerySchema = z.object({
|
|
142
143
|
thread_id: z.string().optional(), // If there is not thread id provided, a new thread will be created
|
|
143
144
|
context_ids: z.array(z.string()).optional(), // Run on all organization files unless specific file ids are provided
|
|
144
145
|
organization_id: z.string(), // Will be used to fetch the agent, contexts, chunks, etc.
|
|
145
146
|
user_id: z.string(),
|
|
146
147
|
query: z.string().min(1),
|
|
148
|
+
pre_defined_query_id: z.string().optional(),
|
|
147
149
|
timestamp: z.number(),
|
|
148
150
|
})
|
|
149
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
|
+
|
|
150
177
|
export type EventAttributeType = {
|
|
151
178
|
http_request: {
|
|
152
179
|
client_ip?: string;
|
|
@@ -174,6 +201,8 @@ export type ModelType = (typeof modelsList)[number];
|
|
|
174
201
|
export type UserRoleType = (typeof userRoles)[number];
|
|
175
202
|
export type FullFileTextType = z.infer<typeof zodFullTextSchema>;
|
|
176
203
|
export type QueryType = z.infer<typeof zodQuerySchema>;
|
|
204
|
+
export type ThreadType = z.infer<typeof zodThreadSchema>;
|
|
205
|
+
export type MessageType = z.infer<typeof zodMessageSchema>;
|
|
177
206
|
|
|
178
207
|
export enum FileType {
|
|
179
208
|
PDF = 'application/pdf',
|