diff --git a/packages/components/nodes/vectorstores/Milvus/Milvus.ts b/packages/components/nodes/vectorstores/Milvus/Milvus.ts index 527d57bf5d2..fe5475ab778 100644 --- a/packages/components/nodes/vectorstores/Milvus/Milvus.ts +++ b/packages/components/nodes/vectorstores/Milvus/Milvus.ts @@ -112,6 +112,29 @@ class Milvus_VectorStores implements INode { additionalParams: true, optional: true }, + { + label: 'Metric Type', + name: 'metricType', + description: 'Distance metric for similarity search. Default to L2 (Euclidean distance)', + type: 'options', + options: [ + { + label: 'L2 (Euclidean Distance)', + name: 'L2' + }, + { + label: 'IP (Inner Product)', + name: 'IP' + }, + { + label: 'COSINE (Cosine Similarity)', + name: 'COSINE' + } + ], + default: 'L2', + additionalParams: true, + optional: true + }, { label: 'Secure', name: 'secure', @@ -194,6 +217,9 @@ class Milvus_VectorStores implements INode { // partition const partitionName = nodeData.inputs?.milvusPartition ?? '_default' + // metric type + const metricType = (nodeData.inputs?.metricType as string) ?? 'L2' + // init MilvusLibArgs const milVusArgs: MilvusLibArgs = { url: address, @@ -217,6 +243,11 @@ class Milvus_VectorStores implements INode { if (milvusUser) milVusArgs.username = milvusUser if (milvusPassword) milVusArgs.password = milvusPassword + // Set metric type for index creation + milVusArgs.indexCreateParams = { + metric_type: MetricType[metricType as keyof typeof MetricType] + } + const flattenDocs = docs && docs.length ? flatten(docs) : [] const finalDocs = [] for (let i = 0; i < flattenDocs.length; i += 1) { @@ -276,6 +307,9 @@ class Milvus_VectorStores implements INode { // partition const partitionName = nodeData.inputs?.milvusPartition ?? '_default' + // metric type + const metricType = (nodeData.inputs?.metricType as string) ?? 'L2' + // init MilvusLibArgs const milVusArgs: MilvusLibArgs = { url: address, @@ -300,6 +334,11 @@ class Milvus_VectorStores implements INode { if (milvusUser) milVusArgs.username = milvusUser if (milvusPassword) milVusArgs.password = milvusPassword + // Set metric type for index creation + milVusArgs.indexCreateParams = { + metric_type: MetricType[metricType as keyof typeof MetricType] + } + let milvusFilter = _milvusFilter if (isFileUploadEnabled && options.chatId) { if (milvusFilter) milvusFilter += ` OR ${FLOWISE_CHATID} == "${options.chatId}" OR NOT EXISTS(${FLOWISE_CHATID})` @@ -471,7 +510,7 @@ class MilvusUpsert extends Milvus { field_name: this.vectorField, index_name: `myindex_${Date.now().toString()}`, index_type: IndexType.AUTOINDEX, - metric_type: MetricType.L2 + metric_type: this.indexCreateParams?.metric_type || MetricType.L2 }) if (resp.error_code !== ErrorCode.SUCCESS) { throw new Error(`Error creating index`) diff --git a/packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx b/packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx index f9ba47e73fd..67fa1e57920 100644 --- a/packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx +++ b/packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx @@ -6,7 +6,7 @@ import { enqueueSnackbar as enqueueSnackbarAction, closeSnackbar as closeSnackba import { cloneDeep } from 'lodash' // Material -import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Box, Stack, OutlinedInput, Typography } from '@mui/material' +import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Box, Stack, OutlinedInput, Typography, Checkbox, FormControlLabel } from '@mui/material' // Project imports import { StyledButton } from '@/ui-component/button/StyledButton' @@ -47,6 +47,28 @@ const ShareWithWorkspaceDialog = ({ show, dialogProps, onCancel, setError }) => const [outputSchema, setOutputSchema] = useState([]) const [name, setName] = useState('') + const [selectAll, setSelectAll] = useState(false) + + // Handle select all / deselect all + const handleSelectAllChange = (event) => { + const checked = event.target.checked + setSelectAll(checked) + setOutputSchema((prevRows) => { + return prevRows.map((row) => ({ + ...row, + shared: checked + })) + }) + } + + // Update selectAll state when individual rows change + useEffect(() => { + if (outputSchema.length > 0) { + const allSelected = outputSchema.every((row) => row.shared) + const noneSelected = outputSchema.every((row) => !row.shared) + setSelectAll(allSelected ? true : noneSelected ? false : false) + } + }, [outputSchema]) const onRowUpdate = (newRow) => { setTimeout(() => { @@ -187,6 +209,13 @@ const ShareWithWorkspaceDialog = ({ show, dialogProps, onCancel, setError }) => + + Workspaces + } + label={Select All} + /> + diff --git a/packages/ui/src/ui-component/tooltip/MoreItemsTooltip.jsx b/packages/ui/src/ui-component/tooltip/MoreItemsTooltip.jsx index 260240453f3..c10a710c505 100644 --- a/packages/ui/src/ui-component/tooltip/MoreItemsTooltip.jsx +++ b/packages/ui/src/ui-component/tooltip/MoreItemsTooltip.jsx @@ -2,7 +2,7 @@ import { Tooltip, Typography } from '@mui/material' import { styled } from '@mui/material/styles' import PropTypes from 'prop-types' -const StyledOl = styled('ol')(() => ({ +const StyledUl = styled('ul')(() => ({ paddingLeft: 20, margin: 0 })) @@ -17,13 +17,13 @@ const MoreItemsTooltip = ({ images, children }) => { return ( + {images.map((img) => ( {img.label} ))} - + } placement='top' >