ben-ai-models-registry 1.0.45 → 1.0.47
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 +2 -0
- package/models/ChatMessages.js +43 -39
- package/models/FileStore.js +17 -0
- package/models/Files.js +13 -0
- package/models/ScraperConfig.js +7 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ const FileStore = require("./models/FileStore");
|
|
|
13
13
|
const State = require("./models/State");
|
|
14
14
|
const StatePermission = require("./models/StatePermission");
|
|
15
15
|
const UserChatHistory = require("./models/UserChatHistory");
|
|
16
|
+
const ScraperConfig = require("./models/ScraperConfig");
|
|
16
17
|
|
|
17
18
|
module.exports = {
|
|
18
19
|
JobStatus,
|
|
@@ -29,4 +30,5 @@ module.exports = {
|
|
|
29
30
|
EventLog,
|
|
30
31
|
FileStore,
|
|
31
32
|
UserChatHistory,
|
|
33
|
+
ScraperConfig,
|
|
32
34
|
};
|
package/models/ChatMessages.js
CHANGED
|
@@ -24,49 +24,53 @@ const CitationSchema = new mongoose.Schema({
|
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
const chatMessages = new Schema(
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
27
|
+
const chatMessages = new Schema({
|
|
28
|
+
role: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
content: {
|
|
33
|
+
type: String,
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
feedback: {
|
|
37
|
+
like: { type: Boolean, default: false },
|
|
38
|
+
dislike: {
|
|
39
|
+
value: { type: Boolean, default: false },
|
|
40
|
+
reason: {
|
|
41
|
+
type: [String],
|
|
42
|
+
enum: [
|
|
43
|
+
"Not Helpful",
|
|
44
|
+
"Inaccurate",
|
|
45
|
+
"Other",
|
|
46
|
+
"Wrong Citation",
|
|
47
|
+
"Unspecified",
|
|
48
|
+
],
|
|
49
|
+
default: [],
|
|
50
|
+
},
|
|
51
|
+
explanation: {
|
|
52
|
+
type: [String],
|
|
53
|
+
validate: {
|
|
54
|
+
validator: function (arr) {
|
|
55
|
+
return arr.every(
|
|
56
|
+
(str) => typeof str === "string" && str.length <= 300
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
message: "Each explanation must be a string of max 300 characters.",
|
|
56
60
|
},
|
|
61
|
+
default: [],
|
|
57
62
|
},
|
|
58
63
|
},
|
|
59
|
-
citations: {
|
|
60
|
-
type: [CitationSchema],
|
|
61
|
-
required: false,
|
|
62
|
-
},
|
|
63
|
-
traceId: {
|
|
64
|
-
type: String,
|
|
65
|
-
required: false,
|
|
66
|
-
},
|
|
67
64
|
},
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
citations: {
|
|
66
|
+
type: [CitationSchema],
|
|
67
|
+
required: false,
|
|
68
|
+
},
|
|
69
|
+
traceId: {
|
|
70
|
+
type: String,
|
|
71
|
+
required: false,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
70
74
|
|
|
71
75
|
const ChatMessageSchema = new mongoose.Schema(
|
|
72
76
|
{
|
package/models/FileStore.js
CHANGED
|
@@ -3,6 +3,22 @@ const ChunkingOptionsSchema = require("./utils/sharedSchemas/ChunkingOptionsSche
|
|
|
3
3
|
|
|
4
4
|
const { Schema, Types } = mongoose;
|
|
5
5
|
|
|
6
|
+
const FileStatusSchema = new Schema(
|
|
7
|
+
{
|
|
8
|
+
fileId: {
|
|
9
|
+
type: Schema.Types.ObjectId,
|
|
10
|
+
ref: "Files",
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
ingestionStatus: {
|
|
14
|
+
type: String,
|
|
15
|
+
enum: ["not ingested", "in progress", "ingested", "skipped", "failed"],
|
|
16
|
+
default: "not ingested",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{ _id: false }
|
|
20
|
+
);
|
|
21
|
+
|
|
6
22
|
const FileStoreSchema = new Schema(
|
|
7
23
|
{
|
|
8
24
|
stateId: { type: mongoose.Schema.Types.ObjectId, ref: "State" },
|
|
@@ -14,6 +30,7 @@ const FileStoreSchema = new Schema(
|
|
|
14
30
|
required: true,
|
|
15
31
|
unique: true,
|
|
16
32
|
},
|
|
33
|
+
filesWithStatus: [FileStatusSchema],
|
|
17
34
|
files: [{ type: Schema.Types.ObjectId, ref: "Files" }],
|
|
18
35
|
openAI: {
|
|
19
36
|
assistantId: {
|
package/models/Files.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
2
|
const { Schema } = mongoose;
|
|
3
3
|
|
|
4
|
+
const ScraperMetadataSchema = new Schema({
|
|
5
|
+
scraperId: { type: Schema.Types.ObjectId, ref: "ScraperConfig" },
|
|
6
|
+
contentLength: { type: Number },
|
|
7
|
+
scrapedAt: { type: Date },
|
|
8
|
+
sourceUrl: { type: String }
|
|
9
|
+
}, { _id: false });
|
|
10
|
+
|
|
4
11
|
const FileSchema = new Schema(
|
|
5
12
|
{
|
|
6
13
|
stateId: { type: mongoose.Schema.Types.ObjectId, ref: "State" },
|
|
14
|
+
programId: { type: Schema.Types.ObjectId, ref: "Program", required: true },
|
|
7
15
|
displayName: {
|
|
8
16
|
type: String,
|
|
9
17
|
required: [true, "Please provide a display name."],
|
|
@@ -23,6 +31,11 @@ const FileSchema = new Schema(
|
|
|
23
31
|
openAIFileId: {
|
|
24
32
|
type: String,
|
|
25
33
|
},
|
|
34
|
+
scraperMetadata: {
|
|
35
|
+
type: ScraperMetadataSchema,
|
|
36
|
+
required: false
|
|
37
|
+
},
|
|
38
|
+
source: { type: String, default: "scraper", required: false},
|
|
26
39
|
},
|
|
27
40
|
{ timestamps: true, versionKey: false }
|
|
28
41
|
);
|