@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.
@@ -1,6 +1,5 @@
1
- import { generateText, Output } from "ai";
2
1
  import { z } from "zod";
3
- import { withRetry } from "@SRC/utils/with-retry";
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 withRetry(
107
- () =>
108
- generateText({
109
- model,
110
- temperature: 0,
111
- system: buildDocPagePrompt(knownIdentifiers),
112
- messages: [{ role: "user", content: question }],
113
- output: Output.object({
114
- schema: z.object({
115
- hasFilenameHint: z.boolean(),
116
- filenameHints: z.array(z.string()).optional(),
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 withRetry(
140
- () =>
141
- generateText({
142
- model,
143
- temperature: 0,
144
- system: kbSystemPrompt,
145
- output: Output.object({
146
- schema: z.object({
147
- explicitlyRequestedKnowledgeBases: z.array(
148
- z.enum(enabledContexts.map((c) => c.id) as [string, ...string[]]),
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 withRetry(
271
- () =>
272
- generateText({
273
- model,
274
- temperature: 0,
275
- system: classifyPrompt,
276
- messages: [{ role: "user", content: question }],
277
- output: Output.object({
278
- schema: z.object({
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) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exulu/backend",
3
3
  "author": "Qventu Bv.",
4
- "version": "3.0.0",
4
+ "version": "3.1.0",
5
5
  "main": "./dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {