feat: add configurable metric type for Milvus vector store#6403
Open
xxiaoxiong wants to merge 3 commits into
Open
feat: add configurable metric type for Milvus vector store#6403xxiaoxiong wants to merge 3 commits into
xxiaoxiong wants to merge 3 commits into
Conversation
Fixes FlowiseAI#5639 When managing credential sharing across multiple workspaces, users had to manually check/uncheck each workspace individually. This was tedious and time-consuming, especially when unsharing a credential from all workspaces. Solution: Add a "Select All" checkbox above the workspace list that allows users to: - Check all workspaces with one click - Uncheck all workspaces with one click - Automatically updates when individual checkboxes are toggled Changes: **packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx** - Import Checkbox and FormControlLabel from MUI - Add `selectAll` state to track the select-all checkbox - Add `handleSelectAllChange` to toggle all workspace checkboxes - Add useEffect to sync selectAll state with individual row changes - Add UI: "Select All" checkbox above the workspace grid - Position: right-aligned next to "Workspaces" label Features: 1. **One-click select all**: Check the "Select All" box to share with all workspaces 2. **One-click deselect all**: Uncheck to unshare from all workspaces 3. **Smart sync**: Checkbox automatically unchecks if any individual workspace is unchecked 4. **Clean UI**: Positioned next to "Workspaces" label, doesn't clutter the interface Testing: 1. Go to Credentials page 2. Click the share icon (⋮ menu → Share) on any credential 3. ✅ See "Select All" checkbox in the top-right 4. Click "Select All" 5. ✅ All workspace checkboxes are checked 6. Click "Select All" again 7. ✅ All workspace checkboxes are unchecked 8. Check "Select All", then uncheck one workspace manually 9. ✅ "Select All" checkbox automatically unchecks 10. Click Save 11. ✅ Only selected workspaces receive the credential Before: Had to scroll and click each workspace individually After: One click to select/deselect all workspaces
Fixes FlowiseAI#5443 When hovering over "+ X More" in the Nodes column of chatflows/agentflows list, the tooltip showed a numbered list (1, 2, 3...) of additional tools. However, these numbers were misleading because: - The first 5 tools are already displayed as icons - The tooltip shows tools 6, 7, 8... but numbered them as 1, 2, 3... - The order is not semantically important - The count is already shown in "+ X More" Solution: Replace ordered list (<ol>) with unordered list (<ul>) to show bullet points instead of numbers. This makes it clear that the list is just "more items" without implying a specific ordering or position. Changes: **packages/ui/src/ui-component/tooltip/MoreItemsTooltip.jsx** - Rename `StyledOl` to `StyledUl` - Change `<ol>` to `<ul>` in the tooltip content - Keep all other styling and behavior unchanged Before: After: Impact: - Chatflows list: Tooltip now shows bullet points - Agentflows list: Tooltip now shows bullet points - No functional changes, only visual improvement - Reduces user confusion about tool ordering Testing: 1. Go to Chatflows or Agentflows page 2. Find a flow with more than 5 tools/nodes 3. Hover over "+ X More" text 4. ✅ Tooltip shows bullet points (•) instead of numbers (1, 2, 3...) 5. ✅ All tool names are still displayed correctly 6. ✅ Tooltip positioning and styling unchanged
Fixes FlowiseAI#6033 ## Problem The Milvus node hardcoded the metric type to L2 (Euclidean distance) when creating indexes. This caused metric type mismatch errors when querying collections configured with COSINE or IP, and limited flexibility for users who need different distance metrics. ## Solution Add a configurable "Metric Type" parameter to the Milvus node that allows users to choose between L2, IP (Inner Product), and COSINE (Cosine Similarity). ## Changes **packages/components/nodes/vectorstores/Milvus/Milvus.ts** 1. **Added new input parameter** (lines 116-138): - Label: "Metric Type" - Type: dropdown with 3 options - Options: L2, IP, COSINE - Default: L2 (maintains backward compatibility) - Category: Additional Parameters 2. **Read metric type in upsert method** (lines 220-221): - Extract metricType from nodeData.inputs - Default to 'L2' if not specified 3. **Pass metric type to MilvusLibArgs in upsert** (lines 246-249): - Set milVusArgs.indexCreateParams.metric_type - Convert string to MetricType enum 4. **Read metric type in init method** (lines 309-310): - Extract metricType from nodeData.inputs - Default to 'L2' if not specified 5. **Pass metric type to MilvusLibArgs in init** (lines 338-341): - Set milVusArgs.indexCreateParams.metric_type - Convert string to MetricType enum 6. **Use configured metric type in index creation** (line 507): - Changed from hardcoded `MetricType.L2` - To `this.indexCreateParams?.metric_type || MetricType.L2` - Falls back to L2 if not configured ## Behavior ### Before - Metric type was always L2 - Queries failed with mismatch errors for COSINE/IP collections - No way to configure metric type ### After - Users can select L2, IP, or COSINE from dropdown - Metric type is used for both index creation and queries - Defaults to L2 for backward compatibility - Existing flows continue to work without changes ## Testing ### Manual Testing 1. **Create new collection with COSINE:** - Set Metric Type to "COSINE" - Upsert documents - ✅ Index created with COSINE metric - ✅ Queries use COSINE metric - ✅ No mismatch errors 2. **Create new collection with IP:** - Set Metric Type to "IP" - Upsert documents - ✅ Index created with IP metric - ✅ Queries use IP metric 3. **Create new collection with L2 (default):** - Leave Metric Type as default - Upsert documents - ✅ Index created with L2 metric (backward compatible) 4. **Query existing collection:** - Connect to existing COSINE collection - Set Metric Type to "COSINE" - ✅ Queries work correctly - ✅ No mismatch errors 5. **Backward compatibility:** - Open existing flow without metricType set - ✅ Defaults to L2 - ✅ Existing flows work without changes ### Edge Cases - ✅ Missing metricType parameter → defaults to L2 - ✅ Invalid metricType string → TypeScript enum conversion handles it - ✅ Existing index with different metric → uses existing index (no recreation) - ✅ New index creation → uses configured metric type ## Impact ### Affected Components - ✅ Milvus vector store node (upsert and query) - ✅ Index creation logic - ✅ Similarity search logic ### Breaking Changes - ❌ None - defaults to L2 for backward compatibility ### Benefits - ✅ Fixes metric type mismatch errors - ✅ Enables COSINE and IP metrics - ✅ Maintains backward compatibility - ✅ Consistent with Milvus best practices - ✅ User-friendly dropdown UI ## Documentation The new parameter includes: - Clear label: "Metric Type" - Helpful description: "Distance metric for similarity search. Default to L2 (Euclidean distance)" - Descriptive option labels: - "L2 (Euclidean Distance)" - "IP (Inner Product)" - "COSINE (Cosine Similarity)" ## Related Issues - Fixes FlowiseAI#6033 - Addresses metric type mismatch errors reported by users - Aligns with Milvus documentation on metric types
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to configure the metric type for Milvus vector stores, adds a 'Select All' functionality to the workspace sharing dialog, and updates the tooltip component to use unordered lists. A suggestion was made to simplify the state logic for the 'Select All' checkbox in the workspace dialog to remove redundant ternary operations.
| if (outputSchema.length > 0) { | ||
| const allSelected = outputSchema.every((row) => row.shared) | ||
| const noneSelected = outputSchema.every((row) => !row.shared) | ||
| setSelectAll(allSelected ? true : noneSelected ? false : false) |
Contributor
There was a problem hiding this comment.
The ternary logic here is redundant. Since allSelected is only true when all rows are shared, and in all other cases (none selected or some selected) the selectAll state should be false, you can simplify this to just setSelectAll(allSelected).
Suggested change
| setSelectAll(allSelected ? true : noneSelected ? false : false) | |
| setSelectAll(allSelected) |
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.
Description
Fixes #6033
Adds a configurable Metric Type parameter to the Milvus vector store node, allowing users to choose between L2, IP, and COSINE distance metrics instead of being locked to L2.
Problem
Current behavior:
MetricType.L2when creating indexesUser report from #6033:
Error Example
Solution
Add a dropdown parameter that lets users select the metric type:
Changes
packages/components/nodes/vectorstores/Milvus/Milvus.ts1. Added Metric Type Input Parameter
2. Read Metric Type in Both Methods
3. Pass to MilvusLibArgs
4. Use in Index Creation
Behavior
Before (Hardcoded L2)
Problems:
After (Configurable)
Benefits:
Use Cases
1. COSINE for Normalized Embeddings
When to use: OpenAI embeddings, Sentence Transformers (normalized)
2. IP for Maximum Inner Product
When to use: Recommendation systems, collaborative filtering
3. L2 for Euclidean Distance (Default)
When to use: General purpose, spatial data
Testing
Manual Testing
Test 1: Create Collection with COSINE
Expected:
Test 2: Create Collection with IP
Expected:
Test 3: Default L2 (Backward Compatibility)
Expected:
Test 4: Query Existing COSINE Collection
Expected:
Edge Cases
Impact
Affected Components
Breaking Changes
Backward Compatibility
Benefits
Screenshots
New Parameter in UI
The Metric Type dropdown appears in Additional Parameters section with three options:
Documentation
The parameter includes helpful descriptions:
Related Issues
Type of Change
Checklist