@memorylayerai/vercel-ai 0.3.2 → 0.4.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.cjs +26 -5
- package/dist/index.d.cts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +26 -5
- package/package.json +2 -2
- package/src/tools.ts +32 -2
package/dist/index.cjs
CHANGED
|
@@ -154,19 +154,38 @@ function memoryTool(config) {
|
|
|
154
154
|
}
|
|
155
155
|
function searchTool(config) {
|
|
156
156
|
return {
|
|
157
|
-
description: "Search memories in the MemoryLayer system to retrieve relevant information",
|
|
157
|
+
description: "Search memories in the MemoryLayer system to retrieve relevant information with advanced retrieval options",
|
|
158
158
|
parameters: import_zod.z.object({
|
|
159
159
|
query: import_zod.z.string().describe("The search query to find relevant memories"),
|
|
160
160
|
limit: import_zod.z.number().optional().describe("Maximum number of results to return (default: 10)"),
|
|
161
|
-
threshold: import_zod.z.number().optional().describe("Minimum relevance score threshold (0-1)")
|
|
161
|
+
threshold: import_zod.z.number().optional().describe("Minimum relevance score threshold (0-1)"),
|
|
162
|
+
enableQueryRewriting: import_zod.z.boolean().optional().describe("Enable query rewriting for better results (default: true)"),
|
|
163
|
+
enableEntityExpansion: import_zod.z.boolean().optional().describe("Enable entity expansion search (default: false)"),
|
|
164
|
+
enableGraphConnectivity: import_zod.z.boolean().optional().describe("Enable graph connectivity search (default: false)"),
|
|
165
|
+
enableSemanticDedup: import_zod.z.boolean().optional().describe("Enable semantic deduplication (default: false)"),
|
|
166
|
+
rerankingStrategy: import_zod.z.enum(["none", "cross-encoder", "llm"]).optional().describe("Reranking strategy (default: none)")
|
|
162
167
|
}),
|
|
163
|
-
execute: async ({
|
|
168
|
+
execute: async ({
|
|
169
|
+
query,
|
|
170
|
+
limit,
|
|
171
|
+
threshold,
|
|
172
|
+
enableQueryRewriting,
|
|
173
|
+
enableEntityExpansion,
|
|
174
|
+
enableGraphConnectivity,
|
|
175
|
+
enableSemanticDedup,
|
|
176
|
+
rerankingStrategy
|
|
177
|
+
}) => {
|
|
164
178
|
try {
|
|
165
179
|
const response = await config.client.search.search({
|
|
166
180
|
query,
|
|
167
181
|
projectId: config.projectId,
|
|
168
182
|
limit,
|
|
169
|
-
threshold
|
|
183
|
+
threshold,
|
|
184
|
+
enableQueryRewriting,
|
|
185
|
+
enableEntityExpansion,
|
|
186
|
+
enableGraphConnectivity,
|
|
187
|
+
enableSemanticDedup,
|
|
188
|
+
rerankingStrategy
|
|
170
189
|
});
|
|
171
190
|
return {
|
|
172
191
|
success: true,
|
|
@@ -174,7 +193,9 @@ function searchTool(config) {
|
|
|
174
193
|
content: r.memory.content,
|
|
175
194
|
score: r.score,
|
|
176
195
|
metadata: r.memory.metadata,
|
|
177
|
-
id: r.memory.id
|
|
196
|
+
id: r.memory.id,
|
|
197
|
+
scoreBreakdown: r.scoreBreakdown,
|
|
198
|
+
connections: r.connections
|
|
178
199
|
})),
|
|
179
200
|
total: response.total
|
|
180
201
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -199,19 +199,39 @@ declare function searchTool(config: MemoryToolConfig): {
|
|
|
199
199
|
query: z.ZodString;
|
|
200
200
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
201
201
|
threshold: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
enableQueryRewriting: z.ZodOptional<z.ZodBoolean>;
|
|
203
|
+
enableEntityExpansion: z.ZodOptional<z.ZodBoolean>;
|
|
204
|
+
enableGraphConnectivity: z.ZodOptional<z.ZodBoolean>;
|
|
205
|
+
enableSemanticDedup: z.ZodOptional<z.ZodBoolean>;
|
|
206
|
+
rerankingStrategy: z.ZodOptional<z.ZodEnum<["none", "cross-encoder", "llm"]>>;
|
|
202
207
|
}, "strip", z.ZodTypeAny, {
|
|
203
208
|
query: string;
|
|
204
209
|
limit?: number | undefined;
|
|
205
210
|
threshold?: number | undefined;
|
|
211
|
+
enableQueryRewriting?: boolean | undefined;
|
|
212
|
+
enableEntityExpansion?: boolean | undefined;
|
|
213
|
+
enableGraphConnectivity?: boolean | undefined;
|
|
214
|
+
enableSemanticDedup?: boolean | undefined;
|
|
215
|
+
rerankingStrategy?: "none" | "cross-encoder" | "llm" | undefined;
|
|
206
216
|
}, {
|
|
207
217
|
query: string;
|
|
208
218
|
limit?: number | undefined;
|
|
209
219
|
threshold?: number | undefined;
|
|
220
|
+
enableQueryRewriting?: boolean | undefined;
|
|
221
|
+
enableEntityExpansion?: boolean | undefined;
|
|
222
|
+
enableGraphConnectivity?: boolean | undefined;
|
|
223
|
+
enableSemanticDedup?: boolean | undefined;
|
|
224
|
+
rerankingStrategy?: "none" | "cross-encoder" | "llm" | undefined;
|
|
210
225
|
}>;
|
|
211
|
-
execute: ({ query, limit, threshold }: {
|
|
226
|
+
execute: ({ query, limit, threshold, enableQueryRewriting, enableEntityExpansion, enableGraphConnectivity, enableSemanticDedup, rerankingStrategy, }: {
|
|
212
227
|
query: string;
|
|
213
228
|
limit?: number;
|
|
214
229
|
threshold?: number;
|
|
230
|
+
enableQueryRewriting?: boolean;
|
|
231
|
+
enableEntityExpansion?: boolean;
|
|
232
|
+
enableGraphConnectivity?: boolean;
|
|
233
|
+
enableSemanticDedup?: boolean;
|
|
234
|
+
rerankingStrategy?: "none" | "cross-encoder" | "llm";
|
|
215
235
|
}) => Promise<{
|
|
216
236
|
success: boolean;
|
|
217
237
|
results: any;
|
package/dist/index.d.ts
CHANGED
|
@@ -199,19 +199,39 @@ declare function searchTool(config: MemoryToolConfig): {
|
|
|
199
199
|
query: z.ZodString;
|
|
200
200
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
201
201
|
threshold: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
enableQueryRewriting: z.ZodOptional<z.ZodBoolean>;
|
|
203
|
+
enableEntityExpansion: z.ZodOptional<z.ZodBoolean>;
|
|
204
|
+
enableGraphConnectivity: z.ZodOptional<z.ZodBoolean>;
|
|
205
|
+
enableSemanticDedup: z.ZodOptional<z.ZodBoolean>;
|
|
206
|
+
rerankingStrategy: z.ZodOptional<z.ZodEnum<["none", "cross-encoder", "llm"]>>;
|
|
202
207
|
}, "strip", z.ZodTypeAny, {
|
|
203
208
|
query: string;
|
|
204
209
|
limit?: number | undefined;
|
|
205
210
|
threshold?: number | undefined;
|
|
211
|
+
enableQueryRewriting?: boolean | undefined;
|
|
212
|
+
enableEntityExpansion?: boolean | undefined;
|
|
213
|
+
enableGraphConnectivity?: boolean | undefined;
|
|
214
|
+
enableSemanticDedup?: boolean | undefined;
|
|
215
|
+
rerankingStrategy?: "none" | "cross-encoder" | "llm" | undefined;
|
|
206
216
|
}, {
|
|
207
217
|
query: string;
|
|
208
218
|
limit?: number | undefined;
|
|
209
219
|
threshold?: number | undefined;
|
|
220
|
+
enableQueryRewriting?: boolean | undefined;
|
|
221
|
+
enableEntityExpansion?: boolean | undefined;
|
|
222
|
+
enableGraphConnectivity?: boolean | undefined;
|
|
223
|
+
enableSemanticDedup?: boolean | undefined;
|
|
224
|
+
rerankingStrategy?: "none" | "cross-encoder" | "llm" | undefined;
|
|
210
225
|
}>;
|
|
211
|
-
execute: ({ query, limit, threshold }: {
|
|
226
|
+
execute: ({ query, limit, threshold, enableQueryRewriting, enableEntityExpansion, enableGraphConnectivity, enableSemanticDedup, rerankingStrategy, }: {
|
|
212
227
|
query: string;
|
|
213
228
|
limit?: number;
|
|
214
229
|
threshold?: number;
|
|
230
|
+
enableQueryRewriting?: boolean;
|
|
231
|
+
enableEntityExpansion?: boolean;
|
|
232
|
+
enableGraphConnectivity?: boolean;
|
|
233
|
+
enableSemanticDedup?: boolean;
|
|
234
|
+
rerankingStrategy?: "none" | "cross-encoder" | "llm";
|
|
215
235
|
}) => Promise<{
|
|
216
236
|
success: boolean;
|
|
217
237
|
results: any;
|
package/dist/index.js
CHANGED
|
@@ -122,19 +122,38 @@ function memoryTool(config) {
|
|
|
122
122
|
}
|
|
123
123
|
function searchTool(config) {
|
|
124
124
|
return {
|
|
125
|
-
description: "Search memories in the MemoryLayer system to retrieve relevant information",
|
|
125
|
+
description: "Search memories in the MemoryLayer system to retrieve relevant information with advanced retrieval options",
|
|
126
126
|
parameters: z.object({
|
|
127
127
|
query: z.string().describe("The search query to find relevant memories"),
|
|
128
128
|
limit: z.number().optional().describe("Maximum number of results to return (default: 10)"),
|
|
129
|
-
threshold: z.number().optional().describe("Minimum relevance score threshold (0-1)")
|
|
129
|
+
threshold: z.number().optional().describe("Minimum relevance score threshold (0-1)"),
|
|
130
|
+
enableQueryRewriting: z.boolean().optional().describe("Enable query rewriting for better results (default: true)"),
|
|
131
|
+
enableEntityExpansion: z.boolean().optional().describe("Enable entity expansion search (default: false)"),
|
|
132
|
+
enableGraphConnectivity: z.boolean().optional().describe("Enable graph connectivity search (default: false)"),
|
|
133
|
+
enableSemanticDedup: z.boolean().optional().describe("Enable semantic deduplication (default: false)"),
|
|
134
|
+
rerankingStrategy: z.enum(["none", "cross-encoder", "llm"]).optional().describe("Reranking strategy (default: none)")
|
|
130
135
|
}),
|
|
131
|
-
execute: async ({
|
|
136
|
+
execute: async ({
|
|
137
|
+
query,
|
|
138
|
+
limit,
|
|
139
|
+
threshold,
|
|
140
|
+
enableQueryRewriting,
|
|
141
|
+
enableEntityExpansion,
|
|
142
|
+
enableGraphConnectivity,
|
|
143
|
+
enableSemanticDedup,
|
|
144
|
+
rerankingStrategy
|
|
145
|
+
}) => {
|
|
132
146
|
try {
|
|
133
147
|
const response = await config.client.search.search({
|
|
134
148
|
query,
|
|
135
149
|
projectId: config.projectId,
|
|
136
150
|
limit,
|
|
137
|
-
threshold
|
|
151
|
+
threshold,
|
|
152
|
+
enableQueryRewriting,
|
|
153
|
+
enableEntityExpansion,
|
|
154
|
+
enableGraphConnectivity,
|
|
155
|
+
enableSemanticDedup,
|
|
156
|
+
rerankingStrategy
|
|
138
157
|
});
|
|
139
158
|
return {
|
|
140
159
|
success: true,
|
|
@@ -142,7 +161,9 @@ function searchTool(config) {
|
|
|
142
161
|
content: r.memory.content,
|
|
143
162
|
score: r.score,
|
|
144
163
|
metadata: r.memory.metadata,
|
|
145
|
-
id: r.memory.id
|
|
164
|
+
id: r.memory.id,
|
|
165
|
+
scoreBreakdown: r.scoreBreakdown,
|
|
166
|
+
connections: r.connections
|
|
146
167
|
})),
|
|
147
168
|
total: response.total
|
|
148
169
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memorylayerai/vercel-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Vercel AI SDK integration for MemoryLayer",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"author": "MemoryLayer",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@memorylayerai/sdk": "^0.
|
|
33
|
+
"@memorylayerai/sdk": "^0.4.0",
|
|
34
34
|
"ai": "^3.0.0",
|
|
35
35
|
"zod": "^3.22.4"
|
|
36
36
|
},
|
package/src/tools.ts
CHANGED
|
@@ -97,19 +97,47 @@ export function memoryTool(config: MemoryToolConfig) {
|
|
|
97
97
|
*/
|
|
98
98
|
export function searchTool(config: MemoryToolConfig) {
|
|
99
99
|
return {
|
|
100
|
-
description: 'Search memories in the MemoryLayer system to retrieve relevant information',
|
|
100
|
+
description: 'Search memories in the MemoryLayer system to retrieve relevant information with advanced retrieval options',
|
|
101
101
|
parameters: z.object({
|
|
102
102
|
query: z.string().describe('The search query to find relevant memories'),
|
|
103
103
|
limit: z.number().optional().describe('Maximum number of results to return (default: 10)'),
|
|
104
104
|
threshold: z.number().optional().describe('Minimum relevance score threshold (0-1)'),
|
|
105
|
+
enableQueryRewriting: z.boolean().optional().describe('Enable query rewriting for better results (default: true)'),
|
|
106
|
+
enableEntityExpansion: z.boolean().optional().describe('Enable entity expansion search (default: false)'),
|
|
107
|
+
enableGraphConnectivity: z.boolean().optional().describe('Enable graph connectivity search (default: false)'),
|
|
108
|
+
enableSemanticDedup: z.boolean().optional().describe('Enable semantic deduplication (default: false)'),
|
|
109
|
+
rerankingStrategy: z.enum(['none', 'cross-encoder', 'llm']).optional().describe('Reranking strategy (default: none)'),
|
|
105
110
|
}),
|
|
106
|
-
execute: async ({
|
|
111
|
+
execute: async ({
|
|
112
|
+
query,
|
|
113
|
+
limit,
|
|
114
|
+
threshold,
|
|
115
|
+
enableQueryRewriting,
|
|
116
|
+
enableEntityExpansion,
|
|
117
|
+
enableGraphConnectivity,
|
|
118
|
+
enableSemanticDedup,
|
|
119
|
+
rerankingStrategy,
|
|
120
|
+
}: {
|
|
121
|
+
query: string;
|
|
122
|
+
limit?: number;
|
|
123
|
+
threshold?: number;
|
|
124
|
+
enableQueryRewriting?: boolean;
|
|
125
|
+
enableEntityExpansion?: boolean;
|
|
126
|
+
enableGraphConnectivity?: boolean;
|
|
127
|
+
enableSemanticDedup?: boolean;
|
|
128
|
+
rerankingStrategy?: 'none' | 'cross-encoder' | 'llm';
|
|
129
|
+
}) => {
|
|
107
130
|
try {
|
|
108
131
|
const response = await config.client.search.search({
|
|
109
132
|
query,
|
|
110
133
|
projectId: config.projectId,
|
|
111
134
|
limit,
|
|
112
135
|
threshold,
|
|
136
|
+
enableQueryRewriting,
|
|
137
|
+
enableEntityExpansion,
|
|
138
|
+
enableGraphConnectivity,
|
|
139
|
+
enableSemanticDedup,
|
|
140
|
+
rerankingStrategy,
|
|
113
141
|
});
|
|
114
142
|
|
|
115
143
|
return {
|
|
@@ -119,6 +147,8 @@ export function searchTool(config: MemoryToolConfig) {
|
|
|
119
147
|
score: r.score,
|
|
120
148
|
metadata: r.memory.metadata,
|
|
121
149
|
id: r.memory.id,
|
|
150
|
+
scoreBreakdown: r.scoreBreakdown,
|
|
151
|
+
connections: r.connections,
|
|
122
152
|
})),
|
|
123
153
|
total: response.total,
|
|
124
154
|
};
|