ben-ai-models-registry 1.0.50 → 1.0.52

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
@@ -3,6 +3,8 @@ const JobStatus = require("./models/JobStatus");
3
3
  const Run = require("./models/Run");
4
4
  const GraphRun = require("./models/GraphRun");
5
5
  const GraphEvalResult = require("./models/GraphEvalResult");
6
+ const WikiRun = require("./models/WikiRun");
7
+ const WikiEvalResult = require("./models/WikiEvalResult");
6
8
  const Files = require("./models/Files");
7
9
  const Dataset = require("./models/Dataset");
8
10
  const Program = require("./models/Program");
@@ -16,12 +18,20 @@ const State = require("./models/State");
16
18
  const StatePermission = require("./models/StatePermission");
17
19
  const UserChatHistory = require("./models/UserChatHistory");
18
20
  const ScraperConfig = require("./models/ScraperConfig");
21
+ const {
22
+ CHUNKING_STRATEGIES,
23
+ CHUNKING_STRATEGY_VALUES,
24
+ CHUNKING_OPTION_FIELDS,
25
+ SIMILARITY_THRESHOLD,
26
+ } = require("./models/utils/sharedSchemas/chunkingStrategies");
19
27
 
20
28
  module.exports = {
21
29
  JobStatus,
22
30
  Run,
23
31
  GraphRun,
24
32
  GraphEvalResult,
33
+ WikiRun,
34
+ WikiEvalResult,
25
35
  Files,
26
36
  Dataset,
27
37
  State,
@@ -35,4 +45,8 @@ module.exports = {
35
45
  FileStore,
36
46
  UserChatHistory,
37
47
  ScraperConfig,
48
+ CHUNKING_STRATEGIES,
49
+ CHUNKING_STRATEGY_VALUES,
50
+ CHUNKING_OPTION_FIELDS,
51
+ SIMILARITY_THRESHOLD,
38
52
  };
@@ -2,35 +2,35 @@
2
2
  const mongoose = require("mongoose");
3
3
 
4
4
  const JobStatusSchema = new mongoose.Schema(
5
- {
5
+ {
6
6
  stateId: { type: mongoose.Schema.Types.ObjectId, ref: "State" },
7
- runId: { type: mongoose.Schema.Types.ObjectId, ref: "Run" },
8
- programId: { type: mongoose.Schema.Types.ObjectId, ref: "Program" },
9
- jobType: {
10
- type: String,
11
- enum: ["run", "ingestion", "graph-run"],
12
- },
13
- status: {
14
- type: String,
15
- enum: [
16
- "pending",
17
- "in_progress",
18
- "completed",
19
- "completed_with_errors",
20
- "failed",
21
- ],
22
- default: "pending",
23
- },
24
- progress: {
25
- processed: { type: Number, default: 0 },
26
- failed: { type: Number, default: 0 },
27
- total: Number,
28
- },
29
- details: mongoose.Schema.Types.Mixed,
30
- errorMessage: { type: String },
31
- },
32
- { timestamps: true, versionKey: false }
7
+ runId: { type: mongoose.Schema.Types.ObjectId, ref: "Run" },
8
+ programId: { type: mongoose.Schema.Types.ObjectId, ref: "Program" },
9
+ jobType: {
10
+ type: String,
11
+ enum: ["run", "ingestion", "graph-run", "wiki-run"],
12
+ },
13
+ status: {
14
+ type: String,
15
+ enum: [
16
+ "pending",
17
+ "in_progress",
18
+ "completed",
19
+ "completed_with_errors",
20
+ "failed",
21
+ ],
22
+ default: "pending",
23
+ },
24
+ progress: {
25
+ processed: { type: Number, default: 0 },
26
+ failed: { type: Number, default: 0 },
27
+ total: Number,
28
+ },
29
+ details: mongoose.Schema.Types.Mixed,
30
+ errorMessage: { type: String },
31
+ },
32
+ { timestamps: true, versionKey: false },
33
33
  );
34
34
 
35
35
  module.exports =
36
- mongoose.models.JobStatus || mongoose.model("JobStatus", JobStatusSchema);
36
+ mongoose.models.JobStatus || mongoose.model("JobStatus", JobStatusSchema);
@@ -0,0 +1,99 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ // One LAAJ judge verdict. Mirrors the shape produced by ragEvaluationModel.
5
+ const JudgeScoreSchema = new Schema(
6
+ {
7
+ score: { type: Number },
8
+ reasoning: { type: String },
9
+ },
10
+ { _id: false, versionKey: false }
11
+ );
12
+
13
+ const CitationSchema = new Schema(
14
+ {
15
+ id: { type: String },
16
+ text: { type: String },
17
+ file: { type: String },
18
+ pageNumber: { type: Number },
19
+ url: { type: String },
20
+ sectionTitle: { type: String },
21
+ },
22
+ { _id: false, versionKey: false }
23
+ );
24
+
25
+ // Human evaluation (mirrors GraphEvalResult's humanEvaluation/humanOverallScore).
26
+ const EvaluationQuestionSchema = new Schema(
27
+ {
28
+ question: { type: String },
29
+ score: { type: Number },
30
+ reasoning: { type: String },
31
+ },
32
+ { _id: false, versionKey: false }
33
+ );
34
+
35
+ const HumanEvaluationSchema = new Schema(
36
+ {
37
+ criterion: { type: String },
38
+ questions: [EvaluationQuestionSchema],
39
+ reasoning: { type: String },
40
+ overallScore: { type: Number },
41
+ },
42
+ { _id: false, versionKey: false }
43
+ );
44
+
45
+ const WikiEvalResultSchema = new Schema(
46
+ {
47
+ wikiRunId: {
48
+ type: Schema.Types.ObjectId,
49
+ ref: "WikiRun",
50
+ required: true,
51
+ index: true,
52
+ },
53
+ programId: { type: Schema.Types.ObjectId, ref: "Program" },
54
+ question: { type: String },
55
+ expectedAnswer: { type: String },
56
+ iteration: { type: Number },
57
+ // The finalAnswer variant from resolveCitations() — plain "(citation-{id})"
58
+ // markers, NOT displayAnswer's HTML <sup> markup. Judges must never see UI
59
+ // markup in their prediction input.
60
+ generatedAnswer: { type: String },
61
+ // Classification of generatedAnswer: Wiki's own real taxonomy (its
62
+ // AgentLoopStatusMessage values, plus "substantive" for a normal answer) —
63
+ // deliberately not remapped onto graph's substantive/refusal/conversational.
64
+ answerType: {
65
+ type: String,
66
+ enum: [
67
+ "substantive",
68
+ "refusal",
69
+ "insufficient_context",
70
+ "unrecognized_stop_reason",
71
+ ],
72
+ },
73
+ citations: { type: [CitationSchema], default: [] },
74
+ context: { type: [Schema.Types.Mixed], default: [] },
75
+ // The four RAG judges.
76
+ correctness: { type: JudgeScoreSchema },
77
+ relevance: { type: JudgeScoreSchema },
78
+ groundedness: { type: JudgeScoreSchema },
79
+ retrievalRelevance: { type: JudgeScoreSchema },
80
+ // Human evaluation (filled in from the run view; empty until a human scores it).
81
+ humanEvaluation: { type: [HumanEvaluationSchema], default: [] },
82
+ humanOverallScore: { type: String },
83
+ // Wiki-specific signal not present in the graph path.
84
+ chunksProcessed: { type: Number },
85
+ truncated: { type: Boolean },
86
+ budgetExhausted: { type: Boolean },
87
+ retryCount: { type: Number },
88
+ docsRetrieved: { type: Number },
89
+ latencyMs: { type: Number },
90
+ errorMessage: { type: String },
91
+ traceId: { type: String },
92
+ traceUrl: { type: String },
93
+ },
94
+ { timestamps: true, versionKey: false, collection: "wiki_eval_results" }
95
+ );
96
+
97
+ module.exports =
98
+ mongoose.models.WikiEvalResult ||
99
+ mongoose.model("WikiEvalResult", WikiEvalResultSchema);
@@ -0,0 +1,52 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const ParamsSnapshotSchema = new Schema(
5
+ {
6
+ searchMode: { type: String, enum: ["grep", "bm25"] },
7
+ grepMatchMode: { type: String, enum: ["word", "substring"] },
8
+ model: { type: String },
9
+ maxToolIterations: { type: Number },
10
+ maxInputTokens: { type: Number },
11
+ deadlineMs: { type: Number },
12
+ maxCostUsd: { type: Number },
13
+ instruction: { type: String },
14
+ },
15
+ { _id: false, versionKey: false }
16
+ );
17
+
18
+ const WikiRunSchema = new Schema(
19
+ {
20
+ stateId: { type: Schema.Types.ObjectId, ref: "State" },
21
+ datasetId: { type: Schema.Types.ObjectId, ref: "Dataset", index: true },
22
+ name: { type: String },
23
+ description: { type: String },
24
+ type: { type: String, default: "wiki" },
25
+ programId: { type: Schema.Types.ObjectId, ref: "Program" },
26
+ paramsSnapshot: { type: ParamsSnapshotSchema, default: {} },
27
+ evalModel: { type: String },
28
+ iterations: { type: Number },
29
+ llmPassRate: { type: Number },
30
+ relevanceScore: { type: Number },
31
+ groundednessScore: { type: Number },
32
+ retrievalRelevanceScore: { type: Number },
33
+ refusalRate: { type: Number },
34
+ insufficientContextRate: { type: Number },
35
+ unrecognizedStopReasonRate: { type: Number },
36
+ scoredCounts: {
37
+ correctness: { type: Number },
38
+ relevance: { type: Number },
39
+ groundedness: { type: Number },
40
+ retrievalRelevance: { type: Number },
41
+ },
42
+ humanPassRate: { type: Number },
43
+ humanScoredCount: { type: Number },
44
+ totalScore: { type: Number },
45
+ totalQuestions: { type: Number },
46
+ totalResults: { type: Number },
47
+ },
48
+ { timestamps: true, versionKey: false, collection: "wiki_runs" }
49
+ );
50
+
51
+ module.exports =
52
+ mongoose.models.WikiRun || mongoose.model("WikiRun", WikiRunSchema);
@@ -1,10 +1,14 @@
1
1
  const mongoose = require("mongoose");
2
+ const {
3
+ CHUNKING_STRATEGY_VALUES,
4
+ SIMILARITY_THRESHOLD,
5
+ } = require("./chunkingStrategies");
2
6
 
3
7
  const ChunkingOptionsSchema = new mongoose.Schema(
4
8
  {
5
9
  chunkingStrategy: {
6
10
  type: String,
7
- enum: ["basic", "by_title"],
11
+ enum: [...CHUNKING_STRATEGY_VALUES],
8
12
  },
9
13
  maxCharacters: {
10
14
  type: Number,
@@ -18,6 +22,11 @@ const ChunkingOptionsSchema = new mongoose.Schema(
18
22
  overlapAll: {
19
23
  type: Boolean,
20
24
  },
25
+ similarityThreshold: {
26
+ type: Number,
27
+ min: SIMILARITY_THRESHOLD.min,
28
+ max: SIMILARITY_THRESHOLD.max,
29
+ },
21
30
  },
22
31
  { _id: false }
23
32
  );
@@ -0,0 +1,51 @@
1
+ const CHUNKING_OPTION_FIELDS = Object.freeze([
2
+ "chunkingStrategy",
3
+ "maxCharacters",
4
+ "newAfterNChars",
5
+ "overlap",
6
+ "overlapAll",
7
+ "similarityThreshold",
8
+ ]);
9
+
10
+ const COMMON_OPTIONS = [
11
+ "maxCharacters",
12
+ "newAfterNChars",
13
+ "overlap",
14
+ "overlapAll",
15
+ ];
16
+
17
+ const CHUNKING_STRATEGIES = Object.freeze({
18
+ basic: Object.freeze({
19
+ displayName: "Basic",
20
+ supportedOptions: Object.freeze([...COMMON_OPTIONS]),
21
+ }),
22
+ by_title: Object.freeze({
23
+ displayName: "By Title",
24
+ supportedOptions: Object.freeze([...COMMON_OPTIONS]),
25
+ }),
26
+ by_page: Object.freeze({
27
+ displayName: "By Page",
28
+ supportedOptions: Object.freeze([...COMMON_OPTIONS]),
29
+ }),
30
+ by_similarity: Object.freeze({
31
+ displayName: "By Similarity",
32
+ supportedOptions: Object.freeze([...COMMON_OPTIONS, "similarityThreshold"]),
33
+ }),
34
+ });
35
+
36
+ const CHUNKING_STRATEGY_VALUES = Object.freeze(
37
+ Object.keys(CHUNKING_STRATEGIES)
38
+ );
39
+
40
+ const SIMILARITY_THRESHOLD = Object.freeze({
41
+ min: 0.01,
42
+ max: 0.99,
43
+ default: 0.5,
44
+ });
45
+
46
+ module.exports = {
47
+ CHUNKING_STRATEGIES,
48
+ CHUNKING_STRATEGY_VALUES,
49
+ CHUNKING_OPTION_FIELDS,
50
+ SIMILARITY_THRESHOLD,
51
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ben-ai-models-registry",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "",
5
5
  "files": [
6
6
  "/models"