@mastra/rag 1.2.2 → 1.2.3-alpha.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/index.js CHANGED
@@ -7,7 +7,7 @@ import { Big } from 'big.js';
7
7
  import { createSimilarityPrompt } from '@mastra/core/relevance';
8
8
  import ZeroEntropy from 'zeroentropy';
9
9
  import { createTool } from '@mastra/core/tools';
10
- import { embed } from 'ai';
10
+ import { embedV2, embedV1 } from '@mastra/core/vector';
11
11
 
12
12
  var __create = Object.create;
13
13
  var __defProp = Object.defineProperty;
@@ -6908,13 +6908,25 @@ var vectorQuerySearch = async ({
6908
6908
  topK,
6909
6909
  includeVectors = false,
6910
6910
  maxRetries = 2,
6911
- databaseConfig = {}
6911
+ databaseConfig = {},
6912
+ providerOptions
6912
6913
  }) => {
6913
- const { embedding } = await embed({
6914
- value: queryText,
6915
- model,
6916
- maxRetries
6917
- });
6914
+ let embeddingResult;
6915
+ if (model.specificationVersion === "v2") {
6916
+ embeddingResult = await embedV2({
6917
+ model,
6918
+ value: queryText,
6919
+ maxRetries,
6920
+ ...providerOptions && { providerOptions }
6921
+ });
6922
+ } else {
6923
+ embeddingResult = await embedV1({
6924
+ value: queryText,
6925
+ model,
6926
+ maxRetries
6927
+ });
6928
+ }
6929
+ const embedding = embeddingResult.embedding;
6918
6930
  const queryParams = {
6919
6931
  indexName,
6920
6932
  queryVector: embedding,
@@ -7095,6 +7107,7 @@ var createGraphRAGTool = (options) => {
7095
7107
  const topK = runtimeContext.get("topK") ?? context.topK ?? 10;
7096
7108
  const filter = runtimeContext.get("filter") ?? context.filter;
7097
7109
  const queryText = context.queryText;
7110
+ const providerOptions = runtimeContext.get("providerOptions") ?? options.providerOptions;
7098
7111
  const enableFilter = !!runtimeContext.get("filter") || (options.enableFilter ?? false);
7099
7112
  const logger = mastra?.getLogger();
7100
7113
  if (!logger) {
@@ -7137,7 +7150,8 @@ var createGraphRAGTool = (options) => {
7137
7150
  model,
7138
7151
  queryFilter: Object.keys(queryFilter || {}).length > 0 ? queryFilter : void 0,
7139
7152
  topK: topKValue,
7140
- includeVectors: true
7153
+ includeVectors: true,
7154
+ providerOptions
7141
7155
  });
7142
7156
  if (logger) {
7143
7157
  logger.debug("vectorQuerySearch returned results", { count: results.length });
@@ -7209,6 +7223,7 @@ var createVectorQueryTool = (options) => {
7209
7223
  const reranker = runtimeContext.get("reranker") ?? options.reranker;
7210
7224
  const databaseConfig = runtimeContext.get("databaseConfig") ?? options.databaseConfig;
7211
7225
  const model = runtimeContext.get("model") ?? options.model;
7226
+ const providerOptions = runtimeContext.get("providerOptions") ?? options.providerOptions;
7212
7227
  if (!indexName) throw new Error(`indexName is required, got: ${indexName}`);
7213
7228
  if (!vectorStoreName) throw new Error(`vectorStoreName is required, got: ${vectorStoreName}`);
7214
7229
  const topK = runtimeContext.get("topK") ?? context.topK ?? 10;
@@ -7262,7 +7277,8 @@ var createVectorQueryTool = (options) => {
7262
7277
  queryFilter: Object.keys(queryFilter || {}).length > 0 ? queryFilter : void 0,
7263
7278
  topK: topKValue,
7264
7279
  includeVectors,
7265
- databaseConfig
7280
+ databaseConfig,
7281
+ providerOptions
7266
7282
  });
7267
7283
  if (logger) {
7268
7284
  logger.debug("vectorQuerySearch returned results", { count: results.length });