ben-ai-models-registry 1.0.43 → 1.0.44

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/index.js CHANGED
@@ -12,19 +12,21 @@ const EventLog = require("./models/EventLog");
12
12
  const FileStore = require("./models/FileStore");
13
13
  const State = require("./models/State");
14
14
  const StatePermission = require("./models/StatePermission");
15
+ const UserChatHistory = require("./models/UserChatHistory");
15
16
 
16
17
  module.exports = {
17
- JobStatus,
18
- Run,
19
- Files,
20
- Dataset,
21
- State,
22
- Program,
23
- QA,
24
- ChatMessages,
25
- LanguageObject,
26
- User,
27
- StatePermission,
28
- EventLog,
18
+ JobStatus,
19
+ Run,
20
+ Files,
21
+ Dataset,
22
+ State,
23
+ Program,
24
+ QA,
25
+ ChatMessages,
26
+ LanguageObject,
27
+ User,
28
+ StatePermission,
29
+ EventLog,
29
30
  FileStore,
31
+ UserChatHistory,
30
32
  };
@@ -0,0 +1,45 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const UserChatSchema = new Schema(
5
+ {
6
+ chatId: {
7
+ type: Schema.Types.ObjectId,
8
+ ref: "ChatMessage",
9
+ },
10
+ title: { type: String, maxlength: 50, default: "" },
11
+ updatedOn: {
12
+ type: Date,
13
+ },
14
+ },
15
+ {
16
+ _id: false,
17
+ timestamps: true,
18
+ }
19
+ );
20
+
21
+ const ProgramBucketSchema = new Schema(
22
+ {
23
+ userChats: { type: [UserChatSchema], default: [] },
24
+ },
25
+ { _id: false }
26
+ );
27
+
28
+ const UserChatHistorySchema = new Schema(
29
+ {
30
+ userId: { type: Schema.Types.ObjectId, ref: "User", required: true },
31
+ state: { type: String, required: true },
32
+ programs: {
33
+ type: Map,
34
+ of: ProgramBucketSchema,
35
+ default: () => ({}),
36
+ },
37
+ },
38
+ { timestamps: true, versionKey: false }
39
+ );
40
+
41
+ UserChatHistorySchema.index({ userId: 1, state: 1 }, { unique: true });
42
+
43
+ module.exports =
44
+ mongoose.models.UserChatHistory ||
45
+ mongoose.model("UserChatHistory", UserChatHistorySchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ben-ai-models-registry",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "description": "",
5
5
  "files": [
6
6
  "/models"