@devilsdev/rag-core 3.4.0 → 3.6.0
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/README.md +1 -1
- package/dist/all.d.ts +59 -0
- package/dist/index.cjs +443 -48
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/types/adapters/mastra.d.ts +6 -2
- package/dist/types/agentic/agentic-pipeline.d.ts +1 -1
- package/dist/types/agentic/iterative-retriever.d.ts +1 -1
- package/dist/types/agentic/query-planner.d.ts +1 -1
- package/dist/types/agentic/self-critique.d.ts +1 -1
- package/dist/types/ai/federation/federated-learning-coordinator.d.ts +1 -1
- package/dist/types/ai/training/model-training-orchestrator.d.ts +1 -1
- package/dist/types/chunking/chunking-engine.d.ts +1 -1
- package/dist/types/citation/citation-tracker.d.ts +1 -1
- package/dist/types/config/component-factory.d.ts +1 -0
- package/dist/types/connectors/anthropic-connector.d.ts +35 -1
- package/dist/types/connectors/base-connector.d.ts +1 -1
- package/dist/types/connectors/connector-utils.d.ts +20 -0
- package/dist/types/cost/cost-calculator.d.ts +1 -1
- package/dist/types/cost/cost-tracker.d.ts +1 -1
- package/dist/types/cost/token-budget.d.ts +1 -1
- package/dist/types/dashboard/dashboard-generator.d.ts +1 -1
- package/dist/types/dashboard/metrics-aggregator.d.ts +1 -1
- package/dist/types/debug/execution-tracer.d.ts +1 -1
- package/dist/types/debug/trace-inspector.d.ts +1 -1
- package/dist/types/dev/dev-server.d.ts +1 -1
- package/dist/types/dev/hot-reload.d.ts +1 -1
- package/dist/types/ecosystem/plugin-analytics-dashboard.d.ts +1 -1
- package/dist/types/ecosystem/plugin-certification.d.ts +1 -1
- package/dist/types/ecosystem/plugin-hub.d.ts +1 -1
- package/dist/types/enterprise/audit-logging.d.ts +1 -1
- package/dist/types/enterprise/data-governance.d.ts +1 -1
- package/dist/types/enterprise/multi-tenancy.d.ts +1 -1
- package/dist/types/enterprise/sso-integration.d.ts +1 -1
- package/dist/types/evaluate/pipeline-evaluator.d.ts +1 -1
- package/dist/types/graph/entity-extractor.d.ts +1 -1
- package/dist/types/graph/graph-retriever.d.ts +1 -1
- package/dist/types/graph/knowledge-graph.d.ts +1 -1
- package/dist/types/grounding/llm-judge.d.ts +10 -3
- package/dist/types/grounding/provider-citations.d.ts +244 -0
- package/dist/types/guardrails/detectors.d.ts +88 -0
- package/dist/types/guardrails/evaluate-detectors.d.ts +61 -0
- package/dist/types/guardrails/guardrails-pipeline.d.ts +2 -9
- package/dist/types/guardrails/post-generation-guard.d.ts +33 -3
- package/dist/types/guardrails/pre-retrieval-guard.d.ts +29 -1
- package/dist/types/guardrails/retrieval-guard.d.ts +30 -1
- package/dist/types/mcp/mcp-server.d.ts +1 -1
- package/dist/types/observability/otel.d.ts +9 -3
- package/dist/types/observability/scores.d.ts +57 -0
- package/dist/types/reranker/cascade-reranker.d.ts +1 -1
- package/dist/types/reranker/embedding-reranker.d.ts +1 -1
- package/dist/types/reranker/scoring-reranker.d.ts +1 -1
- package/dist/types/retrieval/bm25-search.d.ts +1 -1
- package/dist/types/retrieval/hybrid-retriever.d.ts +1 -1
- package/dist/types/retrieval/pinecone-retriever.d.ts +141 -0
- package/dist/types/security/jwt-validator.d.ts +1 -1
- package/dist/types/security/plugin-sandbox.d.ts +1 -1
- package/dist/types/streaming/sse-adapter.d.ts +1 -1
- package/dist/types/streaming/stream-router.d.ts +1 -1
- package/dist/types/streaming/streaming-embedder.d.ts +1 -1
- package/dist/types/streaming/websocket-adapter.d.ts +1 -1
- package/dist/types/templates/scaffold.d.ts +1 -1
- package/dist/types/testing/contract-tests.d.ts +8 -4
- package/dist/types/utils/batch-processor.d.ts +1 -1
- package/dist/types/utils/connection-pool.d.ts +1 -1
- package/dist/types/utils/optional-peer.d.ts +21 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createRagPipeline, createPipeline, packContext, createError, wrapError, ERROR_CODES, retry, withRetry, ChunkingEngine, BM25Search, reciprocalRankFusion, HybridRetriever, ScoringReranker, EmbeddingReranker, CascadeReranker, MemoryCache, RedisCache, CostCalculator, PRICING_METADATA, CostTracker, TokenBudget, createModelRouter, classifyQuery, MemoryRetriever, BaseConnector } from "./all";
|
|
1
|
+
export { createRagPipeline, createPipeline, evaluationScores, toLangfuseScores, packContext, createError, wrapError, ERROR_CODES, retry, withRetry, ChunkingEngine, BM25Search, reciprocalRankFusion, HybridRetriever, ScoringReranker, EmbeddingReranker, CascadeReranker, MemoryCache, RedisCache, CostCalculator, PRICING_METADATA, CostTracker, TokenBudget, createModelRouter, classifyQuery, MemoryRetriever, BaseConnector } from "./all";
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
const require = createRequire(import.meta.url);
|
|
3
3
|
const mod = require('./index.cjs');
|
|
4
|
-
export const { createRagPipeline, createPipeline, packContext, createError, wrapError, ERROR_CODES, retry, withRetry, ChunkingEngine, BM25Search, reciprocalRankFusion, HybridRetriever, ScoringReranker, EmbeddingReranker, CascadeReranker, MemoryCache, RedisCache, CostCalculator, PRICING_METADATA, CostTracker, TokenBudget, createModelRouter, classifyQuery, MemoryRetriever, BaseConnector } = mod;
|
|
4
|
+
export const { createRagPipeline, createPipeline, evaluationScores, toLangfuseScores, packContext, createError, wrapError, ERROR_CODES, retry, withRetry, ChunkingEngine, BM25Search, reciprocalRankFusion, HybridRetriever, ScoringReranker, EmbeddingReranker, CascadeReranker, MemoryCache, RedisCache, CostCalculator, PRICING_METADATA, CostTracker, TokenBudget, createModelRouter, classifyQuery, MemoryRetriever, BaseConnector } = mod;
|
|
5
5
|
export default mod;
|
|
@@ -38,11 +38,13 @@ export function createMastraScorer(options?: {
|
|
|
38
38
|
* const guardrails = createMastraGuardrails({ injection: true, pii: "redact" });
|
|
39
39
|
*
|
|
40
40
|
* @param {Object} [options]
|
|
41
|
-
* @param {boolean|Object} [options.injection=true] - Check the last user message; PreRetrievalGuard options
|
|
41
|
+
* @param {boolean|Object} [options.injection=true] - Check the last user message; PreRetrievalGuard options, including `detectors`
|
|
42
42
|
* @param {'redact'|'block'|false} [options.pii='redact'] - Redact PII in the answer, or abort the run
|
|
43
43
|
* @param {Object<string, RegExp>} [options.piiPatterns] - Extra PII patterns by name
|
|
44
|
+
* @param {Array<Object>} [options.piiDetectors] - PII detectors to run on the answer too; their matches are redacted
|
|
45
|
+
* @param {boolean} [options.piiBuiltIn=true] - false: use only piiDetectors, not the built-in PII patterns
|
|
44
46
|
* @param {string} [options.id='rag-pipeline-guardrails']
|
|
45
|
-
* @returns {Object} A Mastra processor
|
|
47
|
+
* @returns {Object} A Mastra processor. With detectors, its methods return promises (Mastra awaits them)
|
|
46
48
|
*/
|
|
47
49
|
export function createMastraGuardrails(options?: {
|
|
48
50
|
injection?: boolean | any;
|
|
@@ -50,6 +52,8 @@ export function createMastraGuardrails(options?: {
|
|
|
50
52
|
piiPatterns?: {
|
|
51
53
|
[x: string]: RegExp;
|
|
52
54
|
};
|
|
55
|
+
piiDetectors?: Array<any>;
|
|
56
|
+
piiBuiltIn?: boolean;
|
|
53
57
|
id?: string;
|
|
54
58
|
}): any;
|
|
55
59
|
export declare let MASTRA_METRICS: string[];
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @extends EventEmitter
|
|
7
7
|
*/
|
|
8
|
-
export class AgenticPipeline extends EventEmitter
|
|
8
|
+
export class AgenticPipeline extends EventEmitter {
|
|
9
9
|
/**
|
|
10
10
|
* @param {object} [options] - Override default configuration
|
|
11
11
|
* @param {number} [options.maxConcurrency=3] - Max concurrent DAG node execution
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @extends EventEmitter
|
|
6
6
|
*/
|
|
7
|
-
export class IterativeRetriever extends EventEmitter
|
|
7
|
+
export class IterativeRetriever extends EventEmitter {
|
|
8
8
|
/**
|
|
9
9
|
* @param {object} [options] - Override default configuration
|
|
10
10
|
* @param {number} [options.maxIterations=3] - Maximum retrieval iterations
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @extends EventEmitter
|
|
15
15
|
*/
|
|
16
|
-
export class QueryPlanner extends EventEmitter
|
|
16
|
+
export class QueryPlanner extends EventEmitter {
|
|
17
17
|
/**
|
|
18
18
|
* @param {object} [options] - Override default configuration
|
|
19
19
|
* @param {number} [options.minComplexityToSplit=2] - Minimum complexity
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @extends EventEmitter
|
|
6
6
|
*/
|
|
7
|
-
export class SelfCritiqueChecker extends EventEmitter
|
|
7
|
+
export class SelfCritiqueChecker extends EventEmitter {
|
|
8
8
|
/**
|
|
9
9
|
* @param {object} [options] - Override default configuration
|
|
10
10
|
* @param {number} [options.approvalThreshold=0.5] - Minimum groundedness score to approve an answer
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @extends EventEmitter
|
|
6
6
|
*/
|
|
7
|
-
export class CitationTracker extends EventEmitter
|
|
7
|
+
export class CitationTracker extends EventEmitter {
|
|
8
8
|
/**
|
|
9
9
|
* @param {object} [options] - Override default configuration
|
|
10
10
|
* @param {number} [options.similarityThreshold=0.5] - Minimum similarity for a citation match
|
|
@@ -42,6 +42,7 @@ export namespace BUILT_INS {
|
|
|
42
42
|
memory: (cfg: any) => import("../connectors/memory-retriever").MemoryRetriever;
|
|
43
43
|
pgvector: (cfg: any) => import("../retrieval/pgvector-retriever").PgVectorRetriever;
|
|
44
44
|
qdrant: (cfg: any) => import("../retrieval/qdrant-retriever").QdrantRetriever;
|
|
45
|
+
pinecone: (cfg: any) => import("../retrieval/pinecone-retriever").PineconeRetriever;
|
|
45
46
|
};
|
|
46
47
|
namespace llm {
|
|
47
48
|
export function openai_1(cfg: any): import("../connectors/openai-connector").OpenAIConnector;
|
|
@@ -66,11 +66,37 @@ export class AnthropicConnector extends BaseConnector {
|
|
|
66
66
|
* @param {Array<Object|string>} [context=[]] - Retrieved documents for RAG
|
|
67
67
|
* @param {Object} [options={}] - Override model, temperature, maxTokens per-call
|
|
68
68
|
* @param {AbortSignal} [options.signal] - Cancels the request
|
|
69
|
-
* @returns {Promise<string>} The
|
|
69
|
+
* @returns {Promise<string>} The answer: every text block of the reply,
|
|
70
|
+
* joined. Rejects (code MODEL_REFUSED or NO_TEXT) when the reply has no
|
|
71
|
+
* text, such as a refusal or a reply that ran out of maxTokens while
|
|
72
|
+
* thinking.
|
|
70
73
|
*/
|
|
71
74
|
generate(query: string, context?: Array<any | string>, options?: {
|
|
72
75
|
signal?: AbortSignal;
|
|
73
76
|
}): Promise<string>;
|
|
77
|
+
/**
|
|
78
|
+
* Like generate(), with the reply's token usage. The LLM judge uses it so
|
|
79
|
+
* `check.judge.usage` reports what the judge cost.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} query
|
|
82
|
+
* @param {Array<Object|string>} [context=[]]
|
|
83
|
+
* @param {Object} [options={}] - As for generate()
|
|
84
|
+
* @returns {Promise<{text: string, usage: {inputTokens: number, outputTokens: number, totalTokens: number}}>}
|
|
85
|
+
*/
|
|
86
|
+
generateWithUsage(query: string, context?: Array<any | string>, options?: any): Promise<{
|
|
87
|
+
text: string;
|
|
88
|
+
usage: {
|
|
89
|
+
inputTokens: number;
|
|
90
|
+
outputTokens: number;
|
|
91
|
+
totalTokens: number;
|
|
92
|
+
};
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* POST a Messages request with retries; a model that rejects
|
|
96
|
+
* `temperature` gets the request again without it.
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
private _post;
|
|
74
100
|
/**
|
|
75
101
|
* Stream a response from Claude token-by-token via SSE.
|
|
76
102
|
*
|
|
@@ -108,6 +134,14 @@ export namespace DEFAULT_CONFIG {
|
|
|
108
134
|
export let retryDelay: number;
|
|
109
135
|
export const apiKey: string;
|
|
110
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* The answer text of a Messages API response: every `text` block, joined.
|
|
139
|
+
* Models that think reply with `thinking` blocks before the text, so the
|
|
140
|
+
* first block is not always the answer.
|
|
141
|
+
* @param {Object} data - The response body
|
|
142
|
+
* @returns {string}
|
|
143
|
+
*/
|
|
144
|
+
export function responseText(data: any): string;
|
|
111
145
|
import { BaseConnector } from "./base-connector";
|
|
112
146
|
/**
|
|
113
147
|
* Default configuration for the Anthropic connector.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Provides connection lifecycle, health checking, and retry logic.
|
|
4
4
|
* @extends EventEmitter
|
|
5
5
|
*/
|
|
6
|
-
export class BaseConnector extends EventEmitter
|
|
6
|
+
export class BaseConnector extends EventEmitter {
|
|
7
7
|
/**
|
|
8
8
|
* @param {Object} options
|
|
9
9
|
* @param {string} [options.name] - Connector display name
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An axios error without what it carries from the request. axios errors
|
|
3
|
+
* keep the request config, headers included, so logging or serializing one
|
|
4
|
+
* prints the API key. This copies what callers and the retry logic use
|
|
5
|
+
* (the response status, headers and body, and the network error code)
|
|
6
|
+
* into a plain Error, and puts the API's own explanation in the message:
|
|
7
|
+
* "Anthropic API error 401: authentication_error: invalid x-api-key".
|
|
8
|
+
*
|
|
9
|
+
* @param {*} err
|
|
10
|
+
* @param {string} provider - Name for the message, e.g. "Anthropic"
|
|
11
|
+
* @returns {*} A clean Error for an axios error; anything else unchanged
|
|
12
|
+
*/
|
|
13
|
+
export function toConnectorError(err: any, provider: string): any;
|
|
14
|
+
/**
|
|
15
|
+
* Make every error from an axios client a toConnectorError() one.
|
|
16
|
+
* @param {Object} client - From axios.create()
|
|
17
|
+
* @param {string} provider
|
|
18
|
+
* @returns {Object} The client
|
|
19
|
+
*/
|
|
20
|
+
export function cleanAxiosErrors(client: any, provider: string): any;
|
|
1
21
|
/**
|
|
2
22
|
* The text of a streamed response body, chunk by chunk. Handles what axios
|
|
3
23
|
* returns for `responseType: 'stream'` on each runtime: a Node stream of
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* const cost = calc.estimate('gpt-4o', 1500, 500);
|
|
7
7
|
* console.log(cost.totalCost); // 0.015
|
|
8
8
|
*/
|
|
9
|
-
export class CostCalculator extends EventEmitter
|
|
9
|
+
export class CostCalculator extends EventEmitter {
|
|
10
10
|
/**
|
|
11
11
|
* Provenance of the built-in pricing table.
|
|
12
12
|
* @returns {typeof PRICING_METADATA}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* console.log(result.cost); // { inputTokens, outputTokens, estimatedCost, model }
|
|
9
9
|
* console.log(tracker.getSummary());
|
|
10
10
|
*/
|
|
11
|
-
export class CostTracker extends EventEmitter
|
|
11
|
+
export class CostTracker extends EventEmitter {
|
|
12
12
|
/**
|
|
13
13
|
* @param {object} [options]
|
|
14
14
|
* @param {string} [options.model='gpt-3.5-turbo'] - Default LLM model for cost estimation.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* const status = budget.check(2000, 0.10);
|
|
13
13
|
* if (status.allowed) budget.record(2000, 0.10);
|
|
14
14
|
*/
|
|
15
|
-
export class TokenBudget extends EventEmitter
|
|
15
|
+
export class TokenBudget extends EventEmitter {
|
|
16
16
|
/**
|
|
17
17
|
* @param {object} [options]
|
|
18
18
|
* @param {number} [options.maxTokens=Infinity] - Hard token limit.
|
|
@@ -16,7 +16,7 @@ export type DashboardGeneratorConfig = {
|
|
|
16
16
|
* Generates standalone HTML dashboards from pipeline metrics snapshots.
|
|
17
17
|
* @extends EventEmitter
|
|
18
18
|
*/
|
|
19
|
-
export class DashboardGenerator extends EventEmitter
|
|
19
|
+
export class DashboardGenerator extends EventEmitter {
|
|
20
20
|
/**
|
|
21
21
|
* @param {Partial<DashboardGeneratorConfig>} options
|
|
22
22
|
*/
|
|
@@ -71,7 +71,7 @@ export type ErrorData = {
|
|
|
71
71
|
* Collects and aggregates pipeline metrics into dashboard-ready snapshots.
|
|
72
72
|
* @extends EventEmitter
|
|
73
73
|
*/
|
|
74
|
-
export class MetricsAggregator extends EventEmitter
|
|
74
|
+
export class MetricsAggregator extends EventEmitter {
|
|
75
75
|
/**
|
|
76
76
|
* @param {Partial<MetricsAggregatorConfig>} options
|
|
77
77
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Execution tracer that wraps pipelines to capture run traces
|
|
3
3
|
* @extends EventEmitter
|
|
4
4
|
*/
|
|
5
|
-
export class ExecutionTracer extends EventEmitter
|
|
5
|
+
export class ExecutionTracer extends EventEmitter {
|
|
6
6
|
/**
|
|
7
7
|
* Create a new ExecutionTracer
|
|
8
8
|
* @param {object} [options] - Tracer configuration
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Trace inspector that analyzes execution traces produced by ExecutionTracer
|
|
3
3
|
* @extends EventEmitter
|
|
4
4
|
*/
|
|
5
|
-
export class TraceInspector extends EventEmitter
|
|
5
|
+
export class TraceInspector extends EventEmitter {
|
|
6
6
|
/**
|
|
7
7
|
* Create a new TraceInspector
|
|
8
8
|
* @param {object} [options] - Inspector configuration
|
|
@@ -11,7 +11,7 @@ export function toIgnoreMatcher(patterns: Array<string | RegExp | Function>): (f
|
|
|
11
11
|
*
|
|
12
12
|
* Manages file watching and hot reloading of plugins and configuration.
|
|
13
13
|
*/
|
|
14
|
-
export class HotReloadManager extends EventEmitter
|
|
14
|
+
export class HotReloadManager extends EventEmitter {
|
|
15
15
|
constructor(options?: {});
|
|
16
16
|
options: {
|
|
17
17
|
enabled: boolean;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* evaluator.on('evaluated', (result) => console.log(result.scores));
|
|
10
10
|
* const result = evaluator.evaluate({ query: 'What is RAG?', answer: '...', results: [...] });
|
|
11
11
|
*/
|
|
12
|
-
export class PipelineEvaluator extends EventEmitter
|
|
12
|
+
export class PipelineEvaluator extends EventEmitter {
|
|
13
13
|
/**
|
|
14
14
|
* Create a new PipelineEvaluator.
|
|
15
15
|
* @param {object} [options={}] - Configuration options
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Uses configurable regex patterns to identify named entities,
|
|
5
5
|
* dates, measurements, URLs, emails, and technical terms.
|
|
6
6
|
*/
|
|
7
|
-
export class EntityExtractor extends EventEmitter
|
|
7
|
+
export class EntityExtractor extends EventEmitter {
|
|
8
8
|
/**
|
|
9
9
|
* @param {Object} [options={}] - Extractor options
|
|
10
10
|
* @param {Object<string, RegExp>} [options.patterns] - Custom patterns to merge with defaults
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Combines entity-based graph traversal with token-overlap text scoring
|
|
5
5
|
* to rank and retrieve relevant documents from a corpus.
|
|
6
6
|
*/
|
|
7
|
-
export class GraphRetriever extends EventEmitter
|
|
7
|
+
export class GraphRetriever extends EventEmitter {
|
|
8
8
|
/**
|
|
9
9
|
* @param {Object} [options={}] - Retriever options
|
|
10
10
|
* @param {number} [options.traversalDepth=2] - Graph traversal depth
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Stores typed entities and directed relationships between them,
|
|
5
5
|
* supporting traversal, pattern-based querying, and adjacency lookups.
|
|
6
6
|
*/
|
|
7
|
-
export class KnowledgeGraph extends EventEmitter
|
|
7
|
+
export class KnowledgeGraph extends EventEmitter {
|
|
8
8
|
/**
|
|
9
9
|
* @param {Object} [options={}] - Graph configuration options
|
|
10
10
|
*/
|
|
@@ -41,15 +41,18 @@ export function parseJudgeVerdicts(raw: any, claimCount: number): {
|
|
|
41
41
|
*
|
|
42
42
|
* @param {Array<{text: string, classification: string}>} sentences - From
|
|
43
43
|
* CitationTracker's hallucination report
|
|
44
|
-
* @param {Array<{content: string}>} docs
|
|
44
|
+
* @param {Array<{id?: string, content: string}>} docs
|
|
45
|
+
* @param {Array<string[]>} [allowed] - Per sentence, the ids of the only
|
|
46
|
+
* docs that may support it (verifyCitations: the passages it cites)
|
|
45
47
|
* @returns {string[]}
|
|
46
48
|
*/
|
|
47
49
|
export function lexicalReasons(sentences: Array<{
|
|
48
50
|
text: string;
|
|
49
51
|
classification: string;
|
|
50
52
|
}>, docs: Array<{
|
|
53
|
+
id?: string;
|
|
51
54
|
content: string;
|
|
52
|
-
}>): string[];
|
|
55
|
+
}>, allowed?: Array<string[]>): string[];
|
|
53
56
|
/**
|
|
54
57
|
* Run the judge on the sentences that failed for lack of overlap and
|
|
55
58
|
* combine its verdicts with the lexical result.
|
|
@@ -63,9 +66,12 @@ export function lexicalReasons(sentences: Array<{
|
|
|
63
66
|
* @param {{generate: Function}} params.judge
|
|
64
67
|
* @param {Array<{text: string, classification: string, bestSource: Object|null}>} params.sentences
|
|
65
68
|
* @param {Array<{id: string, content: string}>} params.docs
|
|
69
|
+
* @param {Array<string[]>} [params.allowed] - Per sentence, the ids of the
|
|
70
|
+
* only docs that may support it; a verdict naming another doc is kept
|
|
71
|
+
* unsupported. Default: any doc.
|
|
66
72
|
* @returns {Promise<{verdicts: Array<Object>, calls: number, usage?: Object, error?: string}>}
|
|
67
73
|
*/
|
|
68
|
-
export function runJudge({ judge, sentences, docs }: {
|
|
74
|
+
export function runJudge({ judge, sentences, docs, allowed }: {
|
|
69
75
|
judge: {
|
|
70
76
|
generate: Function;
|
|
71
77
|
};
|
|
@@ -78,6 +84,7 @@ export function runJudge({ judge, sentences, docs }: {
|
|
|
78
84
|
id: string;
|
|
79
85
|
content: string;
|
|
80
86
|
}>;
|
|
87
|
+
allowed?: Array<string[]>;
|
|
81
88
|
}): Promise<{
|
|
82
89
|
verdicts: Array<any>;
|
|
83
90
|
calls: number;
|