File tree Expand file tree Collapse file tree 2 files changed +65
-8
lines changed
Expand file tree Collapse file tree 2 files changed +65
-8
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,17 @@ import { DbOperationArgs, MongoDBToolBase } from "../mongodbTool.js";
44import { ToolArgs , OperationType } from "../../tool.js" ;
55import { checkIndexUsage } from "../../../helpers/indexCheck.js" ;
66
7+ export function deleteManyResponse ( collection : string , delectedCount : number ) : CallToolResult {
8+ return {
9+ content : [
10+ {
11+ text : `Deleted \`${ delectedCount } \` document(s) from collection "${ collection } "` ,
12+ type : "text" ,
13+ } ,
14+ ] ,
15+ } ;
16+ }
17+
718export class DeleteManyTool extends MongoDBToolBase {
819 protected name = "delete-many" ;
920 protected description = "Removes all documents that match the filter from a MongoDB collection" ;
@@ -45,13 +56,6 @@ export class DeleteManyTool extends MongoDBToolBase {
4556
4657 const result = await provider . deleteMany ( database , collection , filter ) ;
4758
48- return {
49- content : [
50- {
51- text : `Deleted \`${ result . deletedCount } \` document(s) from collection "${ collection } "` ,
52- type : "text" ,
53- } ,
54- ] ,
55- } ;
59+ return deleteManyResponse ( collection , result . deletedCount ) ;
5660 }
5761}
Original file line number Diff line number Diff line change 1+ import { describeAccuracyTests } from "./sdk/describe-accuracy-tests.js" ;
2+ import { getAvailableModels } from "./sdk/models.js" ;
3+ import { AccuracyTestConfig } from "./sdk/describe-accuracy-tests.js" ;
4+ import { deleteManyResponse } from "../../src/tools/mongodb/delete/deleteMany.js" ;
5+
6+ function callsDeleteManyWithEmptyFilters ( prompt : string ) : AccuracyTestConfig {
7+ return {
8+ injectConnectedAssumption : true ,
9+ prompt : prompt ,
10+ mockedTools : {
11+ "delete-many" : function listDatabases ( ) {
12+ return deleteManyResponse ( "coll1" , 10 ) ;
13+ } ,
14+ } ,
15+ expectedToolCalls : [
16+ {
17+ toolName : "delete-many" ,
18+ parameters : {
19+ database : "db1" ,
20+ collection : "coll1" ,
21+ } ,
22+ } ,
23+ ] ,
24+ } ;
25+ }
26+
27+ function callsDeleteManyWithFilters ( prompt : string ) : AccuracyTestConfig {
28+ return {
29+ injectConnectedAssumption : true ,
30+ prompt : prompt ,
31+ mockedTools : {
32+ "delete-many" : function listDatabases ( ) {
33+ return deleteManyResponse ( "coll1" , 10 ) ;
34+ } ,
35+ } ,
36+ expectedToolCalls : [
37+ {
38+ toolName : "delete-many" ,
39+ parameters : {
40+ database : "db1" ,
41+ collection : "coll1" ,
42+ filters : { provider : "BongoDB" } ,
43+ } ,
44+ } ,
45+ ] ,
46+ } ;
47+ }
48+
49+ describeAccuracyTests ( "delete-many" , getAvailableModels ( ) , [
50+ callsDeleteManyWithEmptyFilters ( "Delete all the documents from 'db1.coll1' namespace" ) ,
51+ callsDeleteManyWithEmptyFilters ( "Purge the collection 'coll1' in database 'db1'" ) ,
52+ callsDeleteManyWithFilters ( "Remove all the documents from namespace 'db1.coll1' where provider is 'BongoDB'" ) ,
53+ ] ) ;
You can’t perform that action at this time.
0 commit comments