@absolutejs/rag 0.22.6 → 0.22.7

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.
@@ -15,6 +15,7 @@ export declare const researchPlugin: (options: ResearchPluginOptions) => import(
15
15
  body: {
16
16
  task?: string | undefined;
17
17
  freshness?: string | undefined;
18
+ queryMode?: "search" | "task" | undefined;
18
19
  query: string;
19
20
  };
20
21
  params: {};
@@ -43,6 +44,7 @@ export declare const researchPlugin: (options: ResearchPluginOptions) => import(
43
44
  body: {
44
45
  task?: string | undefined;
45
46
  freshness?: string | undefined;
47
+ queryMode?: "search" | "task" | undefined;
46
48
  query: string;
47
49
  };
48
50
  params: {};
@@ -68,6 +70,7 @@ export declare const researchPlugin: (options: ResearchPluginOptions) => import(
68
70
  }, import("elysia/types").DefaultEphemeral, import("elysia/types").DefaultEphemeral, "post", `${string}/stream`, import("elysia/types").IntersectIfObjectSchema<import("elysia").UnwrapRoute<{
69
71
  body: import("typebox").TObject<{
70
72
  query: import("typebox").TString;
73
+ queryMode: import("typebox").TOptional<import("typebox").TUnion<[import("typebox").TLiteral<"search">, import("typebox").TLiteral<"task">]>>;
71
74
  task: import("typebox").TOptional<import("typebox").TString>;
72
75
  freshness: import("typebox").TOptional<import("typebox").TString>;
73
76
  }>;
@@ -75,6 +78,7 @@ export declare const researchPlugin: (options: ResearchPluginOptions) => import(
75
78
  body: {
76
79
  task?: string | undefined;
77
80
  freshness?: string | undefined;
81
+ queryMode?: "search" | "task" | undefined;
78
82
  query: string;
79
83
  };
80
84
  query: Record<string, string | undefined>;
@@ -216,6 +220,7 @@ export declare const researchPlugin: (options: ResearchPluginOptions) => import(
216
220
  defer: (fn: import("elysia/types").AfterResponseHandler<NoInfer<import("elysia/types").IntersectIfObjectSchema<import("elysia").UnwrapRoute<{
217
221
  body: import("typebox").TObject<{
218
222
  query: import("typebox").TString;
223
+ queryMode: import("typebox").TOptional<import("typebox").TUnion<[import("typebox").TLiteral<"search">, import("typebox").TLiteral<"task">]>>;
219
224
  task: import("typebox").TOptional<import("typebox").TString>;
220
225
  freshness: import("typebox").TOptional<import("typebox").TString>;
221
226
  }>;
@@ -49,6 +49,8 @@ export type ResearchTask<S extends ResearchSchema = ResearchSchema> = {
49
49
  instructions?: string;
50
50
  };
51
51
  export type ResearchInput = {
52
+ /** Tasks may contain instructions/JSON; quotes are not literal search filters. */
53
+ queryMode?: "search" | "task";
52
54
  queries?: string[];
53
55
  requiredPhrases?: string[];
54
56
  query: string;
@@ -122733,7 +122733,7 @@ ${prompt}`,
122733
122733
  return generated.object;
122734
122734
  };
122735
122735
  const normalize = (text) => text.normalize("NFKC").toLowerCase().replace(/\s+/gu, " ").trim();
122736
- const requiredPhrases = input.requiredPhrases ?? [...input.query.matchAll(/"([^"\n]+)"/gu)].map((match) => match[1]);
122736
+ const requiredPhrases = input.requiredPhrases ?? (input.queryMode === "task" ? [] : [...input.query.matchAll(/"([^"\n]+)"/gu)].map((match) => match[1]));
122737
122737
  const urls = new Set;
122738
122738
  const queries = new Set;
122739
122739
  let evidenceChars = 0;
@@ -122840,9 +122840,20 @@ ${prompt}`,
122840
122840
  }
122841
122841
  };
122842
122842
  try {
122843
- for (const query of input.queries ?? [input.query])
122844
- await doSearch(query);
122845
- for (let round = 0;round < limits.rounds; round++) {
122843
+ const needsInitialPlan = !input.queries && (input.queryMode === "task" || boundedQueries(input.query).length > 1) && limits.rounds > 0;
122844
+ if (needsInitialPlan) {
122845
+ const initial = await generate("plan", PlanSchema, "Turn the research task into concise search-engine queries. Preserve the requested company identity and target criteria, but never copy instructions, JSON, internal markers, or the whole brief into a query. Prioritize the most useful query first. Return at most remainingSearches queries. Return no URLs: source URLs must be discovered rather than invented.", {
122846
+ query: input.query,
122847
+ instructions: task.instructions,
122848
+ remainingSearches: limits.searches
122849
+ });
122850
+ for (const query of initial.queries)
122851
+ await doSearch(query);
122852
+ } else {
122853
+ for (const query of input.queries ?? [input.query])
122854
+ await doSearch(query);
122855
+ }
122856
+ for (let round = needsInitialPlan ? 1 : 0;round < limits.rounds; round++) {
122846
122857
  if (!result.sources.length && queries.size >= limits.searches)
122847
122858
  break;
122848
122859
  let plan;
@@ -123027,5 +123038,5 @@ export {
123027
123038
  webIndexPostgresSchemaSql
123028
123039
  };
123029
123040
 
123030
- //# debugId=FAEEE7AE83FFF95664756E2164756E21
123041
+ //# debugId=977A90765872948B64756E2164756E21
123031
123042
  //# sourceMappingURL=index.js.map