Skip to content

AI Assistant: adjust filterValue schema for gemini#33741

Merged
anna-shakhova merged 1 commit into
DevExpress:26_1from
anna-shakhova:26_1__ai_assistant_filter
May 27, 2026
Merged

AI Assistant: adjust filterValue schema for gemini#33741
anna-shakhova merged 1 commit into
DevExpress:26_1from
anna-shakhova:26_1__ai_assistant_filter

Conversation

@anna-shakhova
Copy link
Copy Markdown
Contributor

No description provided.

@anna-shakhova anna-shakhova self-assigned this May 27, 2026
Copilot AI review requested due to automatic review settings May 27, 2026 08:19
@anna-shakhova anna-shakhova requested a review from a team as a code owner May 27, 2026 08:19
@anna-shakhova anna-shakhova changed the title AI Assistant: adjust filterValue scheme for gemini AI Assistant: adjust filterValue schema for gemini May 27, 2026
type FilterExprObj = BasicFilterExpr | CombinedFilterExpr | NegatedFilterExpr;
type FilterExpr = BasicFilterExpr | CombinedFilterExpr | NegatedFilterExpr;

interface FilterExprNode {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The node id lives on this wrapper, not inside the expr union. Azure OpenAI's strict structured-output mode rejects an anyOf whose object branches share an identical property (the variants would all carry id: string); keeping id out of the union leaves the branches sharing only their type discriminator.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the filterValueCommand Zod schema used by the grid AI assistant so it works with structured-output providers (notably Gemini) that don't support recursive schemas. The previous recursive expression form (using nested left/right/expression) is replaced with a flat node-list tree ({ rootId, nodes } where nodes reference each other by id), and a new converter walks the node graph to produce the existing legacy filterValue array consumed by the grid. Tests are updated and expanded accordingly.

Changes:

  • Replaced the recursive z.lazy schema with separate basic/combined/negated variants that reference other nodes by id, plus a FilterExprTree wrapper.
  • Added a convertFilterExprToArray implementation that validates uniqueness, missing references, and cycles, and updated the command description to instruct the model in the new format.
  • Refactored existing filtering tests around new basicNode/combinedNode/negatedNode/tree helpers and added coverage for empty nodes, strictness, duplicate ids, missing rootId/refs, cycles, and unreachable nodes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/filtering.ts Switches filterValueCommand to a flat node-list schema and adds an id-resolving converter to the legacy array form.
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/__tests__/filtering.test.ts Rewrites helpers/tests for the new tree shape and adds converter-failure tests (duplicate id, missing refs, cycle, unreachable nodes).

@anna-shakhova anna-shakhova merged commit 629eaa0 into DevExpress:26_1 May 27, 2026
103 checks passed
@anna-shakhova anna-shakhova deleted the 26_1__ai_assistant_filter branch May 27, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants