@exulu/backend 3.0.0 → 3.1.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/dist/{chunk-KFL7HIID.js → chunk-ZDH5S2WF.js} +873 -277
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-YY2WIMMJ.js → convert-exulu-tools-to-ai-sdk-tools-FN6WZSIQ.js} +1 -1
- package/dist/index.cjs +2306 -608
- package/dist/index.d.cts +41 -8
- package/dist/index.d.ts +41 -8
- package/dist/index.js +1203 -202
- package/ee/agentic-retrieval/pipeline/hyde.test.ts +1 -1
- package/ee/agentic-retrieval/pipeline/hyde.ts +6 -3
- package/ee/agentic-retrieval/pipeline/memory.test.ts +5 -1
- package/ee/agentic-retrieval/pipeline/memory.ts +71 -104
- package/ee/agentic-retrieval/pipeline/micro-call.test.ts +112 -0
- package/ee/agentic-retrieval/pipeline/micro-call.ts +98 -0
- package/ee/agentic-retrieval/pipeline/prefilter.test.ts +1 -0
- package/ee/agentic-retrieval/pipeline/prefilter.ts +11 -20
- package/ee/agentic-retrieval/pipeline/routing.test.ts +44 -1
- package/ee/agentic-retrieval/pipeline/routing.ts +31 -56
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { generateText, Output } from "ai";
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
2
|
+
import { microCall } from "./micro-call";
|
|
4
3
|
import { fuzzyPrefilter } from "./prefilter";
|
|
5
4
|
import { normalizeFileName } from "./text-utils";
|
|
6
5
|
import type { RoutingRule } from "./config";
|
|
@@ -103,25 +102,17 @@ export async function runRoutingPhase(opts: {
|
|
|
103
102
|
const [docPageRaw, explicitKBRaw] = await Promise.all([
|
|
104
103
|
(async () => {
|
|
105
104
|
try {
|
|
106
|
-
return await
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
hasPageHint: z.boolean(),
|
|
118
|
-
pageNumber: z.number().int().nullable().optional(),
|
|
119
|
-
}),
|
|
120
|
-
}),
|
|
121
|
-
maxOutputTokens: 300,
|
|
122
|
-
}),
|
|
123
|
-
3,
|
|
124
|
-
);
|
|
105
|
+
return await microCall({
|
|
106
|
+
model,
|
|
107
|
+
system: buildDocPagePrompt(knownIdentifiers),
|
|
108
|
+
messages: [{ role: "user", content: question }],
|
|
109
|
+
schema: z.object({
|
|
110
|
+
hasFilenameHint: z.boolean(),
|
|
111
|
+
filenameHints: z.array(z.string()).optional(),
|
|
112
|
+
hasPageHint: z.boolean(),
|
|
113
|
+
pageNumber: z.number().int().nullable().optional(),
|
|
114
|
+
}),
|
|
115
|
+
});
|
|
125
116
|
} catch (err) {
|
|
126
117
|
steps.push({ text: "Doc/page detection failed — skipping filename and page hints." });
|
|
127
118
|
return {
|
|
@@ -136,24 +127,16 @@ export async function runRoutingPhase(opts: {
|
|
|
136
127
|
})(),
|
|
137
128
|
(async () => {
|
|
138
129
|
try {
|
|
139
|
-
return await
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
),
|
|
150
|
-
}),
|
|
151
|
-
}),
|
|
152
|
-
messages: [{ role: "user", content: question }],
|
|
153
|
-
maxOutputTokens: 200,
|
|
154
|
-
}),
|
|
155
|
-
3,
|
|
156
|
-
);
|
|
130
|
+
return await microCall({
|
|
131
|
+
model,
|
|
132
|
+
system: kbSystemPrompt,
|
|
133
|
+
schema: z.object({
|
|
134
|
+
explicitlyRequestedKnowledgeBases: z.array(
|
|
135
|
+
z.enum(enabledContexts.map((c) => c.id) as [string, ...string[]]),
|
|
136
|
+
),
|
|
137
|
+
}),
|
|
138
|
+
messages: [{ role: "user", content: question }],
|
|
139
|
+
});
|
|
157
140
|
} catch (err) {
|
|
158
141
|
return { output: { explicitlyRequestedKnowledgeBases: [] as string[] } };
|
|
159
142
|
}
|
|
@@ -267,23 +250,15 @@ export async function runRoutingPhase(opts: {
|
|
|
267
250
|
}
|
|
268
251
|
|
|
269
252
|
try {
|
|
270
|
-
const { output: classified } = await
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
ruleId: z.enum(ruleIds as [string, ...string[]]),
|
|
280
|
-
reason: z.string(),
|
|
281
|
-
}),
|
|
282
|
-
}),
|
|
283
|
-
maxOutputTokens: 200,
|
|
284
|
-
}),
|
|
285
|
-
3,
|
|
286
|
-
);
|
|
253
|
+
const { output: classified } = await microCall({
|
|
254
|
+
model,
|
|
255
|
+
system: classifyPrompt,
|
|
256
|
+
messages: [{ role: "user", content: question }],
|
|
257
|
+
schema: z.object({
|
|
258
|
+
ruleId: z.enum(ruleIds as [string, ...string[]]),
|
|
259
|
+
reason: z.string(),
|
|
260
|
+
}),
|
|
261
|
+
});
|
|
287
262
|
|
|
288
263
|
const matchedRule = routingRules.find((r) => r.id === classified.ruleId);
|
|
289
264
|
if (matchedRule) {
|