Flowise icon indicating copy to clipboard operation
Flowise copied to clipboard

[FEATURE]Can you add milvus to project?

Open lhkg1988 opened this issue 1 year ago • 4 comments

Langchainjs support milvus. Can you add milvus to Flowise?

lhkg1988 avatar May 23 '23 07:05 lhkg1988

certainly! work in progress :)

HenryHengZJ avatar May 23 '23 11:05 HenryHengZJ

Is there any new progress?

hujghc avatar Jun 13 '23 07:06 hujghc

This branch feature/Milvus, but problem

lhkg1988 avatar Jun 14 '23 01:06 lhkg1988

I tried working on it on this branch feature/Milvus, but keep getting heap memory issue. Appreciate if anyone can chime in

HenryHengZJ avatar Jun 18 '23 21:06 HenryHengZJ

I tried working on it on this branch feature/Milvus, but keep getting heap memory issue. Appreciate if anyone can chime in

What's the error ?

shanghaikid avatar Jul 10 '23 03:07 shanghaikid

I tried working on it on this branch feature/Milvus, but keep getting heap memory issue. Appreciate if anyone can chime in

Seems like the GRPC client can not be reused after the vector store class initialized , it keeps retrying to connect until hitting the memory limit. Don't know why...

shanghaikid avatar Jul 11 '23 14:07 shanghaikid

I understand the problem, here

        this.app.get('/api/v1/nodes', (req: Request, res: Response) => {
            const returnData = []
            for (const nodeName in this.nodesPool.componentNodes) {
                const clonedNode = cloneDeep(this.nodesPool.componentNodes[nodeName])
                returnData.push(clonedNode)
            }
            return res.json(returnData)
        })

You deep clone the node, milvus node sdk uses grpc to communicate with the milvus server, when it is initialized, it builds the GRPC channel to the server, but after you clone the object, the GRPC channel is not allowed to be reused, so later requests can not be finished, and the grpc node package will retry to connect, again and again, then we hit the memory limit.

Is there a way that we can avoid this cloneDeep?

shanghaikid avatar Jul 13 '23 01:07 shanghaikid

@HenryHengZJ

shanghaikid avatar Jul 13 '23 01:07 shanghaikid

// in processPrediction
 const nodeToExecute = reactFlowNodes.find((node: IReactFlowNode) => node.id === endingNodeId)
                    if (!nodeToExecute) return res.status(404).send(`Node ${endingNodeId} not found`)

                    const reactFlowNodeData: INodeData = resolveVariables(nodeToExecute.data, reactFlowNodes, incomingInput.question)
                    nodeToExecuteData = reactFlowNodeData

                    const startingNodes = nodes.filter((nd) => startingNodeIds.includes(nd.id))
                    this.chatflowPool.add(chatflowid, nodeToExecuteData, startingNodes, incomingInput?.overrideConfig)


export const resolveVariables = (reactFlowNodeData: INodeData, reactFlowNodes: IReactFlowNode[], question: string): INodeData => {
    let flowNodeData = cloneDeep(reactFlowNodeData)
    if (reactFlowNodeData.instance && isVectorStoreFaiss(reactFlowNodeData)) {
        // omit and merge because cloneDeep of instance gives "Illegal invocation" Exception
        const flowNodeDataWithoutInstance = cloneDeep(omit(reactFlowNodeData, ['instance']))
        flowNodeData = merge(flowNodeDataWithoutInstance, { instance: reactFlowNodeData.instance })
    }
    const types = 'inputs'

    const getParamValues = (paramsObj: ICommonObject) => {
        for (const key in paramsObj) {
            const paramValue: string = paramsObj[key]
            if (Array.isArray(paramValue)) {
                const resolvedInstances = []
                for (const param of paramValue) {
                    const resolvedInstance = getVariableValue(param, reactFlowNodes, question)
                    resolvedInstances.push(resolvedInstance)
                }
                paramsObj[key] = resolvedInstances
            } else {
                const isAcceptVariable = reactFlowNodeData.inputParams.find((param) => param.name === key)?.acceptVariable ?? false
                const resolvedInstance = getVariableValue(paramValue, reactFlowNodes, question, isAcceptVariable)
                paramsObj[key] = resolvedInstance
            }
        }
    }

    const paramsObj = flowNodeData[types] ?? {}

    getParamValues(paramsObj)

    return flowNodeData
}

looks like here

shanghaikid avatar Jul 13 '23 02:07 shanghaikid

Milvus is now supported on Flowise! Closing as #794 merged

HenryHengZJ avatar Aug 24 '23 00:08 HenryHengZJ