Skip to content

Commit a4ccfae

Browse files
committed
fix agg test
1 parent 8aa1980 commit a4ccfae

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/tools/mongodb/read/aggregate.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020

2121
const pipelineDescriptionWithVectorSearch = `\
2222
An array of aggregation stages to execute.
23-
\`$vectorSearch\` **MUST** be the first stage of the pipeline, or the first stage of a \`$unionWith\` subpipeline.
23+
If the user has asked for a vector search, \`$vectorSearch\` **MUST** be the first stage of the pipeline, or the first stage of a \`$unionWith\` subpipeline.
24+
If the user has asked for lexical/Atlas search, use \`$search\` instead of \`$text\`.
2425
### Usage Rules for \`$vectorSearch\`
2526
- **Unset embeddings:**
2627
Unless the user explicitly requests the embeddings, add an \`$unset\` stage **at the end of the pipeline** to remove the embedding field and avoid context limits. **The $unset stage in this situation is mandatory**.
@@ -29,9 +30,12 @@ If the user requests additional filtering, include filters in \`$vectorSearch.fi
2930
NEVER include fields in $vectorSearch.filter that are not part of the vector index.
3031
- **Post-filtering:**
3132
For all remaining filters, add a $match stage after $vectorSearch.
32-
### Note to LLM
3333
- If unsure which fields are filterable, use the collection-indexes tool to determine valid prefilter fields.
34-
- If no requested filters are valid prefilters, omit the filter key from $vectorSearch.\
34+
- If no requested filters are valid prefilters, omit the filter key from $vectorSearch.
35+
36+
### Usage Rules for \`$search\`
37+
- Include the index name, unless you know for a fact there's a default index. If unsure, use the collection-indexes tool to determine the index name.
38+
- The \`$search\` stage supports multiple operators, such as 'autocomplete', 'text', 'geoWithin', and others. Choose the approprate operator based on the user's query. If unsure of the exact syntax, consult the MongoDB Atlas Search documentation, which can be found here: https://www.mongodb.com/docs/atlas/atlas-search/operators-and-collectors/
3539
`;
3640

3741
const genericPipelineDescription = "An array of aggregation stages to execute.";

tests/accuracy/aggregate.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ describeAccuracyTests([
422422
},
423423
},
424424
{
425-
prompt: "Run a search query on mflix.movies to find all movies that mention 'space travel' in the plot.",
425+
prompt: "Run a $search query on mflix.movies to find all movies that mention 'space travel' in the plot or title. Use the default search index.",
426426
expectedToolCalls: [
427427
{
428428
toolName: "aggregate",
@@ -432,9 +432,10 @@ describeAccuracyTests([
432432
pipeline: [
433433
{
434434
$search: {
435-
index: "default",
435+
index: Matcher.anyOf(Matcher.undefined, Matcher.value("default")),
436436
text: {
437437
query: "space travel",
438+
path: ["plot", "title"],
438439
},
439440
},
440441
},

0 commit comments

Comments
 (0)