@mastra/rag 2.7.0-alpha.2 → 2.7.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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +61 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -63
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
|
17
17
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
18
18
|
var __getProtoOf = Object.getPrototypeOf;
|
|
19
19
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
20
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
20
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
21
21
|
var __copyProps = (to, from, except, desc) => {
|
|
22
22
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
23
23
|
key = keys[i];
|
|
@@ -28,7 +28,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
28
28
|
}
|
|
29
29
|
return to;
|
|
30
30
|
};
|
|
31
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", {
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp$1(target, "default", {
|
|
32
32
|
value: mod,
|
|
33
33
|
enumerable: true
|
|
34
34
|
}) : target, mod));
|
|
@@ -776,7 +776,6 @@ function createEventSourceParserStream() {
|
|
|
776
776
|
case "retry":
|
|
777
777
|
const parsedRetry = parseInt(value, 10);
|
|
778
778
|
if (!isNaN(parsedRetry)) retry = parsedRetry;
|
|
779
|
-
break;
|
|
780
779
|
}
|
|
781
780
|
}
|
|
782
781
|
return new TransformStream({
|
|
@@ -1275,16 +1274,14 @@ function convertToOpenAIChatMessages({ prompt, useLegacyFunctionCalling = false,
|
|
|
1275
1274
|
case "text":
|
|
1276
1275
|
text += part.text;
|
|
1277
1276
|
break;
|
|
1278
|
-
case "tool-call":
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
});
|
|
1287
|
-
break;
|
|
1277
|
+
case "tool-call": toolCalls.push({
|
|
1278
|
+
id: part.toolCallId,
|
|
1279
|
+
type: "function",
|
|
1280
|
+
function: {
|
|
1281
|
+
name: part.toolName,
|
|
1282
|
+
arguments: JSON.stringify(part.args)
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1288
1285
|
}
|
|
1289
1286
|
if (useLegacyFunctionCalling) {
|
|
1290
1287
|
if (toolCalls.length > 1) throw new UnsupportedFunctionalityError({ functionality: "useLegacyFunctionCalling with multiple tool calls in one message" });
|
|
@@ -2641,14 +2638,12 @@ function convertToOpenAIResponsesMessages({ prompt, systemMessageMode }) {
|
|
|
2641
2638
|
}]
|
|
2642
2639
|
});
|
|
2643
2640
|
break;
|
|
2644
|
-
case "tool-call":
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
});
|
|
2651
|
-
break;
|
|
2641
|
+
case "tool-call": messages.push({
|
|
2642
|
+
type: "function_call",
|
|
2643
|
+
call_id: part.toolCallId,
|
|
2644
|
+
name: part.toolName,
|
|
2645
|
+
arguments: JSON.stringify(part.args)
|
|
2646
|
+
});
|
|
2652
2647
|
}
|
|
2653
2648
|
break;
|
|
2654
2649
|
case "tool":
|
|
@@ -2704,20 +2699,16 @@ function prepareResponsesTools({ mode, strict }) {
|
|
|
2704
2699
|
user_location: tool.args.userLocation
|
|
2705
2700
|
});
|
|
2706
2701
|
break;
|
|
2707
|
-
default:
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
});
|
|
2712
|
-
break;
|
|
2702
|
+
default: toolWarnings.push({
|
|
2703
|
+
type: "unsupported-tool",
|
|
2704
|
+
tool
|
|
2705
|
+
});
|
|
2713
2706
|
}
|
|
2714
2707
|
break;
|
|
2715
|
-
default:
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
});
|
|
2720
|
-
break;
|
|
2708
|
+
default: toolWarnings.push({
|
|
2709
|
+
type: "unsupported-tool",
|
|
2710
|
+
tool
|
|
2711
|
+
});
|
|
2721
2712
|
}
|
|
2722
2713
|
if (toolChoice == null) return {
|
|
2723
2714
|
tools: openaiTools2,
|
|
@@ -3332,19 +3323,21 @@ var OpenAISpeechModel = class {
|
|
|
3332
3323
|
speed,
|
|
3333
3324
|
instructions
|
|
3334
3325
|
};
|
|
3335
|
-
if (outputFormat)
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3326
|
+
if (outputFormat) {
|
|
3327
|
+
if ([
|
|
3328
|
+
"mp3",
|
|
3329
|
+
"opus",
|
|
3330
|
+
"aac",
|
|
3331
|
+
"flac",
|
|
3332
|
+
"wav",
|
|
3333
|
+
"pcm"
|
|
3334
|
+
].includes(outputFormat)) requestBody.response_format = outputFormat;
|
|
3335
|
+
else warnings.push({
|
|
3336
|
+
type: "unsupported-setting",
|
|
3337
|
+
setting: "outputFormat",
|
|
3338
|
+
details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3348
3341
|
if (openAIOptions) {
|
|
3349
3342
|
const speechModelOptions = {};
|
|
3350
3343
|
for (const key in speechModelOptions) {
|
|
@@ -4948,21 +4941,22 @@ var RecursiveJsonTransformer = class RecursiveJsonTransformer {
|
|
|
4948
4941
|
*/
|
|
4949
4942
|
handlePrimitiveValue(value, key, currentChunk, chunks, fullPath) {
|
|
4950
4943
|
const testValue = { [key]: value };
|
|
4951
|
-
if (RecursiveJsonTransformer.jsonSize(testValue) <= this.maxSize)
|
|
4952
|
-
|
|
4953
|
-
...testValue
|
|
4954
|
-
}) <= this.maxSize) return {
|
|
4955
|
-
currentChunk: {
|
|
4944
|
+
if (RecursiveJsonTransformer.jsonSize(testValue) <= this.maxSize) {
|
|
4945
|
+
if (RecursiveJsonTransformer.jsonSize({
|
|
4956
4946
|
...currentChunk,
|
|
4957
4947
|
...testValue
|
|
4958
|
-
}
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4948
|
+
}) <= this.maxSize) return {
|
|
4949
|
+
currentChunk: {
|
|
4950
|
+
...currentChunk,
|
|
4951
|
+
...testValue
|
|
4952
|
+
},
|
|
4953
|
+
chunks
|
|
4954
|
+
};
|
|
4955
|
+
else return {
|
|
4956
|
+
currentChunk: testValue,
|
|
4957
|
+
chunks: [...chunks, currentChunk]
|
|
4958
|
+
};
|
|
4959
|
+
} else if (typeof value === "string") {
|
|
4966
4960
|
const newChunks = this.splitLongString(value).map((chunk) => {
|
|
4967
4961
|
return this.createChunk(chunk, fullPath);
|
|
4968
4962
|
}).filter((chunk) => RecursiveJsonTransformer.jsonSize(chunk) <= this.maxSize);
|
|
@@ -6896,9 +6890,10 @@ const createGraphRAGTool = (options) => {
|
|
|
6896
6890
|
};
|
|
6897
6891
|
const graphRag = new GraphRAG(graphOptions.dimension, graphOptions.threshold);
|
|
6898
6892
|
let isInitialized = false;
|
|
6893
|
+
const inputSchema = options.enableFilter ? filterSchema : z.object(baseSchema).passthrough();
|
|
6899
6894
|
return createTool({
|
|
6900
6895
|
id: toolId,
|
|
6901
|
-
inputSchema
|
|
6896
|
+
inputSchema,
|
|
6902
6897
|
outputSchema: outputSchema$1,
|
|
6903
6898
|
description: toolDescription,
|
|
6904
6899
|
execute: async (inputData, context) => {
|
|
@@ -7042,10 +7037,13 @@ const createGraphRAGTool = (options) => {
|
|
|
7042
7037
|
const createVectorQueryTool = (options) => {
|
|
7043
7038
|
const { id, description } = options;
|
|
7044
7039
|
const storeName = options["vectorStoreName"] ? options.vectorStoreName : "DirectVectorStore";
|
|
7040
|
+
const toolId = id || `VectorQuery ${storeName} ${options.indexName} Tool`;
|
|
7041
|
+
const toolDescription = description || defaultVectorQueryDescription();
|
|
7042
|
+
const inputSchema = options.enableFilter ? filterSchema : z.object(baseSchema).passthrough();
|
|
7045
7043
|
return createTool({
|
|
7046
|
-
id:
|
|
7047
|
-
description:
|
|
7048
|
-
inputSchema
|
|
7044
|
+
id: toolId,
|
|
7045
|
+
description: toolDescription,
|
|
7046
|
+
inputSchema,
|
|
7049
7047
|
outputSchema: outputSchema$1,
|
|
7050
7048
|
execute: async (inputData, context) => {
|
|
7051
7049
|
const { requestContext, mastra, tracingContext } = context || {};
|