mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 03:01:10 +03:00
remove redundant imports and move some options to additional
This commit is contained in:
+23
-20
@@ -1,10 +1,7 @@
|
|||||||
import { INode, INodeData, INodeOutputsValue, INodeParams, INodeOptionsValue } from '../../../src/Interface'
|
import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||||
import { Embeddings } from 'langchain/embeddings/base'
|
import { Embeddings } from 'langchain/embeddings/base'
|
||||||
import { Document } from 'langchain/document'
|
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { ConnectionOptions, SingleStoreVectorStore, SingleStoreVectorStoreConfig } from 'langchain/vectorstores/singlestore'
|
import { SingleStoreVectorStore, SingleStoreVectorStoreConfig } from 'langchain/vectorstores/singlestore'
|
||||||
import { flatten } from 'lodash'
|
|
||||||
import { integer } from '@opensearch-project/opensearch/api/types'
|
|
||||||
|
|
||||||
class SingleStoreExisting_VectorStores implements INode {
|
class SingleStoreExisting_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
@@ -36,11 +33,6 @@ class SingleStoreExisting_VectorStores implements INode {
|
|||||||
name: 'host',
|
name: 'host',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'Port',
|
|
||||||
name: 'port',
|
|
||||||
type: 'string'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'User',
|
label: 'User',
|
||||||
name: 'user',
|
name: 'user',
|
||||||
@@ -59,27 +51,38 @@ class SingleStoreExisting_VectorStores implements INode {
|
|||||||
{
|
{
|
||||||
label: 'Table Name',
|
label: 'Table Name',
|
||||||
name: 'tableName',
|
name: 'tableName',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
placeholder: 'embeddings',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Content Column Name',
|
label: 'Content Column Name',
|
||||||
name: 'contentColumnName',
|
name: 'contentColumnName',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
placeholder: 'content',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Vector Column Name',
|
label: 'Vector Column Name',
|
||||||
name: 'vectorColumnName',
|
name: 'vectorColumnName',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
placeholder: 'vector',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Metadata Column Name',
|
label: 'Metadata Column Name',
|
||||||
name: 'metadataColumnName',
|
name: 'metadataColumnName',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
placeholder: 'metadata',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Top K',
|
label: 'Top K',
|
||||||
name: 'topK',
|
name: 'topK',
|
||||||
description: 'Number of top results to fetch. Default to 4',
|
|
||||||
placeholder: '4',
|
placeholder: '4',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
additionalParams: true,
|
additionalParams: true,
|
||||||
@@ -104,15 +107,15 @@ class SingleStoreExisting_VectorStores implements INode {
|
|||||||
const singleStoreConnectionConfig = {
|
const singleStoreConnectionConfig = {
|
||||||
connectionOptions: {
|
connectionOptions: {
|
||||||
host: nodeData.inputs?.host as string,
|
host: nodeData.inputs?.host as string,
|
||||||
port: nodeData.inputs?.port as integer,
|
port: 3306,
|
||||||
user: nodeData.inputs?.user as string,
|
user: nodeData.inputs?.user as string,
|
||||||
password: nodeData.inputs?.password as string,
|
password: nodeData.inputs?.password as string,
|
||||||
database: nodeData.inputs?.database as string
|
database: nodeData.inputs?.database as string
|
||||||
},
|
},
|
||||||
tableName: nodeData.inputs?.tableName as string,
|
...(nodeData.inputs?.tableName ? { tableName: nodeData.inputs.tableName as string } : {}),
|
||||||
contentColumnName: nodeData.inputs?.contentColumnName as string,
|
...(nodeData.inputs?.contentColumnName ? { contentColumnName: nodeData.inputs.contentColumnName as string } : {}),
|
||||||
vectorColumnName: nodeData.inputs?.vectorColumnName as string,
|
...(nodeData.inputs?.vectorColumnName ? { vectorColumnName: nodeData.inputs.vectorColumnName as string } : {}),
|
||||||
metadataColumnName: nodeData.inputs?.metadataColumnName as string
|
...(nodeData.inputs?.metadataColumnName ? { metadataColumnName: nodeData.inputs.metadataColumnName as string } : {})
|
||||||
} as SingleStoreVectorStoreConfig
|
} as SingleStoreVectorStoreConfig
|
||||||
|
|
||||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ import { INode, INodeData, INodeOutputsValue, INodeParams, INodeOptionsValue } f
|
|||||||
import { Embeddings } from 'langchain/embeddings/base'
|
import { Embeddings } from 'langchain/embeddings/base'
|
||||||
import { Document } from 'langchain/document'
|
import { Document } from 'langchain/document'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { ConnectionOptions, SingleStoreVectorStore, SingleStoreVectorStoreConfig } from 'langchain/vectorstores/singlestore'
|
import { SingleStoreVectorStore, SingleStoreVectorStoreConfig } from 'langchain/vectorstores/singlestore'
|
||||||
import { flatten } from 'lodash'
|
import { flatten } from 'lodash'
|
||||||
import { integer } from '@opensearch-project/opensearch/api/types'
|
|
||||||
import { MemoryVectorStore } from 'langchain/vectorstores/memory'
|
import { MemoryVectorStore } from 'langchain/vectorstores/memory'
|
||||||
|
|
||||||
class SingleStoreUpsert_VectorStores implements INode {
|
class SingleStoreUpsert_VectorStores implements INode {
|
||||||
@@ -43,11 +42,6 @@ class SingleStoreUpsert_VectorStores implements INode {
|
|||||||
name: 'host',
|
name: 'host',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'Port',
|
|
||||||
name: 'port',
|
|
||||||
type: 'string'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'User',
|
label: 'User',
|
||||||
name: 'user',
|
name: 'user',
|
||||||
@@ -66,27 +60,38 @@ class SingleStoreUpsert_VectorStores implements INode {
|
|||||||
{
|
{
|
||||||
label: 'Table Name',
|
label: 'Table Name',
|
||||||
name: 'tableName',
|
name: 'tableName',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
placeholder: 'embeddings',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Content Column Name',
|
label: 'Content Column Name',
|
||||||
name: 'contentColumnName',
|
name: 'contentColumnName',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
placeholder: 'content',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Vector Column Name',
|
label: 'Vector Column Name',
|
||||||
name: 'vectorColumnName',
|
name: 'vectorColumnName',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
placeholder: 'vector',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Metadata Column Name',
|
label: 'Metadata Column Name',
|
||||||
name: 'metadataColumnName',
|
name: 'metadataColumnName',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
placeholder: 'metadata',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Top K',
|
label: 'Top K',
|
||||||
name: 'topK',
|
name: 'topK',
|
||||||
description: 'Number of top results to fetch. Default to 4',
|
|
||||||
placeholder: '4',
|
placeholder: '4',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
additionalParams: true,
|
additionalParams: true,
|
||||||
@@ -111,15 +116,15 @@ class SingleStoreUpsert_VectorStores implements INode {
|
|||||||
const singleStoreConnectionConfig = {
|
const singleStoreConnectionConfig = {
|
||||||
connectionOptions: {
|
connectionOptions: {
|
||||||
host: nodeData.inputs?.host as string,
|
host: nodeData.inputs?.host as string,
|
||||||
port: nodeData.inputs?.port as integer,
|
port: 3306,
|
||||||
user: nodeData.inputs?.user as string,
|
user: nodeData.inputs?.user as string,
|
||||||
password: nodeData.inputs?.password as string,
|
password: nodeData.inputs?.password as string,
|
||||||
database: nodeData.inputs?.database as string
|
database: nodeData.inputs?.database as string
|
||||||
},
|
},
|
||||||
tableName: nodeData.inputs?.tableName as string,
|
...(nodeData.inputs?.tableName ? { tableName: nodeData.inputs.tableName as string } : {}),
|
||||||
contentColumnName: nodeData.inputs?.contentColumnName as string,
|
...(nodeData.inputs?.contentColumnName ? { contentColumnName: nodeData.inputs.contentColumnName as string } : {}),
|
||||||
vectorColumnName: nodeData.inputs?.vectorColumnName as string,
|
...(nodeData.inputs?.vectorColumnName ? { vectorColumnName: nodeData.inputs.vectorColumnName as string } : {}),
|
||||||
metadataColumnName: nodeData.inputs?.metadataColumnName as string
|
...(nodeData.inputs?.metadataColumnName ? { metadataColumnName: nodeData.inputs.metadataColumnName as string } : {})
|
||||||
} as SingleStoreVectorStoreConfig
|
} as SingleStoreVectorStoreConfig
|
||||||
|
|
||||||
const docs = nodeData.inputs?.document as Document[]
|
const docs = nodeData.inputs?.document as Document[]
|
||||||
@@ -134,12 +139,11 @@ class SingleStoreUpsert_VectorStores implements INode {
|
|||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
let vectorStore: SingleStoreVectorStore | MemoryVectorStore
|
let vectorStore: SingleStoreVectorStore
|
||||||
|
|
||||||
vectorStore = new SingleStoreVectorStore(embeddings, singleStoreConnectionConfig)
|
vectorStore = new SingleStoreVectorStore(embeddings, singleStoreConnectionConfig)
|
||||||
vectorStore.addDocuments.bind(vectorStore)(finalDocs)
|
vectorStore.addDocuments.bind(vectorStore)(finalDocs)
|
||||||
|
|
||||||
|
|
||||||
if (output === 'retriever') {
|
if (output === 'retriever') {
|
||||||
const retriever = vectorStore.asRetriever(k)
|
const retriever = vectorStore.asRetriever(k)
|
||||||
return retriever
|
return retriever
|
||||||
|
|||||||
Reference in New Issue
Block a user