-
Notifications
You must be signed in to change notification settings - Fork 0
fix(components): correct index parsing in AIListFilter component #324
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
|
🏷️ This PR has been automatically assigned to milestone 1.0.0-alpha based on the version in |
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 fixes a bug in the AIListFilter component where it was incorrectly looking for an indices key in the tool result when the actual response contains a result key. Additionally, it significantly enhances the parsing capabilities of the ParsingTools utility.
- Fixed the key name from
indicestoresultin AIListFilter component - Enhanced ParsingTools with comprehensive index parsing support for various formats
- Added CHANGELOG entry documenting the fix
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/SmartHopper.Components/List/AIListFilter.cs | Fixed the key name from "indices" to "result" when parsing tool results |
| src/SmartHopper.Core.Grasshopper/Utils/ParsingTools.cs | Significantly expanded index parsing capabilities with support for JSON arrays, objects, ranges, and various text formats |
| CHANGELOG.md | Added entry documenting the AIListFilter bug fix |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| /// </summary> | ||
| private static string ExtractFromMarkdownCodeBlock(string text) | ||
| { | ||
| var match = System.Text.RegularExpressions.Regex.Match(text, @"```(?:json|txt|text)?\s*\n?(.*?)\n?```", System.Text.RegularExpressions.RegexOptions.Singleline); |
Copilot
AI
Oct 11, 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.
Consider caching this regex pattern as a static readonly field to avoid recompiling the pattern on every method call.
| /// </summary> | ||
| private static string ExtractFirstBracketedArray(string text) | ||
| { | ||
| var match = System.Text.RegularExpressions.Regex.Match(text, @"\[([^\[\]]*)\]"); |
Copilot
AI
Oct 11, 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.
Consider caching this regex pattern as a static readonly field to avoid recompiling the pattern on every method call.
| private static string ExpandRanges(string text) | ||
| { | ||
| var result = System.Text.RegularExpressions.Regex.Replace(text, @"(\d+)(?:-|\.\.)(\d+)", match => |
Copilot
AI
Oct 11, 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.
Consider caching this regex pattern as a static readonly field to avoid recompiling the pattern on every method call.
| private static string ExpandRanges(string text) | |
| { | |
| var result = System.Text.RegularExpressions.Regex.Replace(text, @"(\d+)(?:-|\.\.)(\d+)", match => | |
| private static readonly System.Text.RegularExpressions.Regex RangeRegex = | |
| new System.Text.RegularExpressions.Regex(@"(\d+)(?:-|\.\.)(\d+)", System.Text.RegularExpressions.RegexOptions.Compiled); | |
| private static string ExpandRanges(string text) | |
| { | |
| var result = RangeRegex.Replace(text, match => |
| trimmed = ExpandRanges(trimmed); | ||
|
|
||
| // 6. Extract all numbers from comma/space/newline-separated text | ||
| var parts = System.Text.RegularExpressions.Regex.Split(trimmed, @"[,\s\n\r]+"); |
Copilot
AI
Oct 11, 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.
Consider caching this regex pattern as a static readonly field to avoid recompiling the pattern on every method call.
…ns for optimization
Description
Fixed an issue in the AIListFilter component where it was incorrectly looking for an
indiceskey in the tool result when the actual response contains aresultkey. This was causing the component to return empty results even when the AI successfully identified matching indices.Changes Made
toolResult["result"]instead oftoolResult["indices"]Testing Done
Breaking Changes
Checklist