PHPLIB-1734: Add query and model arguments for automated embedding to $vectorSearch stage#1937
Open
GromNaN wants to merge 1 commit into
Open
PHPLIB-1734: Add query and model arguments for automated embedding to $vectorSearch stage#1937GromNaN wants to merge 1 commit into
GromNaN wants to merge 1 commit into
Conversation
c49fcbf to
55f6333
Compare
This comment was marked as outdated.
This comment was marked as outdated.
2eb2a55 to
a1ee223
Compare
… VectorSearchStage Support the automated embedding feature introduced in MongoDB 8.2, which allows passing a natural language text query instead of a pre-computed queryVector. The $vectorSearch stage now accepts query (string) and model (string) optional arguments. Depends on mongodb/mql-specifications#55.
a1ee223 to
ff0b6c4
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Extends the aggregation builder’s $vectorSearch stage to support MongoDB 8.2 “automated embedding” usage by accepting a natural-language query and optional model override, in addition to the existing queryVector flow.
Changes:
- Added
queryandmodelarguments toVectorSearchStage(and corresponding factory methods). - Made
queryVectoroptional to enable query-text-based vector search. - Added new pipeline fixtures and tests covering the new automated embedding examples.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Builder/Stage/VectorSearchStage.php |
Adds query/model properties and makes queryVector optional for $vectorSearch. |
src/Builder/Stage/FactoryTrait.php |
Updates Stage::vectorSearch() signature to accept optional queryVector, plus query/model. |
src/Builder/Stage/FluentFactoryTrait.php |
Updates fluent ->vectorSearch() signature and forwarding call to include query/model. |
tests/Builder/Stage/VectorSearchStageTest.php |
Adds new test cases building pipelines for automated embedding and model override. |
tests/Builder/Stage/Pipelines.php |
Adds canonical extended JSON fixtures for the new automated embedding pipelines. |
Comments suppressed due to low confidence (1)
src/Builder/Stage/VectorSearchStage.php:154
- The stage currently allows constructing/encoding a $vectorSearch stage without either
queryVectororquery, even though the docblocks (and MongoDB 8.2 automated embedding semantics) require one of them. This results in an invalid pipeline being sent to the server. Consider validating that at least one of$queryVectoror$queryis provided, and that$modelis only accepted when$queryis set (as documented).
$this->index = $index;
$this->limit = $limit;
$this->path = $path;
if (is_array($queryVector) && ! array_is_list($queryVector)) {
throw new InvalidArgumentException('Expected $queryVector argument to be a list, got an associative array.');
Comment on lines
+107
to
+109
| $this->assertSamePipeline(Pipelines::VectorSearchAutomatedEmbeddingWithModelOverride, $pipeline); | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
queryandmodelarguments for autoEmbed to$vectorSearchstage mql-specifications#55arrayIndexAssupport for$filterand$reduceoperators #1936Fix PHPLIB-1734
Add the optional
query(string) andmodel(string) arguments to the$vectorSearchpipeline stage, introduced in MongoDB 8.2 for the Automated Embedding feature.These arguments allow passing a natural language text query instead of a pre-computed
queryVector; MongoDB automatically generates the vector embedding at query time using the embedding model configured in the index, or an optionally overridden compatible model viamodel.queryVectoris now optional (eitherqueryVectororquerymust be provided)queryoptional string argument (minVersion: '8.2')modeloptional string argument (minVersion: '8.2')