@cool-digital-solutions/interferir-models 1.0.99 → 1.1.1
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.
|
@@ -9,7 +9,7 @@ const ai_conversation_message_type_1 = require("../types/ai-conversation-message
|
|
|
9
9
|
const _config_1 = require("../config");
|
|
10
10
|
const aiConversationMessageSchema = new mongoose_1.Schema({
|
|
11
11
|
conversationId: { type: mongoose_1.Schema.Types.ObjectId, ref: 'AiConversation', required: true },
|
|
12
|
-
role: { type: String,
|
|
12
|
+
role: { type: String, required: true },
|
|
13
13
|
content: { type: String, default: null },
|
|
14
14
|
token: { type: Number },
|
|
15
15
|
isLiked: { type: Boolean, default: null },
|
|
@@ -22,6 +22,11 @@ const aiConversationMessageSchema = new mongoose_1.Schema({
|
|
|
22
22
|
useCases: [{ type: mongoose_1.Schema.Types.ObjectId, ref: 'UseCase', default: null }],
|
|
23
23
|
researches: [{ type: mongoose_1.Schema.Types.ObjectId, ref: 'Theme', default: null }],
|
|
24
24
|
relatedQuestions: [{ type: mongoose_1.Schema.Types.ObjectId, ref: 'AiConversationMessage', default: null }],
|
|
25
|
+
defaultCompanyDisplayColumns: [{ type: String, default: null }],
|
|
26
|
+
hasScoutingRequest: { type: Boolean, default: false },
|
|
27
|
+
contentVersion: { type: String, required: true },
|
|
28
|
+
nextRole: { type: String, default: '' },
|
|
29
|
+
requestId: { type: String, default: '' },
|
|
25
30
|
createdBy: { type: mongoose_1.Schema.Types.ObjectId, ref: 'User', default: null },
|
|
26
31
|
updatedBy: { type: mongoose_1.Schema.Types.ObjectId, ref: 'User', default: null },
|
|
27
32
|
updatedDate: Number,
|
|
@@ -87,18 +87,29 @@ const themeSchema = new mongoose_1.Schema({
|
|
|
87
87
|
const excludeNonNullField = (schema, options) => {
|
|
88
88
|
const { fieldName } = options;
|
|
89
89
|
const addCondition = function (next) {
|
|
90
|
-
if (!this.getQuery().hasOwnProperty(fieldName))
|
|
90
|
+
if (!this.getQuery().hasOwnProperty(fieldName)) {
|
|
91
91
|
this.where({ $or: [{ [fieldName]: { $eq: null } }, { [fieldName]: { $exists: false } }] });
|
|
92
|
+
}
|
|
92
93
|
next();
|
|
93
94
|
};
|
|
95
|
+
const hasField = (obj, field) => {
|
|
96
|
+
return !!lodash.find(obj, (value, key) => {
|
|
97
|
+
if (key === field)
|
|
98
|
+
return true;
|
|
99
|
+
if (lodash.isObject(value))
|
|
100
|
+
return hasField(value, field);
|
|
101
|
+
return false;
|
|
102
|
+
});
|
|
103
|
+
};
|
|
94
104
|
const addAggregateCondition = function (next) {
|
|
95
105
|
const pipeline = this.pipeline();
|
|
96
|
-
const
|
|
97
|
-
if (stage.$match)
|
|
98
|
-
return
|
|
106
|
+
const hasFieldInMatch = lodash.find(pipeline, (stage) => {
|
|
107
|
+
if (stage.$match) {
|
|
108
|
+
return hasField(stage.$match, fieldName);
|
|
109
|
+
}
|
|
99
110
|
return false;
|
|
100
111
|
});
|
|
101
|
-
if (!
|
|
112
|
+
if (!hasFieldInMatch)
|
|
102
113
|
this.pipeline().unshift({ $match: { $or: [{ [fieldName]: { $eq: null } }, { [fieldName]: { $exists: false } }] } });
|
|
103
114
|
next();
|
|
104
115
|
};
|
|
@@ -25,10 +25,6 @@
|
|
|
25
25
|
import { Types } from 'mongoose';
|
|
26
26
|
import { IAiConversation, ICompany, IPortiaArticle, ITheme, IUseCase } from './';
|
|
27
27
|
import { BaseModel, BaseSchema } from '../config';
|
|
28
|
-
export declare enum ROLE {
|
|
29
|
-
USER = "user",
|
|
30
|
-
ASSISTANT = "assistant"
|
|
31
|
-
}
|
|
32
28
|
export declare enum IMessageReason {
|
|
33
29
|
IRRELEVANT_ANSWER = "Irrelevant answer",
|
|
34
30
|
INACCURATE_INFORMATION = "Inaccurate information",
|
|
@@ -37,7 +33,7 @@ export declare enum IMessageReason {
|
|
|
37
33
|
}
|
|
38
34
|
export interface IAiConversationMessage extends BaseSchema {
|
|
39
35
|
conversationId: Types.ObjectId | IAiConversation;
|
|
40
|
-
role:
|
|
36
|
+
role: string;
|
|
41
37
|
content?: string;
|
|
42
38
|
token?: number;
|
|
43
39
|
isLiked?: boolean;
|
|
@@ -50,6 +46,11 @@ export interface IAiConversationMessage extends BaseSchema {
|
|
|
50
46
|
useCases?: Types.ObjectId[] | IUseCase[];
|
|
51
47
|
researches?: Types.ObjectId[] | ITheme[];
|
|
52
48
|
relatedQuestions?: Types.ObjectId[] | IAiConversationMessage[];
|
|
49
|
+
defaultCompanyDisplayColumns?: string[];
|
|
50
|
+
hasScoutingRequest?: boolean;
|
|
51
|
+
contentVersion: string;
|
|
52
|
+
nextRole?: string;
|
|
53
|
+
requestId?: string;
|
|
53
54
|
}
|
|
54
55
|
export interface IAiConversationMessageModel extends BaseModel<IAiConversationMessage> {
|
|
55
56
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IMessageReason =
|
|
4
|
-
var ROLE;
|
|
5
|
-
(function (ROLE) {
|
|
6
|
-
ROLE["USER"] = "user";
|
|
7
|
-
ROLE["ASSISTANT"] = "assistant";
|
|
8
|
-
})(ROLE || (exports.ROLE = ROLE = {}));
|
|
3
|
+
exports.IMessageReason = void 0;
|
|
9
4
|
var IMessageReason;
|
|
10
5
|
(function (IMessageReason) {
|
|
11
6
|
IMessageReason["IRRELEVANT_ANSWER"] = "Irrelevant answer";
|