-
Notifications
You must be signed in to change notification settings - Fork 246
fix(gen-ai): parse responses individually for find and aggregate COMPASS-10176 #7645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modifies the generative AI query parsing logic to handle find and aggregate operations separately, ensuring each operation type receives only its relevant response fields.
Key Changes:
- Modified
parseXmlToJsonResponseto accept atypeparameter ('find' or 'aggregate') to determine response structure - For 'aggregate' type, only the aggregation pipeline is returned; for 'find' type, both query and aggregation fields are returned
- Updated all call sites to pass the appropriate type parameter
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/compass-generative-ai/src/utils/parse-xml-response.ts | Refactored to accept type parameter and conditionally return response fields based on operation type |
| packages/compass-generative-ai/src/utils/parse-xml-response.spec.ts | Restructured tests into separate contexts for 'find' and 'aggregate' operations with updated expectations |
| packages/compass-generative-ai/src/atlas-ai-service.ts | Updated call sites to pass the type parameter ('find' or 'aggregate') to parseXmlToJsonResponse |
| packages/compass-generative-ai/src/atlas-ai-service.spec.ts | Added aggregation field to test expectation to match new response structure |
| limit: '10', | ||
| context('handles aggregate', function () { | ||
| const options = { logger: createNoopLogger(), type: 'aggregate' as const }; | ||
| it('returns empty pipeline its not available in the response', function () { |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling: 'its' should be 'if it's' or 'when it's' for grammatical correctness.
| it('returns empty pipeline its not available in the response', function () { | |
| it("returns empty pipeline if it's not available in the response", function () { |
| : {}), | ||
| ...(isQueryEmpty ? {} : { query }), | ||
| query, | ||
| aggregation, |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the 'find' type, returning both query and aggregation fields means aggregation will always be included even when not relevant to find operations. Consider if the find path should only return query-related fields to maintain a clearer separation between operation types, similar to how aggregate only returns aggregation.
| aggregation, |
ivandevp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes