Skip to content

Commit 978bcbc

Browse files
committed
chore: improvements on documentation
1 parent 1c5955a commit 978bcbc

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/tools/mongodb/read/aggregate.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const VectorSearchStage = z.object({
2626
.describe(
2727
"When true, uses an ENN algorithm, otherwise uses ANN. Using ENN is not compatible with numCandidates, in that case, numCandidates must be left empty."
2828
),
29-
index: z.string().describe("Name of the index, as retrieved from the collection-indexes tool."),
29+
index: z.string().describe("Name of the index, as retrieved from the `collection-indexes` tool."),
3030
path: z
3131
.string()
3232
.describe(
@@ -35,18 +35,20 @@ const VectorSearchStage = z.object({
3535
queryVector: z
3636
.union([z.string(), z.array(z.number())])
3737
.describe(
38-
"The content to search for. If a string, the embeddingModel is mandatory, if not, the embeddingModel is ignored."
38+
"The content to search for. The embeddingParameters field is mandatory if the queryVector is a string."
3939
),
4040
numCandidates: z
4141
.number()
4242
.int()
4343
.positive()
4444
.optional()
45-
.describe("Number of candidates for the ANN algorithm. Only valid when exact is false."),
45+
.describe("Number of candidates for the ANN algorithm. Mandatory when exact is false."),
4646
limit: z.number().int().positive().optional().default(10),
4747
filter: zEJSON()
4848
.optional()
49-
.describe("MQL filter that can only use pre-filter fields from the index definition."),
49+
.describe(
50+
"MQL filter that can only use pre-filter fields from the index definition. Note to LLM: If unsure, use the `collection-indexes` tool to learn which fields can be used for pre-filtering."
51+
),
5052
embeddingParameters: zSupportedEmbeddingParameters
5153
.optional()
5254
.describe(
@@ -252,9 +254,9 @@ export class AggregateTool extends MongoDBToolBase {
252254
inputType: "query",
253255
});
254256

255-
// $vectorSearch.queryVector can be a BSON.Binary, which is neither a number nor an array.
256-
// It's not exactly valid from the LLM perspective. That's why we overwrite the
257-
// stage in an untyped way, as what we expose and what we can use are different.
257+
// $vectorSearch.queryVector can be a BSON.Binary: that it's not either number or an array.
258+
// It's not exactly valid from the LLM perspective (they can't provide binaries).
259+
// That's why we overwrite the stage in an untyped way, as what we expose and what LLMs can use is different.
258260
vectorSearchStage.queryVector = embeddings as number[];
259261
}
260262
}

0 commit comments

Comments
 (0)