@absolutejs/rag 0.18.0 → 0.19.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/CHANGELOG.md +16 -0
- package/RESEARCH.md +42 -4
- package/changelog.json +39 -0
- package/dist/research/index.js +123 -31
- package/dist/research/index.js.map +6 -5
- package/dist/src/research/evidence.d.ts +28 -2
- package/dist/src/research/schema.d.ts +8 -0
- package/dist/src/research/types.d.ts +16 -3
- package/package.json +7 -5
|
@@ -5,10 +5,15 @@ export declare const ReviewSchema: import("@sinclair/typebox").TObject<{
|
|
|
5
5
|
path: import("@sinclair/typebox").TString;
|
|
6
6
|
verdict: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"unknown" | "supported" | "unsupported" | "conflicting">[]>;
|
|
7
7
|
citations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
8
|
-
|
|
9
|
-
quote: import("@sinclair/typebox").TString;
|
|
8
|
+
passageId: import("@sinclair/typebox").TString;
|
|
10
9
|
}>>;
|
|
11
10
|
reason: import("@sinclair/typebox").TString;
|
|
11
|
+
checks: import("@sinclair/typebox").TObject<{
|
|
12
|
+
answersQuestion: import("@sinclair/typebox").TBoolean;
|
|
13
|
+
correctEntity: import("@sinclair/typebox").TBoolean;
|
|
14
|
+
correctTime: import("@sinclair/typebox").TBoolean;
|
|
15
|
+
preservesScope: import("@sinclair/typebox").TBoolean;
|
|
16
|
+
}>;
|
|
12
17
|
}>>;
|
|
13
18
|
}>;
|
|
14
19
|
export declare const researchLeaves: (value: unknown, maxFields?: number) => Pick<ResearchField, "value" | "path">[];
|
|
@@ -18,4 +23,25 @@ export declare const bindResearchReview: (leaves: ReturnType<typeof researchLeav
|
|
|
18
23
|
verdict: ResearchField["verdict"];
|
|
19
24
|
citations: ResearchField["citations"];
|
|
20
25
|
reason: string;
|
|
26
|
+
checks?: ResearchField["checks"];
|
|
21
27
|
}[], sources: SearchSource[]) => ResearchField[];
|
|
28
|
+
/** Stable references let the runtime copy evidence instead of asking a model to transcribe it. */
|
|
29
|
+
export declare const researchPassages: (sources: SearchSource[]) => {
|
|
30
|
+
passages: {
|
|
31
|
+
id: string;
|
|
32
|
+
text: string;
|
|
33
|
+
}[];
|
|
34
|
+
id: string;
|
|
35
|
+
url: string;
|
|
36
|
+
title: string;
|
|
37
|
+
retrievedAt: string;
|
|
38
|
+
publishedAt?: string;
|
|
39
|
+
contentFetchedAt?: string;
|
|
40
|
+
metadata?: Record<string, unknown>;
|
|
41
|
+
}[];
|
|
42
|
+
export declare const resolveResearchPassages: (citations: {
|
|
43
|
+
passageId: string;
|
|
44
|
+
}[], sources: ReturnType<typeof researchPassages>) => {
|
|
45
|
+
sourceId: string;
|
|
46
|
+
quote: string;
|
|
47
|
+
}[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TSchema, type Static as LegacyStatic } from "@sinclair/typebox";
|
|
2
|
+
import type { Static } from "typebox";
|
|
3
|
+
/** JSON-compatible TypeBox 0.34 or TypeBox 1 schemas, including Elysia 2's t. */
|
|
4
|
+
export type ResearchSchema = TSchema | {
|
|
5
|
+
"~kind": string;
|
|
6
|
+
};
|
|
7
|
+
export type ResearchStatic<S extends ResearchSchema> = S extends TSchema ? LegacyStatic<S> : Static<S>;
|
|
8
|
+
export declare const checkResearchValue: <S extends ResearchSchema>(schema: S, value: unknown) => value is ResearchStatic<S>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AIProviderConfig, AIUsage } from "@absolutejs/ai";
|
|
2
2
|
import type { SearchProvider, SearchResult, SearchSource, SearchCacheStore } from "@absolutejs/search";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResearchSchema, ResearchStatic } from "./schema";
|
|
4
|
+
export type { ResearchSchema, ResearchStatic } from "./schema";
|
|
4
5
|
import type { ReadWebpageOptions, WebReadResult } from "../web";
|
|
5
6
|
export type ResearchOperation = "search" | "read" | "plan" | "extract" | "review";
|
|
6
7
|
export type ResearchProgress = {
|
|
@@ -18,6 +19,13 @@ export type ResearchField = {
|
|
|
18
19
|
quote: string;
|
|
19
20
|
}[];
|
|
20
21
|
reason: string;
|
|
22
|
+
/** Model judgments, not independent verification; all must pass for support. */
|
|
23
|
+
checks?: {
|
|
24
|
+
answersQuestion: boolean;
|
|
25
|
+
correctEntity: boolean;
|
|
26
|
+
correctTime: boolean;
|
|
27
|
+
preservesScope: boolean;
|
|
28
|
+
};
|
|
21
29
|
};
|
|
22
30
|
export type ResearchResult<T = unknown> = {
|
|
23
31
|
id: string;
|
|
@@ -36,7 +44,7 @@ export type ResearchResult<T = unknown> = {
|
|
|
36
44
|
durationMs: number;
|
|
37
45
|
}[];
|
|
38
46
|
};
|
|
39
|
-
export type ResearchTask<S extends
|
|
47
|
+
export type ResearchTask<S extends ResearchSchema = ResearchSchema> = {
|
|
40
48
|
schema: S;
|
|
41
49
|
instructions?: string;
|
|
42
50
|
};
|
|
@@ -65,6 +73,11 @@ export type ResearchConfig = {
|
|
|
65
73
|
search: SearchProvider;
|
|
66
74
|
provider: AIProviderConfig;
|
|
67
75
|
model: string;
|
|
76
|
+
/** Optional separate reviewer. Host reservations must price this model too. */
|
|
77
|
+
reviewer?: {
|
|
78
|
+
provider: AIProviderConfig;
|
|
79
|
+
model: string;
|
|
80
|
+
};
|
|
68
81
|
tasks?: Record<string, ResearchTask>;
|
|
69
82
|
limits?: Partial<ResearchLimits>;
|
|
70
83
|
/** Explicit shared-public or tenant scope. Omit to disable search caching. */
|
|
@@ -91,5 +104,5 @@ export type ResearchConfig = {
|
|
|
91
104
|
};
|
|
92
105
|
export type ResearchRuntime = {
|
|
93
106
|
run: (input: ResearchInput) => Promise<ResearchResult>;
|
|
94
|
-
extract: <S extends
|
|
107
|
+
extract: <S extends ResearchSchema>(task: ResearchTask<S>, input: ResearchInput) => Promise<ResearchResult<ResearchStatic<S>>>;
|
|
95
108
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/rag",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"homepage": "https://github.com/absolutejs/rag",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/absolutejs/rag/issues"
|
|
@@ -84,13 +84,14 @@
|
|
|
84
84
|
"manifestContract": 2
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
+
"@absolutejs/egress": "^0.3.1",
|
|
87
88
|
"@absolutejs/manifest": "^0.9.0",
|
|
89
|
+
"@absolutejs/search": "^0.2.0",
|
|
88
90
|
"@sinclair/typebox": "^0.34.0",
|
|
89
91
|
"linkedom": "0.18.13",
|
|
90
|
-
"pdfjs-dist": "6.3.289",
|
|
91
92
|
"pdf-lib": "1.17.1",
|
|
92
|
-
"
|
|
93
|
-
"
|
|
93
|
+
"pdfjs-dist": "6.3.289",
|
|
94
|
+
"typebox": "^1.3.16"
|
|
94
95
|
},
|
|
95
96
|
"peerDependencies": {
|
|
96
97
|
"@angular/core": "^21.0.0",
|
|
@@ -153,7 +154,8 @@
|
|
|
153
154
|
"test": "bun test",
|
|
154
155
|
"release": "bun run build && bun publish --access public",
|
|
155
156
|
"check:package": "absolute-changelog check",
|
|
156
|
-
"prepublishOnly": "bun run check:package"
|
|
157
|
+
"prepublishOnly": "bun run check:package",
|
|
158
|
+
"test:research-types": "tsc --project tsconfig.research-types.json"
|
|
157
159
|
},
|
|
158
160
|
"publishConfig": {
|
|
159
161
|
"access": "public"
|