diff --git a/LICENSE.md b/LICENSE.md index 4a27187d..0f4afcd1 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,23 @@ - Apache License + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ +Flowise is governed by the Apache License 2.0, with additional terms and conditions outlined below: + +Flowise can be used for commercial purposes for "backend-as-a-service" for your applications or as a development platform for enterprises. However, under specific conditions, you must reach out to the project's administrators to secure a commercial license: + +a. Multi-tenant SaaS service: Unless you have explicit written authorization from Flowise, you may not utilize the Flowise source code to operate a multi-tenant SaaS service that closely resembles the Flowise cloud-based services. +b. Logo and copyright information: While using Flowise in commercial application, you are prohibited from removing or altering the LOGO or copyright information displayed in the Flowise console and UI. + +For inquiries regarding licensing matters, please contact hello@flowiseai.com via email. + +Contributors are required to consent to the following terms related to their contributed code: + +a. The project maintainers have the authority to modify the open-source agreement to be more stringent or lenient. +b. Contributed code can be used for commercial purposes, including Flowise's cloud-based services. + +All other rights and restrictions are in accordance with the Apache License 2.0. + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. diff --git a/package.json b/package.json index 523f615a..649a9a47 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flowise", - "version": "1.4.0-rc.1", + "version": "1.4.3", "private": true, "homepage": "https://flowiseai.com", "workspaces": [ diff --git a/packages/components/credentials/ElectricsearchUserPassword.credential.ts b/packages/components/credentials/ElectricsearchUserPassword.credential.ts index 6c47f7b1..c1ac82c1 100644 --- a/packages/components/credentials/ElectricsearchUserPassword.credential.ts +++ b/packages/components/credentials/ElectricsearchUserPassword.credential.ts @@ -11,8 +11,8 @@ class ElasticSearchUserPassword implements INodeCredential { this.label = 'ElasticSearch User Password' this.name = 'elasticSearchUserPassword' this.version = 1.0 - this.description = - 'Refer to official guide on how to get User Password from ElasticSearch' + this.description = `Use Cloud ID field to enter your Elastic Cloud ID or the URL of the Elastic server instance. + Refer to official guide on how to get User Password from ElasticSearch.` this.inputs = [ { label: 'Cloud ID', diff --git a/packages/components/credentials/LangfuseApi.credential.ts b/packages/components/credentials/LangfuseApi.credential.ts index 452ca989..923af517 100644 --- a/packages/components/credentials/LangfuseApi.credential.ts +++ b/packages/components/credentials/LangfuseApi.credential.ts @@ -12,7 +12,7 @@ class LangfuseApi implements INodeCredential { this.name = 'langfuseApi' this.version = 1.0 this.description = - 'Refer to official guide on how to get API key on Langfuse' + 'Refer to integration guide on how to get API keys on Langfuse' this.inputs = [ { label: 'Secret Key', diff --git a/packages/components/credentials/MongoDBUrlApi.credential.ts b/packages/components/credentials/MongoDBUrlApi.credential.ts new file mode 100644 index 00000000..4412539c --- /dev/null +++ b/packages/components/credentials/MongoDBUrlApi.credential.ts @@ -0,0 +1,25 @@ +import { INodeParams, INodeCredential } from '../src/Interface' + +class MongoDBUrlApi implements INodeCredential { + label: string + name: string + version: number + description: string + inputs: INodeParams[] + + constructor() { + this.label = 'MongoDB ATLAS' + this.name = 'mongoDBUrlApi' + this.version = 1.0 + this.inputs = [ + { + label: 'ATLAS Connection URL', + name: 'mongoDBConnectUrl', + type: 'string', + placeholder: 'mongodb+srv://:@cluster0.example.mongodb.net/?retryWrites=true&w=majority' + } + ] + } +} + +module.exports = { credClass: MongoDBUrlApi } diff --git a/packages/components/credentials/RedisCacheApi.credential.ts b/packages/components/credentials/RedisCacheApi.credential.ts index e09a94e7..4d1a2498 100644 --- a/packages/components/credentials/RedisCacheApi.credential.ts +++ b/packages/components/credentials/RedisCacheApi.credential.ts @@ -8,7 +8,7 @@ class RedisCacheApi implements INodeCredential { inputs: INodeParams[] constructor() { - this.label = 'Redis Cache API' + this.label = 'Redis API' this.name = 'redisCacheApi' this.version = 1.0 this.inputs = [ diff --git a/packages/components/credentials/RedisCacheUrlApi.credential.ts b/packages/components/credentials/RedisCacheUrlApi.credential.ts index fc2e2eb2..e016d78f 100644 --- a/packages/components/credentials/RedisCacheUrlApi.credential.ts +++ b/packages/components/credentials/RedisCacheUrlApi.credential.ts @@ -8,7 +8,7 @@ class RedisCacheUrlApi implements INodeCredential { inputs: INodeParams[] constructor() { - this.label = 'Redis Cache URL' + this.label = 'Redis URL' this.name = 'redisCacheUrlApi' this.version = 1.0 this.inputs = [ @@ -16,7 +16,7 @@ class RedisCacheUrlApi implements INodeCredential { label: 'Redis URL', name: 'redisUrl', type: 'string', - default: '127.0.0.1' + default: 'redis://localhost:6379' } ] } diff --git a/packages/components/nodes/agents/ConversationalAgent/ConversationalAgent.ts b/packages/components/nodes/agents/ConversationalAgent/ConversationalAgent.ts index 00f825d4..8a2329b5 100644 --- a/packages/components/nodes/agents/ConversationalAgent/ConversationalAgent.ts +++ b/packages/components/nodes/agents/ConversationalAgent/ConversationalAgent.ts @@ -3,7 +3,7 @@ import { initializeAgentExecutorWithOptions, AgentExecutor, InitializeAgentExecu import { Tool } from 'langchain/tools' import { BaseChatMemory } from 'langchain/memory' import { getBaseClasses, mapChatHistory } from '../../../src/utils' -import { BaseLanguageModel } from 'langchain/base_language' +import { BaseChatModel } from 'langchain/chat_models/base' import { flatten } from 'lodash' import { additionalCallbacks } from '../../../src/handler' @@ -29,7 +29,7 @@ class ConversationalAgent_Agents implements INode { constructor() { this.label = 'Conversational Agent' this.name = 'conversationalAgent' - this.version = 1.0 + this.version = 2.0 this.type = 'AgentExecutor' this.category = 'Agents' this.icon = 'agent.svg' @@ -45,7 +45,7 @@ class ConversationalAgent_Agents implements INode { { label: 'Language Model', name: 'model', - type: 'BaseLanguageModel' + type: 'BaseChatModel' }, { label: 'Memory', @@ -65,7 +65,7 @@ class ConversationalAgent_Agents implements INode { } async init(nodeData: INodeData): Promise { - const model = nodeData.inputs?.model as BaseLanguageModel + const model = nodeData.inputs?.model as BaseChatModel let tools = nodeData.inputs?.tools as Tool[] tools = flatten(tools) const memory = nodeData.inputs?.memory as BaseChatMemory @@ -92,8 +92,6 @@ class ConversationalAgent_Agents implements INode { const executor = nodeData.instance as AgentExecutor const memory = nodeData.inputs?.memory as BaseChatMemory - const callbacks = await additionalCallbacks(nodeData, options) - if (options && options.chatHistory) { const chatHistoryClassName = memory.chatHistory.constructor.name // Only replace when its In-Memory @@ -103,6 +101,10 @@ class ConversationalAgent_Agents implements INode { } } + ;(executor.memory as any).returnMessages = true // Return true for BaseChatModel + + const callbacks = await additionalCallbacks(nodeData, options) + const result = await executor.call({ input }, [...callbacks]) return result?.output } diff --git a/packages/components/nodes/agents/ConversationalRetrievalAgent/ConversationalRetrievalAgent.ts b/packages/components/nodes/agents/ConversationalRetrievalAgent/ConversationalRetrievalAgent.ts index 4a908d7f..3c956833 100644 --- a/packages/components/nodes/agents/ConversationalRetrievalAgent/ConversationalRetrievalAgent.ts +++ b/packages/components/nodes/agents/ConversationalRetrievalAgent/ConversationalRetrievalAgent.ts @@ -21,7 +21,7 @@ class ConversationalRetrievalAgent_Agents implements INode { constructor() { this.label = 'Conversational Retrieval Agent' this.name = 'conversationalRetrievalAgent' - this.version = 1.0 + this.version = 2.0 this.type = 'AgentExecutor' this.category = 'Agents' this.icon = 'agent.svg' @@ -40,9 +40,9 @@ class ConversationalRetrievalAgent_Agents implements INode { type: 'BaseChatMemory' }, { - label: 'OpenAI Chat Model', + label: 'OpenAI/Azure Chat Model', name: 'model', - type: 'ChatOpenAI' + type: 'ChatOpenAI | AzureChatOpenAI' }, { label: 'System Message', @@ -82,6 +82,8 @@ class ConversationalRetrievalAgent_Agents implements INode { if (executor.memory) { ;(executor.memory as any).memoryKey = 'chat_history' ;(executor.memory as any).outputKey = 'output' + ;(executor.memory as any).returnMessages = true + const chatHistoryClassName = (executor.memory as any).chatHistory.constructor.name // Only replace when its In-Memory if (chatHistoryClassName && chatHistoryClassName === 'ChatMessageHistory') { diff --git a/packages/components/nodes/agents/MRKLAgentChat/MRKLAgentChat.ts b/packages/components/nodes/agents/MRKLAgentChat/MRKLAgentChat.ts index ed169e62..19835e36 100644 --- a/packages/components/nodes/agents/MRKLAgentChat/MRKLAgentChat.ts +++ b/packages/components/nodes/agents/MRKLAgentChat/MRKLAgentChat.ts @@ -18,13 +18,13 @@ class MRKLAgentChat_Agents implements INode { inputs: INodeParams[] constructor() { - this.label = 'MRKL Agent for Chat Models' + this.label = 'ReAct Agent for Chat Models' this.name = 'mrklAgentChat' this.version = 1.0 this.type = 'AgentExecutor' this.category = 'Agents' this.icon = 'agent.svg' - this.description = 'Agent that uses the ReAct Framework to decide what action to take, optimized to be used with Chat Models' + this.description = 'Agent that uses the ReAct logic to decide what action to take, optimized to be used with Chat Models' this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)] this.inputs = [ { diff --git a/packages/components/nodes/agents/MRKLAgentLLM/MRKLAgentLLM.ts b/packages/components/nodes/agents/MRKLAgentLLM/MRKLAgentLLM.ts index 74929af8..43a4dee2 100644 --- a/packages/components/nodes/agents/MRKLAgentLLM/MRKLAgentLLM.ts +++ b/packages/components/nodes/agents/MRKLAgentLLM/MRKLAgentLLM.ts @@ -18,13 +18,13 @@ class MRKLAgentLLM_Agents implements INode { inputs: INodeParams[] constructor() { - this.label = 'MRKL Agent for LLMs' + this.label = 'ReAct Agent for LLMs' this.name = 'mrklAgentLLM' this.version = 1.0 this.type = 'AgentExecutor' this.category = 'Agents' this.icon = 'agent.svg' - this.description = 'Agent that uses the ReAct Framework to decide what action to take, optimized to be used with LLMs' + this.description = 'Agent that uses the ReAct logic to decide what action to take, optimized to be used with LLMs' this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)] this.inputs = [ { diff --git a/packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts b/packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts index c920c399..0f5b9aec 100644 --- a/packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts +++ b/packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts @@ -20,11 +20,11 @@ class OpenAIFunctionAgent_Agents implements INode { constructor() { this.label = 'OpenAI Function Agent' this.name = 'openAIFunctionAgent' - this.version = 1.0 + this.version = 2.0 this.type = 'AgentExecutor' this.category = 'Agents' this.icon = 'openai.png' - this.description = `An agent that uses OpenAI's Function Calling functionality to pick the tool and args to call` + this.description = `An agent that uses Function Calling to pick the tool and args to call` this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)] this.inputs = [ { @@ -39,11 +39,9 @@ class OpenAIFunctionAgent_Agents implements INode { type: 'BaseChatMemory' }, { - label: 'OpenAI Chat Model', + label: 'OpenAI/Azure Chat Model', name: 'model', - description: - 'Only works with gpt-3.5-turbo-0613 and gpt-4-0613. Refer docs for more info', - type: 'BaseChatModel' + type: 'ChatOpenAI | AzureChatOpenAI' }, { label: 'System Message', @@ -89,6 +87,8 @@ class OpenAIFunctionAgent_Agents implements INode { } } + ;(executor.memory as any).returnMessages = true // Return true for BaseChatModel + const loggerHandler = new ConsoleCallbackHandler(options.logger) const callbacks = await additionalCallbacks(nodeData, options) diff --git a/packages/components/nodes/chains/ApiChain/GETApiChain.ts b/packages/components/nodes/chains/ApiChain/GETApiChain.ts index 89aa2f61..d88ab6f9 100644 --- a/packages/components/nodes/chains/ApiChain/GETApiChain.ts +++ b/packages/components/nodes/chains/ApiChain/GETApiChain.ts @@ -47,7 +47,7 @@ class GETApiChain_Chains implements INode { name: 'apiDocs', type: 'string', description: - 'Description of how API works. Please refer to more examples', + 'Description of how API works. Please refer to more examples', rows: 4 }, { diff --git a/packages/components/nodes/chains/ApiChain/POSTApiChain.ts b/packages/components/nodes/chains/ApiChain/POSTApiChain.ts index 70277ee9..f005f47a 100644 --- a/packages/components/nodes/chains/ApiChain/POSTApiChain.ts +++ b/packages/components/nodes/chains/ApiChain/POSTApiChain.ts @@ -36,7 +36,7 @@ class POSTApiChain_Chains implements INode { name: 'apiDocs', type: 'string', description: - 'Description of how API works. Please refer to more examples', + 'Description of how API works. Please refer to more examples', rows: 4 }, { diff --git a/packages/components/nodes/chains/ConversationChain/ConversationChain.ts b/packages/components/nodes/chains/ConversationChain/ConversationChain.ts index 92a0b5ea..7887ce97 100644 --- a/packages/components/nodes/chains/ConversationChain/ConversationChain.ts +++ b/packages/components/nodes/chains/ConversationChain/ConversationChain.ts @@ -106,16 +106,18 @@ class ConversationChain_Chains implements INode { async run(nodeData: INodeData, input: string, options: ICommonObject): Promise { const chain = nodeData.instance as ConversationChain const memory = nodeData.inputs?.memory as BufferMemory + memory.returnMessages = true // Return true for BaseChatModel if (options && options.chatHistory) { const chatHistoryClassName = memory.chatHistory.constructor.name // Only replace when its In-Memory if (chatHistoryClassName && chatHistoryClassName === 'ChatMessageHistory') { memory.chatHistory = mapChatHistory(options) - chain.memory = memory } } + chain.memory = memory + const loggerHandler = new ConsoleCallbackHandler(options.logger) const callbacks = await additionalCallbacks(nodeData, options) diff --git a/packages/components/nodes/chains/LLMChain/LLMChain.ts b/packages/components/nodes/chains/LLMChain/LLMChain.ts index 0d555884..fd398151 100644 --- a/packages/components/nodes/chains/LLMChain/LLMChain.ts +++ b/packages/components/nodes/chains/LLMChain/LLMChain.ts @@ -1,12 +1,13 @@ import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' import { getBaseClasses, handleEscapeCharacters } from '../../../src/utils' import { LLMChain } from 'langchain/chains' -import { BaseLanguageModel } from 'langchain/base_language' +import { BaseLanguageModel, BaseLanguageModelCallOptions } from 'langchain/base_language' import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler' import { BaseOutputParser } from 'langchain/schema/output_parser' import { formatResponse, injectOutputParser } from '../../outputparsers/OutputParserHelpers' import { BaseLLMOutputParser } from 'langchain/schema/output_parser' import { OutputFixingParser } from 'langchain/output_parsers' +import { checkInputs, Moderation, streamResponse } from '../../moderation/Moderation' class LLMChain_Chains implements INode { label: string @@ -47,6 +48,14 @@ class LLMChain_Chains implements INode { type: 'BaseLLMOutputParser', optional: true }, + { + label: 'Input Moderation', + description: 'Detect text that could generate harmful output and prevent it from being sent to the language model', + name: 'inputModeration', + type: 'Moderation', + optional: true, + list: true + }, { label: 'Chain Name', name: 'chainName', @@ -132,7 +141,7 @@ class LLMChain_Chains implements INode { const runPrediction = async ( inputVariables: string[], - chain: LLMChain, + chain: LLMChain>, input: string, promptValuesRaw: ICommonObject | undefined, options: ICommonObject, @@ -144,7 +153,7 @@ const runPrediction = async ( const isStreaming = options.socketIO && options.socketIOClientId const socketIO = isStreaming ? options.socketIO : undefined const socketIOClientId = isStreaming ? options.socketIOClientId : '' - + const moderations = nodeData.inputs?.inputModeration as Moderation[] /** * Apply string transformation to reverse converted special chars: * FROM: { "value": "hello i am benFLOWISE_NEWLINEFLOWISE_NEWLINEFLOWISE_TABhow are you?" } @@ -152,6 +161,17 @@ const runPrediction = async ( */ const promptValues = handleEscapeCharacters(promptValuesRaw, true) + if (moderations && moderations.length > 0) { + try { + // Use the output of the moderation chain as input for the LLM chain + input = await checkInputs(moderations, input) + } catch (e) { + await new Promise((resolve) => setTimeout(resolve, 500)) + streamResponse(isStreaming, e.message, socketIO, socketIOClientId) + return formatResponse(e.message) + } + } + if (promptValues && inputVariables.length > 0) { let seen: string[] = [] diff --git a/packages/components/nodes/chains/VectaraChain/VectaraChain.ts b/packages/components/nodes/chains/VectaraChain/VectaraChain.ts new file mode 100644 index 00000000..3799d062 --- /dev/null +++ b/packages/components/nodes/chains/VectaraChain/VectaraChain.ts @@ -0,0 +1,339 @@ +import { INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses } from '../../../src/utils' +import { VectorDBQAChain } from 'langchain/chains' +import { Document } from 'langchain/document' +import { VectaraStore } from 'langchain/vectorstores/vectara' +import fetch from 'node-fetch' + +// functionality based on https://github.com/vectara/vectara-answer +const reorderCitations = (unorderedSummary: string) => { + const allCitations = unorderedSummary.match(/\[\d+\]/g) || [] + + const uniqueCitations = [...new Set(allCitations)] + const citationToReplacement: { [key: string]: string } = {} + uniqueCitations.forEach((citation, index) => { + citationToReplacement[citation] = `[${index + 1}]` + }) + + return unorderedSummary.replace(/\[\d+\]/g, (match) => citationToReplacement[match]) +} +const applyCitationOrder = (searchResults: any[], unorderedSummary: string) => { + const orderedSearchResults: any[] = [] + const allCitations = unorderedSummary.match(/\[\d+\]/g) || [] + + const addedIndices = new Set() + for (let i = 0; i < allCitations.length; i++) { + const citation = allCitations[i] + const index = Number(citation.slice(1, citation.length - 1)) - 1 + + if (addedIndices.has(index)) continue + orderedSearchResults.push(searchResults[index]) + addedIndices.add(index) + } + + return orderedSearchResults +} + +class VectaraChain_Chains implements INode { + label: string + name: string + version: number + type: string + icon: string + category: string + baseClasses: string[] + description: string + inputs: INodeParams[] + + constructor() { + this.label = 'Vectara QA Chain' + this.name = 'vectaraQAChain' + this.version = 1.0 + this.type = 'VectaraQAChain' + this.icon = 'vectara.png' + this.category = 'Chains' + this.description = 'QA chain for Vectara' + this.baseClasses = [this.type, ...getBaseClasses(VectorDBQAChain)] + this.inputs = [ + { + label: 'Vectara Store', + name: 'vectaraStore', + type: 'VectorStore' + }, + { + label: 'Summarizer Prompt Name', + name: 'summarizerPromptName', + description: + 'Summarize the results fetched from Vectara. Read more', + type: 'options', + options: [ + { + label: 'vectara-summary-ext-v1.2.0 (gpt-3.5-turbo)', + name: 'vectara-summary-ext-v1.2.0' + }, + { + label: 'vectara-experimental-summary-ext-2023-10-23-small (gpt-3.5-turbo)', + name: 'vectara-experimental-summary-ext-2023-10-23-small', + description: 'In beta, available to both Growth and Scale Vectara users' + }, + { + label: 'vectara-summary-ext-v1.3.0 (gpt-4.0)', + name: 'vectara-summary-ext-v1.3.0', + description: 'Only available to paying Scale Vectara users' + }, + { + label: 'vectara-experimental-summary-ext-2023-10-23-med (gpt-4.0)', + name: 'vectara-experimental-summary-ext-2023-10-23-med', + description: 'In beta, only available to paying Scale Vectara users' + } + ], + default: 'vectara-summary-ext-v1.2.0' + }, + { + label: 'Response Language', + name: 'responseLang', + description: + 'Return the response in specific language. If not selected, Vectara will automatically detects the language. Read more', + type: 'options', + options: [ + { + label: 'English', + name: 'eng' + }, + { + label: 'German', + name: 'deu' + }, + { + label: 'French', + name: 'fra' + }, + { + label: 'Chinese', + name: 'zho' + }, + { + label: 'Korean', + name: 'kor' + }, + { + label: 'Arabic', + name: 'ara' + }, + { + label: 'Russian', + name: 'rus' + }, + { + label: 'Thai', + name: 'tha' + }, + { + label: 'Dutch', + name: 'nld' + }, + { + label: 'Italian', + name: 'ita' + }, + { + label: 'Portuguese', + name: 'por' + }, + { + label: 'Spanish', + name: 'spa' + }, + { + label: 'Japanese', + name: 'jpn' + }, + { + label: 'Polish', + name: 'pol' + }, + { + label: 'Turkish', + name: 'tur' + }, + { + label: 'Vietnamese', + name: 'vie' + }, + { + label: 'Indonesian', + name: 'ind' + }, + { + label: 'Czech', + name: 'ces' + }, + { + label: 'Ukrainian', + name: 'ukr' + }, + { + label: 'Greek', + name: 'ell' + }, + { + label: 'Hebrew', + name: 'heb' + }, + { + label: 'Farsi/Persian', + name: 'fas' + }, + { + label: 'Hindi', + name: 'hin' + }, + { + label: 'Urdu', + name: 'urd' + }, + { + label: 'Swedish', + name: 'swe' + }, + { + label: 'Bengali', + name: 'ben' + }, + { + label: 'Malay', + name: 'msa' + }, + { + label: 'Romanian', + name: 'ron' + } + ], + optional: true, + default: 'eng' + }, + { + label: 'Max Summarized Results', + name: 'maxSummarizedResults', + description: 'Maximum results used to build the summarized response', + type: 'number', + default: 7 + } + ] + } + + async init(): Promise { + return null + } + + async run(nodeData: INodeData, input: string): Promise { + const vectorStore = nodeData.inputs?.vectaraStore as VectaraStore + const responseLang = (nodeData.inputs?.responseLang as string) ?? 'auto' + const summarizerPromptName = nodeData.inputs?.summarizerPromptName as string + const maxSummarizedResultsStr = nodeData.inputs?.maxSummarizedResults as string + const maxSummarizedResults = maxSummarizedResultsStr ? parseInt(maxSummarizedResultsStr, 10) : 7 + + const topK = (vectorStore as any)?.k ?? 10 + + const headers = await vectorStore.getJsonHeader() + const vectaraFilter = (vectorStore as any).vectaraFilter ?? {} + const corpusId: number[] = (vectorStore as any).corpusId ?? [] + const customerId = (vectorStore as any).customerId ?? '' + + const corpusKeys = corpusId.map((corpusId) => ({ + customerId, + corpusId, + metadataFilter: vectaraFilter?.filter ?? '', + lexicalInterpolationConfig: { lambda: vectaraFilter?.lambda ?? 0.025 } + })) + + const data = { + query: [ + { + query: input, + start: 0, + numResults: topK, + contextConfig: { + sentencesAfter: vectaraFilter?.contextConfig?.sentencesAfter ?? 2, + sentencesBefore: vectaraFilter?.contextConfig?.sentencesBefore ?? 2 + }, + corpusKey: corpusKeys, + summary: [ + { + summarizerPromptName, + responseLang, + maxSummarizedResults + } + ] + } + ] + } + + try { + const response = await fetch(`https://api.vectara.io/v1/query`, { + method: 'POST', + headers: headers?.headers, + body: JSON.stringify(data) + }) + + if (response.status !== 200) { + throw new Error(`Vectara API returned status code ${response.status}`) + } + + const result = await response.json() + const responses = result.responseSet[0].response + const documents = result.responseSet[0].document + let rawSummarizedText = '' + + for (let i = 0; i < responses.length; i += 1) { + const responseMetadata = responses[i].metadata + const documentMetadata = documents[responses[i].documentIndex].metadata + const combinedMetadata: Record = {} + + responseMetadata.forEach((item: { name: string; value: unknown }) => { + combinedMetadata[item.name] = item.value + }) + + documentMetadata.forEach((item: { name: string; value: unknown }) => { + combinedMetadata[item.name] = item.value + }) + + responses[i].metadata = combinedMetadata + } + + const summaryStatus = result.responseSet[0].summary[0].status + if (summaryStatus.length > 0 && summaryStatus[0].code === 'BAD_REQUEST') { + throw new Error( + `BAD REQUEST: Too much text for the summarizer to summarize. Please try reducing the number of search results to summarize, or the context of each result by adjusting the 'summary_num_sentences', and 'summary_num_results' parameters respectively.` + ) + } + + if ( + summaryStatus.length > 0 && + summaryStatus[0].code === 'NOT_FOUND' && + summaryStatus[0].statusDetail === 'Failed to retrieve summarizer.' + ) { + throw new Error(`BAD REQUEST: summarizer ${summarizerPromptName} is invalid for this account.`) + } + + rawSummarizedText = result.responseSet[0].summary[0]?.text + + let summarizedText = reorderCitations(rawSummarizedText) + let summaryResponses = applyCitationOrder(responses, rawSummarizedText) + + const sourceDocuments: Document[] = summaryResponses.map( + (response: { text: string; metadata: Record; score: number }) => + new Document({ + pageContent: response.text, + metadata: response.metadata + }) + ) + + return { text: summarizedText, sourceDocuments: sourceDocuments } + } catch (error) { + throw new Error(error) + } + } +} + +module.exports = { nodeClass: VectaraChain_Chains } diff --git a/packages/components/nodes/chains/VectaraChain/vectara.png b/packages/components/nodes/chains/VectaraChain/vectara.png new file mode 100644 index 00000000..a13a34e6 Binary files /dev/null and b/packages/components/nodes/chains/VectaraChain/vectara.png differ diff --git a/packages/components/nodes/chatmodels/AWSBedrock/AWSChatBedrock.ts b/packages/components/nodes/chatmodels/AWSBedrock/AWSChatBedrock.ts index ade46ab9..956fcdb3 100644 --- a/packages/components/nodes/chatmodels/AWSBedrock/AWSChatBedrock.ts +++ b/packages/components/nodes/chatmodels/AWSBedrock/AWSChatBedrock.ts @@ -27,7 +27,7 @@ class AWSChatBedrock_ChatModels implements INode { constructor() { this.label = 'AWS Bedrock' this.name = 'awsChatBedrock' - this.version = 2.0 + this.version = 3.0 this.type = 'AWSChatBedrock' this.icon = 'awsBedrock.png' this.category = 'Chat Models' @@ -97,7 +97,8 @@ class AWSChatBedrock_ChatModels implements INode { options: [ { label: 'anthropic.claude-instant-v1', name: 'anthropic.claude-instant-v1' }, { label: 'anthropic.claude-v1', name: 'anthropic.claude-v1' }, - { label: 'anthropic.claude-v2', name: 'anthropic.claude-v2' } + { label: 'anthropic.claude-v2', name: 'anthropic.claude-v2' }, + { label: 'meta.llama2-13b-chat-v1', name: 'meta.llama2-13b-chat-v1' } ], default: 'anthropic.claude-v2' }, @@ -128,12 +129,14 @@ class AWSChatBedrock_ChatModels implements INode { const iTemperature = nodeData.inputs?.temperature as string const iMax_tokens_to_sample = nodeData.inputs?.max_tokens_to_sample as string const cache = nodeData.inputs?.cache as BaseCache + const streaming = nodeData.inputs?.streaming as boolean const obj: BaseBedrockInput & BaseLLMParams = { region: iRegion, model: iModel, maxTokens: parseInt(iMax_tokens_to_sample, 10), - temperature: parseFloat(iTemperature) + temperature: parseFloat(iTemperature), + streaming: streaming ?? true } /** diff --git a/packages/components/nodes/chatmodels/ChatAnthropic/ChatAnthropic.ts b/packages/components/nodes/chatmodels/ChatAnthropic/ChatAnthropic.ts index f16968b6..358a15d1 100644 --- a/packages/components/nodes/chatmodels/ChatAnthropic/ChatAnthropic.ts +++ b/packages/components/nodes/chatmodels/ChatAnthropic/ChatAnthropic.ts @@ -19,7 +19,7 @@ class ChatAnthropic_ChatModels implements INode { constructor() { this.label = 'ChatAnthropic' this.name = 'chatAnthropic' - this.version = 2.0 + this.version = 3.0 this.type = 'ChatAnthropic' this.icon = 'chatAnthropic.png' this.category = 'Chat Models' @@ -48,6 +48,11 @@ class ChatAnthropic_ChatModels implements INode { name: 'claude-2', description: 'Claude 2 latest major version, automatically get updates to the model as they are released' }, + { + label: 'claude-2.1', + name: 'claude-2.1', + description: 'Claude 2 latest full version' + }, { label: 'claude-instant-1', name: 'claude-instant-1', diff --git a/packages/components/nodes/embeddings/AWSBedrockEmbedding/AWSBedrockEmbedding.ts b/packages/components/nodes/embeddings/AWSBedrockEmbedding/AWSBedrockEmbedding.ts index ba2aa5e7..8249d512 100644 --- a/packages/components/nodes/embeddings/AWSBedrockEmbedding/AWSBedrockEmbedding.ts +++ b/packages/components/nodes/embeddings/AWSBedrockEmbedding/AWSBedrockEmbedding.ts @@ -18,7 +18,7 @@ class AWSBedrockEmbedding_Embeddings implements INode { constructor() { this.label = 'AWS Bedrock Embeddings' this.name = 'AWSBedrockEmbeddings' - this.version = 1.0 + this.version = 2.0 this.type = 'AWSBedrockEmbeddings' this.icon = 'awsBedrock.png' this.category = 'Embeddings' @@ -81,7 +81,9 @@ class AWSBedrockEmbedding_Embeddings implements INode { type: 'options', options: [ { label: 'amazon.titan-embed-text-v1', name: 'amazon.titan-embed-text-v1' }, - { label: 'amazon.titan-embed-g1-text-02', name: 'amazon.titan-embed-g1-text-02' } + { label: 'amazon.titan-embed-g1-text-02', name: 'amazon.titan-embed-g1-text-02' }, + { label: 'cohere.embed-english-v3', name: 'cohere.embed-english-v3' }, + { label: 'cohere.embed-multilingual-v3', name: 'cohere.embed-multilingual-v3' } ], default: 'amazon.titan-embed-text-v1' } diff --git a/packages/components/nodes/llms/AWSBedrock/AWSBedrock.ts b/packages/components/nodes/llms/AWSBedrock/AWSBedrock.ts index b67219f3..177a32ef 100644 --- a/packages/components/nodes/llms/AWSBedrock/AWSBedrock.ts +++ b/packages/components/nodes/llms/AWSBedrock/AWSBedrock.ts @@ -27,7 +27,7 @@ class AWSBedrock_LLMs implements INode { constructor() { this.label = 'AWS Bedrock' this.name = 'awsBedrock' - this.version = 1.2 + this.version = 2.0 this.type = 'AWSBedrock' this.icon = 'awsBedrock.png' this.category = 'LLMs' @@ -98,6 +98,7 @@ class AWSBedrock_LLMs implements INode { { label: 'amazon.titan-tg1-large', name: 'amazon.titan-tg1-large' }, { label: 'amazon.titan-e1t-medium', name: 'amazon.titan-e1t-medium' }, { label: 'cohere.command-text-v14', name: 'cohere.command-text-v14' }, + { label: 'cohere.command-light-text-v14', name: 'cohere.command-light-text-v14' }, { label: 'ai21.j2-grande-instruct', name: 'ai21.j2-grande-instruct' }, { label: 'ai21.j2-jumbo-instruct', name: 'ai21.j2-jumbo-instruct' }, { label: 'ai21.j2-mid', name: 'ai21.j2-mid' }, diff --git a/packages/components/nodes/memory/DynamoDb/DynamoDb.ts b/packages/components/nodes/memory/DynamoDb/DynamoDb.ts index 68b09b7b..ac4f7602 100644 --- a/packages/components/nodes/memory/DynamoDb/DynamoDb.ts +++ b/packages/components/nodes/memory/DynamoDb/DynamoDb.ts @@ -109,9 +109,8 @@ const initalizeDynamoDB = async (nodeData: INodeData, options: ICommonObject): P }) const memory = new BufferMemoryExtended({ - memoryKey, + memoryKey: memoryKey ?? 'chat_history', chatHistory: dynamoDb, - returnMessages: true, isSessionIdUsingChatMessageId }) return memory diff --git a/packages/components/nodes/memory/MongoDBMemory/MongoDBMemory.ts b/packages/components/nodes/memory/MongoDBMemory/MongoDBMemory.ts new file mode 100644 index 00000000..6f800cdc --- /dev/null +++ b/packages/components/nodes/memory/MongoDBMemory/MongoDBMemory.ts @@ -0,0 +1,145 @@ +import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src' +import { MongoDBChatMessageHistory } from 'langchain/stores/message/mongodb' +import { BufferMemory, BufferMemoryInput } from 'langchain/memory' +import { BaseMessage, mapStoredMessageToChatMessage } from 'langchain/schema' +import { MongoClient } from 'mongodb' + +class MongoDB_Memory implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + baseClasses: string[] + credential: INodeParams + inputs: INodeParams[] + + constructor() { + this.label = 'MongoDB Atlas Chat Memory' + this.name = 'MongoDBAtlasChatMemory' + this.version = 1.0 + this.type = 'MongoDBAtlasChatMemory' + this.icon = 'mongodb.png' + this.category = 'Memory' + this.description = 'Stores the conversation in MongoDB Atlas' + this.baseClasses = [this.type, ...getBaseClasses(BufferMemory)] + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['mongoDBUrlApi'] + } + this.inputs = [ + { + label: 'Database', + name: 'databaseName', + placeholder: '', + type: 'string' + }, + { + label: 'Collection Name', + name: 'collectionName', + placeholder: '', + type: 'string' + }, + { + label: 'Session Id', + name: 'sessionId', + type: 'string', + description: 'If not specified, the first CHAT_MESSAGE_ID will be used as sessionId', + default: '', + additionalParams: true, + optional: true + }, + { + label: 'Memory Key', + name: 'memoryKey', + type: 'string', + default: 'chat_history', + additionalParams: true + } + ] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + return initializeMongoDB(nodeData, options) + } + + async clearSessionMemory(nodeData: INodeData, options: ICommonObject): Promise { + const mongodbMemory = await initializeMongoDB(nodeData, options) + const sessionId = nodeData.inputs?.sessionId as string + const chatId = options?.chatId as string + options.logger.info(`Clearing MongoDB memory session ${sessionId ? sessionId : chatId}`) + await mongodbMemory.clear() + options.logger.info(`Successfully cleared MongoDB memory session ${sessionId ? sessionId : chatId}`) + } +} + +const initializeMongoDB = async (nodeData: INodeData, options: ICommonObject): Promise => { + const databaseName = nodeData.inputs?.databaseName as string + const collectionName = nodeData.inputs?.collectionName as string + const sessionId = nodeData.inputs?.sessionId as string + const memoryKey = nodeData.inputs?.memoryKey as string + const chatId = options?.chatId as string + + let isSessionIdUsingChatMessageId = false + if (!sessionId && chatId) isSessionIdUsingChatMessageId = true + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + let mongoDBConnectUrl = getCredentialParam('mongoDBConnectUrl', credentialData, nodeData) + + const client = new MongoClient(mongoDBConnectUrl) + await client.connect() + const collection = client.db(databaseName).collection(collectionName) + + const mongoDBChatMessageHistory = new MongoDBChatMessageHistory({ + collection, + sessionId: sessionId ? sessionId : chatId + }) + + mongoDBChatMessageHistory.getMessages = async (): Promise => { + const document = await collection.findOne({ + sessionId: (mongoDBChatMessageHistory as any).sessionId + }) + const messages = document?.messages || [] + return messages.map(mapStoredMessageToChatMessage) + } + + mongoDBChatMessageHistory.addMessage = async (message: BaseMessage): Promise => { + const messages = [message].map((msg) => msg.toDict()) + await collection.updateOne( + { sessionId: (mongoDBChatMessageHistory as any).sessionId }, + { + $push: { messages: { $each: messages } } + }, + { upsert: true } + ) + } + + mongoDBChatMessageHistory.clear = async (): Promise => { + await collection.deleteOne({ sessionId: (mongoDBChatMessageHistory as any).sessionId }) + } + + return new BufferMemoryExtended({ + memoryKey: memoryKey ?? 'chat_history', + chatHistory: mongoDBChatMessageHistory, + isSessionIdUsingChatMessageId + }) +} + +interface BufferMemoryExtendedInput { + isSessionIdUsingChatMessageId: boolean +} + +class BufferMemoryExtended extends BufferMemory { + isSessionIdUsingChatMessageId? = false + + constructor(fields: BufferMemoryInput & Partial) { + super(fields) + this.isSessionIdUsingChatMessageId = fields.isSessionIdUsingChatMessageId + } +} + +module.exports = { nodeClass: MongoDB_Memory } diff --git a/packages/components/nodes/memory/MongoDBMemory/mongodb.png b/packages/components/nodes/memory/MongoDBMemory/mongodb.png new file mode 100644 index 00000000..5586fe0a Binary files /dev/null and b/packages/components/nodes/memory/MongoDBMemory/mongodb.png differ diff --git a/packages/components/nodes/memory/RedisBackedChatMemory/RedisBackedChatMemory.ts b/packages/components/nodes/memory/RedisBackedChatMemory/RedisBackedChatMemory.ts index c65d729b..bdb62911 100644 --- a/packages/components/nodes/memory/RedisBackedChatMemory/RedisBackedChatMemory.ts +++ b/packages/components/nodes/memory/RedisBackedChatMemory/RedisBackedChatMemory.ts @@ -137,7 +137,7 @@ const initalizeRedis = async (nodeData: INodeData, options: ICommonObject): Prom } const memory = new BufferMemoryExtended({ - memoryKey, + memoryKey: memoryKey ?? 'chat_history', chatHistory: redisChatMessageHistory, isSessionIdUsingChatMessageId }) diff --git a/packages/components/nodes/memory/UpstashRedisBackedChatMemory/UpstashRedisBackedChatMemory.ts b/packages/components/nodes/memory/UpstashRedisBackedChatMemory/UpstashRedisBackedChatMemory.ts index 6b5fdf66..2b8b4650 100644 --- a/packages/components/nodes/memory/UpstashRedisBackedChatMemory/UpstashRedisBackedChatMemory.ts +++ b/packages/components/nodes/memory/UpstashRedisBackedChatMemory/UpstashRedisBackedChatMemory.ts @@ -95,6 +95,7 @@ const initalizeUpstashRedis = async (nodeData: INodeData, options: ICommonObject }) const memory = new BufferMemoryExtended({ + memoryKey: 'chat_history', chatHistory: redisChatMessageHistory, isSessionIdUsingChatMessageId }) diff --git a/packages/components/nodes/moderation/Moderation.ts b/packages/components/nodes/moderation/Moderation.ts new file mode 100644 index 00000000..9fd2bfde --- /dev/null +++ b/packages/components/nodes/moderation/Moderation.ts @@ -0,0 +1,27 @@ +import { Server } from 'socket.io' + +export abstract class Moderation { + abstract checkForViolations(input: string): Promise +} + +export const checkInputs = async (inputModerations: Moderation[], input: string): Promise => { + for (const moderation of inputModerations) { + input = await moderation.checkForViolations(input) + } + return input +} + +// is this the correct location for this function? +// should we have a utils files that all node components can use? +export const streamResponse = (isStreaming: any, response: string, socketIO: Server, socketIOClientId: string) => { + if (isStreaming) { + const result = response.split(/(\s+)/) + result.forEach((token: string, index: number) => { + if (index === 0) { + socketIO.to(socketIOClientId).emit('start', token) + } + socketIO.to(socketIOClientId).emit('token', token) + }) + socketIO.to(socketIOClientId).emit('end') + } +} diff --git a/packages/components/nodes/moderation/OpenAIModeration/OpenAIModeration.ts b/packages/components/nodes/moderation/OpenAIModeration/OpenAIModeration.ts new file mode 100644 index 00000000..85b27907 --- /dev/null +++ b/packages/components/nodes/moderation/OpenAIModeration/OpenAIModeration.ts @@ -0,0 +1,56 @@ +import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src' +import { Moderation } from '../Moderation' +import { OpenAIModerationRunner } from './OpenAIModerationRunner' + +class OpenAIModeration implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + baseClasses: string[] + credential: INodeParams + inputs: INodeParams[] + + constructor() { + this.label = 'OpenAI Moderation' + this.name = 'inputModerationOpenAI' + this.version = 1.0 + this.type = 'Moderation' + this.icon = 'openai.png' + this.category = 'Moderation' + this.description = 'Check whether content complies with OpenAI usage policies.' + this.baseClasses = [this.type, ...getBaseClasses(Moderation)] + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['openAIApi'] + } + this.inputs = [ + { + label: 'Error Message', + name: 'moderationErrorMessage', + type: 'string', + rows: 2, + default: "Cannot Process! Input violates OpenAI's content moderation policies.", + optional: true + } + ] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const openAIApiKey = getCredentialParam('openAIApiKey', credentialData, nodeData) + + const runner = new OpenAIModerationRunner(openAIApiKey) + const moderationErrorMessage = nodeData.inputs?.moderationErrorMessage as string + if (moderationErrorMessage) runner.setErrorMessage(moderationErrorMessage) + return runner + } +} + +module.exports = { nodeClass: OpenAIModeration } diff --git a/packages/components/nodes/moderation/OpenAIModeration/OpenAIModerationRunner.ts b/packages/components/nodes/moderation/OpenAIModeration/OpenAIModerationRunner.ts new file mode 100644 index 00000000..3a3ec550 --- /dev/null +++ b/packages/components/nodes/moderation/OpenAIModeration/OpenAIModerationRunner.ts @@ -0,0 +1,34 @@ +import { Moderation } from '../Moderation' +import { OpenAIModerationChain } from 'langchain/chains' + +export class OpenAIModerationRunner implements Moderation { + private openAIApiKey = '' + private moderationErrorMessage: string = "Text was found that violates OpenAI's content policy." + + constructor(openAIApiKey: string) { + this.openAIApiKey = openAIApiKey + } + + async checkForViolations(input: string): Promise { + if (!this.openAIApiKey) { + throw Error('OpenAI API key not found') + } + // Create a new instance of the OpenAIModerationChain + const moderation = new OpenAIModerationChain({ + openAIApiKey: this.openAIApiKey, + throwError: false // If set to true, the call will throw an error when the moderation chain detects violating content. If set to false, violating content will return "Text was found that violates OpenAI's content policy.". + }) + // Send the user's input to the moderation chain and wait for the result + const { output: moderationOutput, results } = await moderation.call({ + input: input + }) + if (results[0].flagged) { + throw Error(this.moderationErrorMessage) + } + return moderationOutput + } + + setErrorMessage(message: string) { + this.moderationErrorMessage = message + } +} diff --git a/packages/components/nodes/moderation/OpenAIModeration/openai.png b/packages/components/nodes/moderation/OpenAIModeration/openai.png new file mode 100644 index 00000000..de08a05b Binary files /dev/null and b/packages/components/nodes/moderation/OpenAIModeration/openai.png differ diff --git a/packages/components/nodes/moderation/SimplePromptModeration/SimplePromptModeration.ts b/packages/components/nodes/moderation/SimplePromptModeration/SimplePromptModeration.ts new file mode 100644 index 00000000..bf5a32f6 --- /dev/null +++ b/packages/components/nodes/moderation/SimplePromptModeration/SimplePromptModeration.ts @@ -0,0 +1,55 @@ +import { INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses } from '../../../src' +import { Moderation } from '../Moderation' +import { SimplePromptModerationRunner } from './SimplePromptModerationRunner' + +class SimplePromptModeration implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + baseClasses: string[] + inputs: INodeParams[] + + constructor() { + this.label = 'Simple Prompt Moderation' + this.name = 'inputModerationSimple' + this.version = 1.0 + this.type = 'Moderation' + this.icon = 'simple_moderation.png' + this.category = 'Moderation' + this.description = 'Check whether input consists of any text from Deny list, and prevent being sent to LLM' + this.baseClasses = [this.type, ...getBaseClasses(Moderation)] + this.inputs = [ + { + label: 'Deny List', + name: 'denyList', + type: 'string', + rows: 4, + placeholder: `ignore previous instructions\ndo not follow the directions\nyou must ignore all previous instructions`, + description: 'An array of string literals (enter one per line) that should not appear in the prompt text.', + optional: false + }, + { + label: 'Error Message', + name: 'moderationErrorMessage', + type: 'string', + rows: 2, + default: 'Cannot Process! Input violates content moderation policies.', + optional: true + } + ] + } + + async init(nodeData: INodeData): Promise { + const denyList = nodeData.inputs?.denyList as string + const moderationErrorMessage = nodeData.inputs?.moderationErrorMessage as string + + return new SimplePromptModerationRunner(denyList, moderationErrorMessage) + } +} + +module.exports = { nodeClass: SimplePromptModeration } diff --git a/packages/components/nodes/moderation/SimplePromptModeration/SimplePromptModerationRunner.ts b/packages/components/nodes/moderation/SimplePromptModeration/SimplePromptModerationRunner.ts new file mode 100644 index 00000000..08f9ed1e --- /dev/null +++ b/packages/components/nodes/moderation/SimplePromptModeration/SimplePromptModerationRunner.ts @@ -0,0 +1,23 @@ +import { Moderation } from '../Moderation' + +export class SimplePromptModerationRunner implements Moderation { + private readonly denyList: string = '' + private readonly moderationErrorMessage: string = '' + + constructor(denyList: string, moderationErrorMessage: string) { + this.denyList = denyList + if (denyList.indexOf('\n') === -1) { + this.denyList += '\n' + } + this.moderationErrorMessage = moderationErrorMessage + } + + async checkForViolations(input: string): Promise { + this.denyList.split('\n').forEach((denyListItem) => { + if (denyListItem && denyListItem !== '' && input.toLowerCase().includes(denyListItem.toLowerCase())) { + throw Error(this.moderationErrorMessage) + } + }) + return Promise.resolve(input) + } +} diff --git a/packages/components/nodes/moderation/SimplePromptModeration/simple_moderation.png b/packages/components/nodes/moderation/SimplePromptModeration/simple_moderation.png new file mode 100644 index 00000000..47d78cb6 Binary files /dev/null and b/packages/components/nodes/moderation/SimplePromptModeration/simple_moderation.png differ diff --git a/packages/components/nodes/outputparsers/OutputParserHelpers.ts b/packages/components/nodes/outputparsers/OutputParserHelpers.ts index a94edddd..8ea77e6b 100644 --- a/packages/components/nodes/outputparsers/OutputParserHelpers.ts +++ b/packages/components/nodes/outputparsers/OutputParserHelpers.ts @@ -1,6 +1,6 @@ import { BaseOutputParser } from 'langchain/schema/output_parser' import { LLMChain } from 'langchain/chains' -import { BaseLanguageModel } from 'langchain/base_language' +import { BaseLanguageModel, BaseLanguageModelCallOptions } from 'langchain/base_language' import { ICommonObject } from '../../src' import { ChatPromptTemplate, FewShotPromptTemplate, PromptTemplate, SystemMessagePromptTemplate } from 'langchain/prompts' @@ -15,7 +15,7 @@ export const formatResponse = (response: string | object): string | object => { export const injectOutputParser = ( outputParser: BaseOutputParser, - chain: LLMChain, + chain: LLMChain>, promptValues: ICommonObject | undefined = undefined ) => { if (outputParser && chain.prompt) { diff --git a/packages/components/nodes/retrievers/HydeRetriever/HydeRetriever.ts b/packages/components/nodes/retrievers/HydeRetriever/HydeRetriever.ts index 2baf677e..9ec7ada0 100644 --- a/packages/components/nodes/retrievers/HydeRetriever/HydeRetriever.ts +++ b/packages/components/nodes/retrievers/HydeRetriever/HydeRetriever.ts @@ -104,7 +104,7 @@ class HydeRetriever_Retrievers implements INode { const promptKey = nodeData.inputs?.promptKey as PromptKey const customPrompt = nodeData.inputs?.customPrompt as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const obj: HydeRetrieverOptions = { llm, diff --git a/packages/components/nodes/tools/ZapierNLA/ZapierNLA.ts b/packages/components/nodes/tools/ZapierNLA/ZapierNLA.ts index 49543136..31ac989b 100644 --- a/packages/components/nodes/tools/ZapierNLA/ZapierNLA.ts +++ b/packages/components/nodes/tools/ZapierNLA/ZapierNLA.ts @@ -11,6 +11,7 @@ class ZapierNLA_Tools implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -23,6 +24,7 @@ class ZapierNLA_Tools implements INode { this.icon = 'zapier.svg' this.category = 'Tools' this.description = "Access to apps and actions on Zapier's platform through a natural language API interface" + this.badge = 'DEPRECATING' this.inputs = [] this.credential = { label: 'Connect Credential', diff --git a/packages/components/nodes/vectorstores/Chroma/Chroma.ts b/packages/components/nodes/vectorstores/Chroma/Chroma.ts new file mode 100644 index 00000000..6e1cfa67 --- /dev/null +++ b/packages/components/nodes/vectorstores/Chroma/Chroma.ts @@ -0,0 +1,170 @@ +import { flatten } from 'lodash' +import { Chroma } from 'langchain/vectorstores/chroma' +import { Embeddings } from 'langchain/embeddings/base' +import { Document } from 'langchain/document' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' +import { ChromaExtended } from './core' + +class Chroma_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Chroma' + this.name = 'chroma' + this.version = 1.0 + this.type = 'Chroma' + this.icon = 'chroma.svg' + this.category = 'Vector Stores' + this.description = 'Upsert embedded data and perform similarity search upon query using Chroma, an open-source embedding database' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + description: 'Only needed if you have chroma on cloud services with X-Api-key', + optional: true, + credentialNames: ['chromaApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Collection Name', + name: 'collectionName', + type: 'string' + }, + { + label: 'Chroma URL', + name: 'chromaURL', + type: 'string', + optional: true + }, + { + label: 'Chroma Metadata Filter', + name: 'chromaMetadataFilter', + type: 'json', + optional: true, + additionalParams: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Chroma Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Chroma Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(Chroma)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const collectionName = nodeData.inputs?.collectionName as string + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + const chromaURL = nodeData.inputs?.chromaURL as string + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData) + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + const obj: { + collectionName: string + url?: string + chromaApiKey?: string + } = { collectionName } + if (chromaURL) obj.url = chromaURL + if (chromaApiKey) obj.chromaApiKey = chromaApiKey + + try { + await ChromaExtended.fromDocuments(finalDocs, embeddings, obj) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const collectionName = nodeData.inputs?.collectionName as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const chromaURL = nodeData.inputs?.chromaURL as string + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData) + + const chromaMetadataFilter = nodeData.inputs?.chromaMetadataFilter + + const obj: { + collectionName: string + url?: string + chromaApiKey?: string + filter?: object | undefined + } = { collectionName } + if (chromaURL) obj.url = chromaURL + if (chromaApiKey) obj.chromaApiKey = chromaApiKey + if (chromaMetadataFilter) { + const metadatafilter = typeof chromaMetadataFilter === 'object' ? chromaMetadataFilter : JSON.parse(chromaMetadataFilter) + obj.filter = metadatafilter + } + + const vectorStore = await ChromaExtended.fromExistingCollection(embeddings, obj) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +module.exports = { nodeClass: Chroma_VectorStores } diff --git a/packages/components/nodes/vectorstores/Chroma/Chroma_Existing.ts b/packages/components/nodes/vectorstores/Chroma/Chroma_Existing.ts index ff929ef1..62d3f8a2 100644 --- a/packages/components/nodes/vectorstores/Chroma/Chroma_Existing.ts +++ b/packages/components/nodes/vectorstores/Chroma/Chroma_Existing.ts @@ -12,6 +12,7 @@ class Chroma_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -26,6 +27,7 @@ class Chroma_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from Chroma (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Chroma/Chroma_Upsert.ts b/packages/components/nodes/vectorstores/Chroma/Chroma_Upsert.ts index 951338ba..e8564478 100644 --- a/packages/components/nodes/vectorstores/Chroma/Chroma_Upsert.ts +++ b/packages/components/nodes/vectorstores/Chroma/Chroma_Upsert.ts @@ -14,6 +14,7 @@ class ChromaUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -28,6 +29,7 @@ class ChromaUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Chroma' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Elasticsearch/ElasticSearchBase.ts b/packages/components/nodes/vectorstores/Elasticsearch/ElasticSearchBase.ts index 59294b7e..3c1dc5a1 100644 --- a/packages/components/nodes/vectorstores/Elasticsearch/ElasticSearchBase.ts +++ b/packages/components/nodes/vectorstores/Elasticsearch/ElasticSearchBase.ts @@ -21,6 +21,7 @@ export abstract class ElasticSearchBase { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -30,6 +31,7 @@ export abstract class ElasticSearchBase { this.type = 'Elasticsearch' this.icon = 'elasticsearch.png' this.category = 'Vector Stores' + this.badge = 'DEPRECATING' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] this.credential = { label: 'Connect Credential', @@ -144,13 +146,26 @@ export abstract class ElasticSearchBase { } else if (cloudId) { let username = getCredentialParam('username', credentialData, nodeData) let password = getCredentialParam('password', credentialData, nodeData) - elasticSearchClientOptions = { - cloud: { - id: cloudId - }, - auth: { - username: username, - password: password + if (cloudId.startsWith('http')) { + elasticSearchClientOptions = { + node: cloudId, + auth: { + username: username, + password: password + }, + tls: { + rejectUnauthorized: false + } + } + } else { + elasticSearchClientOptions = { + cloud: { + id: cloudId + }, + auth: { + username: username, + password: password + } } } } diff --git a/packages/components/nodes/vectorstores/Elasticsearch/Elasticsearch.ts b/packages/components/nodes/vectorstores/Elasticsearch/Elasticsearch.ts new file mode 100644 index 00000000..5f3cf206 --- /dev/null +++ b/packages/components/nodes/vectorstores/Elasticsearch/Elasticsearch.ts @@ -0,0 +1,233 @@ +import { flatten } from 'lodash' +import { Client, ClientOptions } from '@elastic/elasticsearch' +import { Document } from 'langchain/document' +import { Embeddings } from 'langchain/embeddings/base' +import { ElasticClientArgs, ElasticVectorSearch } from 'langchain/vectorstores/elasticsearch' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class Elasticsearch_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Elasticsearch' + this.name = 'elasticsearch' + this.version = 1.0 + this.description = + 'Upsert embedded data and perform similarity search upon query using Elasticsearch, a distributed search and analytics engine' + this.type = 'Elasticsearch' + this.icon = 'elasticsearch.png' + this.category = 'Vector Stores' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['elasticsearchApi', 'elasticSearchUserPassword'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Index Name', + name: 'indexName', + placeholder: '', + type: 'string' + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + }, + { + label: 'Similarity', + name: 'similarity', + description: 'Similarity measure used in Elasticsearch.', + type: 'options', + default: 'l2_norm', + options: [ + { + label: 'l2_norm', + name: 'l2_norm' + }, + { + label: 'dot_product', + name: 'dot_product' + }, + { + label: 'cosine', + name: 'cosine' + } + ], + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Elasticsearch Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Elasticsearch Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(ElasticVectorSearch)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const endPoint = getCredentialParam('endpoint', credentialData, nodeData) + const cloudId = getCredentialParam('cloudId', credentialData, nodeData) + const indexName = nodeData.inputs?.indexName as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const similarityMeasure = nodeData.inputs?.similarityMeasure as string + + const docs = nodeData.inputs?.document as Document[] + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + // The following code is a workaround for a bug (Langchain Issue #1589) in the underlying library. + // Store does not support object in metadata and fail silently + finalDocs.forEach((d) => { + delete d.metadata.pdf + delete d.metadata.loc + }) + // end of workaround + + const elasticSearchClientArgs = prepareClientArgs(endPoint, cloudId, credentialData, nodeData, similarityMeasure, indexName) + const vectorStore = new ElasticVectorSearch(embeddings, elasticSearchClientArgs) + + try { + await vectorStore.addDocuments(finalDocs) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const endPoint = getCredentialParam('endpoint', credentialData, nodeData) + const cloudId = getCredentialParam('cloudId', credentialData, nodeData) + const indexName = nodeData.inputs?.indexName as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const topK = nodeData.inputs?.topK as string + const similarityMeasure = nodeData.inputs?.similarityMeasure as string + const k = topK ? parseFloat(topK) : 4 + const output = nodeData.outputs?.output as string + + const elasticSearchClientArgs = prepareClientArgs(endPoint, cloudId, credentialData, nodeData, similarityMeasure, indexName) + const vectorStore = await ElasticVectorSearch.fromExistingIndex(embeddings, elasticSearchClientArgs) + + if (output === 'retriever') { + return vectorStore.asRetriever(k) + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +const prepareConnectionOptions = ( + endPoint: string | undefined, + cloudId: string | undefined, + credentialData: ICommonObject, + nodeData: INodeData +) => { + let elasticSearchClientOptions: ClientOptions = {} + if (endPoint) { + let apiKey = getCredentialParam('apiKey', credentialData, nodeData) + elasticSearchClientOptions = { + node: endPoint, + auth: { + apiKey: apiKey + } + } + } else if (cloudId) { + let username = getCredentialParam('username', credentialData, nodeData) + let password = getCredentialParam('password', credentialData, nodeData) + elasticSearchClientOptions = { + cloud: { + id: cloudId + }, + auth: { + username: username, + password: password + } + } + } + return elasticSearchClientOptions +} + +const prepareClientArgs = ( + endPoint: string | undefined, + cloudId: string | undefined, + credentialData: ICommonObject, + nodeData: INodeData, + similarityMeasure: string, + indexName: string +) => { + let elasticSearchClientOptions = prepareConnectionOptions(endPoint, cloudId, credentialData, nodeData) + let vectorSearchOptions = {} + switch (similarityMeasure) { + case 'dot_product': + vectorSearchOptions = { + similarity: 'dot_product' + } + break + case 'cosine': + vectorSearchOptions = { + similarity: 'cosine' + } + break + default: + vectorSearchOptions = { + similarity: 'l2_norm' + } + } + const elasticSearchClientArgs: ElasticClientArgs = { + client: new Client(elasticSearchClientOptions), + indexName: indexName, + vectorSearchOptions: vectorSearchOptions + } + return elasticSearchClientArgs +} + +module.exports = { nodeClass: Elasticsearch_VectorStores } diff --git a/packages/components/nodes/vectorstores/Elasticsearch/Elasticsearch_Upsert.ts b/packages/components/nodes/vectorstores/Elasticsearch/Elasticsearch_Upsert.ts index d3965786..a8ccd49a 100644 --- a/packages/components/nodes/vectorstores/Elasticsearch/Elasticsearch_Upsert.ts +++ b/packages/components/nodes/vectorstores/Elasticsearch/Elasticsearch_Upsert.ts @@ -50,7 +50,7 @@ class ElasicsearchUpsert_VectorStores extends ElasticSearchBase implements INode delete d.metadata.loc }) // end of workaround - return super.init(nodeData, _, options, flattenDocs) + return super.init(nodeData, _, options, finalDocs) } } diff --git a/packages/components/nodes/vectorstores/Faiss/Faiss.ts b/packages/components/nodes/vectorstores/Faiss/Faiss.ts new file mode 100644 index 00000000..4120a57e --- /dev/null +++ b/packages/components/nodes/vectorstores/Faiss/Faiss.ts @@ -0,0 +1,145 @@ +import { flatten } from 'lodash' +import { Document } from 'langchain/document' +import { FaissStore } from 'langchain/vectorstores/faiss' +import { Embeddings } from 'langchain/embeddings/base' +import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses } from '../../../src/utils' + +class Faiss_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Faiss' + this.name = 'faiss' + this.version = 1.0 + this.type = 'Faiss' + this.icon = 'faiss.svg' + this.category = 'Vector Stores' + this.description = 'Upsert embedded data and perform similarity search upon query using Faiss library from Meta' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Base Path to load', + name: 'basePath', + description: 'Path to load faiss.index file', + placeholder: `C:\\Users\\User\\Desktop`, + type: 'string' + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Faiss Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Faiss Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(FaissStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData): Promise { + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + const basePath = nodeData.inputs?.basePath as string + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + try { + const vectorStore = await FaissStore.fromDocuments(finalDocs, embeddings) + await vectorStore.save(basePath) + + // Avoid illegal invocation error + vectorStore.similaritySearchVectorWithScore = async (query: number[], k: number) => { + return await similaritySearchVectorWithScore(query, k, vectorStore) + } + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData): Promise { + const embeddings = nodeData.inputs?.embeddings as Embeddings + const basePath = nodeData.inputs?.basePath as string + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + const vectorStore = await FaissStore.load(basePath, embeddings) + + // Avoid illegal invocation error + vectorStore.similaritySearchVectorWithScore = async (query: number[], k: number) => { + return await similaritySearchVectorWithScore(query, k, vectorStore) + } + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +const similaritySearchVectorWithScore = async (query: number[], k: number, vectorStore: FaissStore) => { + const index = vectorStore.index + + if (k > index.ntotal()) { + const total = index.ntotal() + console.warn(`k (${k}) is greater than the number of elements in the index (${total}), setting k to ${total}`) + k = total + } + + const result = index.search(query, k) + return result.labels.map((id, index) => { + const uuid = vectorStore._mapping[id] + return [vectorStore.docstore.search(uuid), result.distances[index]] as [Document, number] + }) +} + +module.exports = { nodeClass: Faiss_VectorStores } diff --git a/packages/components/nodes/vectorstores/Faiss_Existing/Faiss_Existing.ts b/packages/components/nodes/vectorstores/Faiss/Faiss_Existing.ts similarity index 98% rename from packages/components/nodes/vectorstores/Faiss_Existing/Faiss_Existing.ts rename to packages/components/nodes/vectorstores/Faiss/Faiss_Existing.ts index 15d476d8..6f4e54d7 100644 --- a/packages/components/nodes/vectorstores/Faiss_Existing/Faiss_Existing.ts +++ b/packages/components/nodes/vectorstores/Faiss/Faiss_Existing.ts @@ -12,6 +12,7 @@ class Faiss_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] outputs: INodeOutputsValue[] @@ -25,6 +26,7 @@ class Faiss_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from Faiss (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.inputs = [ { label: 'Embeddings', diff --git a/packages/components/nodes/vectorstores/Faiss_Upsert/Faiss_Upsert.ts b/packages/components/nodes/vectorstores/Faiss/Faiss_Upsert.ts similarity index 98% rename from packages/components/nodes/vectorstores/Faiss_Upsert/Faiss_Upsert.ts rename to packages/components/nodes/vectorstores/Faiss/Faiss_Upsert.ts index a84b9da4..9b658a37 100644 --- a/packages/components/nodes/vectorstores/Faiss_Upsert/Faiss_Upsert.ts +++ b/packages/components/nodes/vectorstores/Faiss/Faiss_Upsert.ts @@ -13,6 +13,7 @@ class FaissUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] outputs: INodeOutputsValue[] @@ -26,6 +27,7 @@ class FaissUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Faiss' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.inputs = [ { label: 'Document', diff --git a/packages/components/nodes/vectorstores/Faiss_Existing/faiss.svg b/packages/components/nodes/vectorstores/Faiss/faiss.svg similarity index 100% rename from packages/components/nodes/vectorstores/Faiss_Existing/faiss.svg rename to packages/components/nodes/vectorstores/Faiss/faiss.svg diff --git a/packages/components/nodes/vectorstores/Faiss_Upsert/faiss.svg b/packages/components/nodes/vectorstores/Faiss_Upsert/faiss.svg deleted file mode 100644 index 5fbe9832..00000000 --- a/packages/components/nodes/vectorstores/Faiss_Upsert/faiss.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/packages/components/nodes/vectorstores/InMemory/InMemoryVectorStore.ts b/packages/components/nodes/vectorstores/InMemory/InMemoryVectorStore.ts index a827e3ee..620c3af7 100644 --- a/packages/components/nodes/vectorstores/InMemory/InMemoryVectorStore.ts +++ b/packages/components/nodes/vectorstores/InMemory/InMemoryVectorStore.ts @@ -1,9 +1,9 @@ -import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { flatten } from 'lodash' import { MemoryVectorStore } from 'langchain/vectorstores/memory' import { Embeddings } from 'langchain/embeddings/base' import { Document } from 'langchain/document' +import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' import { getBaseClasses } from '../../../src/utils' -import { flatten } from 'lodash' class InMemoryVectorStore_VectorStores implements INode { label: string @@ -31,7 +31,8 @@ class InMemoryVectorStore_VectorStores implements INode { label: 'Document', name: 'document', type: 'Document', - list: true + list: true, + optional: true }, { label: 'Embeddings', @@ -61,6 +62,28 @@ class InMemoryVectorStore_VectorStores implements INode { ] } + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData): Promise { + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + try { + await MemoryVectorStore.fromDocuments(finalDocs, embeddings) + } catch (e) { + throw new Error(e) + } + } + } + async init(nodeData: INodeData): Promise { const docs = nodeData.inputs?.document as Document[] const embeddings = nodeData.inputs?.embeddings as Embeddings diff --git a/packages/components/nodes/vectorstores/Milvus/Milvus.ts b/packages/components/nodes/vectorstores/Milvus/Milvus.ts new file mode 100644 index 00000000..090f35f7 --- /dev/null +++ b/packages/components/nodes/vectorstores/Milvus/Milvus.ts @@ -0,0 +1,348 @@ +import { flatten } from 'lodash' +import { DataType, ErrorCode, MetricType, IndexType } from '@zilliz/milvus2-sdk-node' +import { Document } from 'langchain/document' +import { MilvusLibArgs, Milvus } from 'langchain/vectorstores/milvus' +import { Embeddings } from 'langchain/embeddings/base' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +interface InsertRow { + [x: string]: string | number[] +} + +class Milvus_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Milvus' + this.name = 'milvus' + this.version = 1.0 + this.type = 'Milvus' + this.icon = 'milvus.svg' + this.category = 'Vector Stores' + this.description = `Upsert embedded data and perform similarity search upon query using Milvus, world's most advanced open-source vector database` + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + optional: true, + credentialNames: ['milvusAuth'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Milvus Server URL', + name: 'milvusServerUrl', + type: 'string', + placeholder: 'http://localhost:19530' + }, + { + label: 'Milvus Collection Name', + name: 'milvusCollection', + type: 'string' + }, + { + label: 'Milvus Filter', + name: 'milvusFilter', + type: 'string', + optional: true, + description: + 'Filter data with a simple string query. Refer Milvus docs for more details.', + placeholder: 'doc=="a"', + additionalParams: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Milvus Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Milvus Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(Milvus)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + // server setup + const address = nodeData.inputs?.milvusServerUrl as string + const collectionName = nodeData.inputs?.milvusCollection as string + + // embeddings + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + + // credential + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const milvusUser = getCredentialParam('milvusUser', credentialData, nodeData) + const milvusPassword = getCredentialParam('milvusPassword', credentialData, nodeData) + + // init MilvusLibArgs + const milVusArgs: MilvusLibArgs = { + url: address, + collectionName: collectionName + } + + if (milvusUser) milVusArgs.username = milvusUser + if (milvusPassword) milVusArgs.password = milvusPassword + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + try { + const vectorStore = await MilvusUpsert.fromDocuments(finalDocs, embeddings, milVusArgs) + + // Avoid Illegal Invocation + vectorStore.similaritySearchVectorWithScore = async (query: number[], k: number, filter?: string) => { + return await similaritySearchVectorWithScore(query, k, vectorStore, undefined, filter) + } + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + // server setup + const address = nodeData.inputs?.milvusServerUrl as string + const collectionName = nodeData.inputs?.milvusCollection as string + const milvusFilter = nodeData.inputs?.milvusFilter as string + + // embeddings + const embeddings = nodeData.inputs?.embeddings as Embeddings + const topK = nodeData.inputs?.topK as string + + // output + const output = nodeData.outputs?.output as string + + // format data + const k = topK ? parseFloat(topK) : 4 + + // credential + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const milvusUser = getCredentialParam('milvusUser', credentialData, nodeData) + const milvusPassword = getCredentialParam('milvusPassword', credentialData, nodeData) + + // init MilvusLibArgs + const milVusArgs: MilvusLibArgs = { + url: address, + collectionName: collectionName + } + + if (milvusUser) milVusArgs.username = milvusUser + if (milvusPassword) milVusArgs.password = milvusPassword + + const vectorStore = await Milvus.fromExistingCollection(embeddings, milVusArgs) + + // Avoid Illegal Invocation + vectorStore.similaritySearchVectorWithScore = async (query: number[], k: number, filter?: string) => { + return await similaritySearchVectorWithScore(query, k, vectorStore, milvusFilter, filter) + } + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +const checkJsonString = (value: string): { isJson: boolean; obj: any } => { + try { + const result = JSON.parse(value) + return { isJson: true, obj: result } + } catch (e) { + return { isJson: false, obj: null } + } +} + +const similaritySearchVectorWithScore = async (query: number[], k: number, vectorStore: Milvus, milvusFilter?: string, filter?: string) => { + const hasColResp = await vectorStore.client.hasCollection({ + collection_name: vectorStore.collectionName + }) + if (hasColResp.status.error_code !== ErrorCode.SUCCESS) { + throw new Error(`Error checking collection: ${hasColResp}`) + } + if (hasColResp.value === false) { + throw new Error(`Collection not found: ${vectorStore.collectionName}, please create collection before search.`) + } + + const filterStr = milvusFilter ?? filter ?? '' + + await vectorStore.grabCollectionFields() + + const loadResp = await vectorStore.client.loadCollectionSync({ + collection_name: vectorStore.collectionName + }) + + if (loadResp.error_code !== ErrorCode.SUCCESS) { + throw new Error(`Error loading collection: ${loadResp}`) + } + + const outputFields = vectorStore.fields.filter((field) => field !== vectorStore.vectorField) + + const searchResp = await vectorStore.client.search({ + collection_name: vectorStore.collectionName, + search_params: { + anns_field: vectorStore.vectorField, + topk: k.toString(), + metric_type: vectorStore.indexCreateParams.metric_type, + params: vectorStore.indexSearchParams + }, + output_fields: outputFields, + vector_type: DataType.FloatVector, + vectors: [query], + filter: filterStr + }) + if (searchResp.status.error_code !== ErrorCode.SUCCESS) { + throw new Error(`Error searching data: ${JSON.stringify(searchResp)}`) + } + const results: [Document, number][] = [] + searchResp.results.forEach((result) => { + const fields = { + pageContent: '', + metadata: {} as Record + } + Object.keys(result).forEach((key) => { + if (key === vectorStore.textField) { + fields.pageContent = result[key] + } else if (vectorStore.fields.includes(key) || key === vectorStore.primaryField) { + if (typeof result[key] === 'string') { + const { isJson, obj } = checkJsonString(result[key]) + fields.metadata[key] = isJson ? obj : result[key] + } else { + fields.metadata[key] = result[key] + } + } + }) + results.push([new Document(fields), result.score]) + }) + return results +} + +class MilvusUpsert extends Milvus { + async addVectors(vectors: number[][], documents: Document[]): Promise { + if (vectors.length === 0) { + return + } + await this.ensureCollection(vectors, documents) + + const insertDatas: InsertRow[] = [] + + for (let index = 0; index < vectors.length; index++) { + const vec = vectors[index] + const doc = documents[index] + const data: InsertRow = { + [this.textField]: doc.pageContent, + [this.vectorField]: vec + } + this.fields.forEach((field) => { + switch (field) { + case this.primaryField: + if (!this.autoId) { + if (doc.metadata[this.primaryField] === undefined) { + throw new Error( + `The Collection's primaryField is configured with autoId=false, thus its value must be provided through metadata.` + ) + } + data[field] = doc.metadata[this.primaryField] + } + break + case this.textField: + data[field] = doc.pageContent + break + case this.vectorField: + data[field] = vec + break + default: // metadata fields + if (doc.metadata[field] === undefined) { + throw new Error(`The field "${field}" is not provided in documents[${index}].metadata.`) + } else if (typeof doc.metadata[field] === 'object') { + data[field] = JSON.stringify(doc.metadata[field]) + } else { + data[field] = doc.metadata[field] + } + break + } + }) + + insertDatas.push(data) + } + + const descIndexResp = await this.client.describeIndex({ + collection_name: this.collectionName + }) + + if (descIndexResp.status.error_code === ErrorCode.IndexNotExist) { + const resp = await this.client.createIndex({ + collection_name: this.collectionName, + field_name: this.vectorField, + index_name: `myindex_${Date.now().toString()}`, + index_type: IndexType.AUTOINDEX, + metric_type: MetricType.L2 + }) + if (resp.error_code !== ErrorCode.SUCCESS) { + throw new Error(`Error creating index`) + } + } + + const insertResp = await this.client.insert({ + collection_name: this.collectionName, + fields_data: insertDatas + }) + + if (insertResp.status.error_code !== ErrorCode.SUCCESS) { + throw new Error(`Error inserting data: ${JSON.stringify(insertResp)}`) + } + + await this.client.flushSync({ collection_names: [this.collectionName] }) + } +} + +module.exports = { nodeClass: Milvus_VectorStores } diff --git a/packages/components/nodes/vectorstores/Milvus/Milvus_Existing.ts b/packages/components/nodes/vectorstores/Milvus/Milvus_Existing.ts index 3e9b125f..bce5b9cb 100644 --- a/packages/components/nodes/vectorstores/Milvus/Milvus_Existing.ts +++ b/packages/components/nodes/vectorstores/Milvus/Milvus_Existing.ts @@ -13,6 +13,7 @@ class Milvus_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -27,6 +28,7 @@ class Milvus_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing collection from Milvus (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Milvus/Milvus_Upsert.ts b/packages/components/nodes/vectorstores/Milvus/Milvus_Upsert.ts index 371fd16f..a0cae742 100644 --- a/packages/components/nodes/vectorstores/Milvus/Milvus_Upsert.ts +++ b/packages/components/nodes/vectorstores/Milvus/Milvus_Upsert.ts @@ -18,6 +18,7 @@ class Milvus_Upsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -32,6 +33,7 @@ class Milvus_Upsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Milvus' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDBAtlas.ts b/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDBAtlas.ts new file mode 100644 index 00000000..a0699f6b --- /dev/null +++ b/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDBAtlas.ts @@ -0,0 +1,194 @@ +import { flatten } from 'lodash' +import { MongoClient } from 'mongodb' +import { MongoDBAtlasVectorSearch } from 'langchain/vectorstores/mongodb_atlas' +import { Embeddings } from 'langchain/embeddings/base' +import { Document } from 'langchain/document' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class MongoDBAtlas_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'MongoDB Atlas' + this.name = 'mongoDBAtlas' + this.version = 1.0 + this.description = `Upsert embedded data and perform similarity search upon query using MongoDB Atlas, a managed cloud mongodb database` + this.type = 'MongoDB Atlas' + this.icon = 'mongodb.png' + this.category = 'Vector Stores' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['mongoDBUrlApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Database', + name: 'databaseName', + placeholder: '', + type: 'string' + }, + { + label: 'Collection Name', + name: 'collectionName', + placeholder: '', + type: 'string' + }, + { + label: 'Index Name', + name: 'indexName', + placeholder: '', + type: 'string' + }, + { + label: 'Content Field', + name: 'textKey', + description: 'Name of the field (column) that contains the actual content', + type: 'string', + default: 'text', + additionalParams: true, + optional: true + }, + { + label: 'Embedded Field', + name: 'embeddingKey', + description: 'Name of the field (column) that contains the Embedding', + type: 'string', + default: 'embedding', + additionalParams: true, + optional: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'MongoDB Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'MongoDB Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(MongoDBAtlasVectorSearch)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const databaseName = nodeData.inputs?.databaseName as string + const collectionName = nodeData.inputs?.collectionName as string + const indexName = nodeData.inputs?.indexName as string + let textKey = nodeData.inputs?.textKey as string + let embeddingKey = nodeData.inputs?.embeddingKey as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + + let mongoDBConnectUrl = getCredentialParam('mongoDBConnectUrl', credentialData, nodeData) + + const docs = nodeData.inputs?.document as Document[] + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + const document = new Document(flattenDocs[i]) + finalDocs.push(document) + } + } + + const mongoClient = new MongoClient(mongoDBConnectUrl) + const collection = mongoClient.db(databaseName).collection(collectionName) + + if (!textKey || textKey === '') textKey = 'text' + if (!embeddingKey || embeddingKey === '') embeddingKey = 'embedding' + + const mongoDBAtlasVectorSearch = new MongoDBAtlasVectorSearch(embeddings, { + collection, + indexName, + textKey, + embeddingKey + }) + + try { + await mongoDBAtlasVectorSearch.addDocuments(finalDocs) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const databaseName = nodeData.inputs?.databaseName as string + const collectionName = nodeData.inputs?.collectionName as string + const indexName = nodeData.inputs?.indexName as string + let textKey = nodeData.inputs?.textKey as string + let embeddingKey = nodeData.inputs?.embeddingKey as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + const output = nodeData.outputs?.output as string + + let mongoDBConnectUrl = getCredentialParam('mongoDBConnectUrl', credentialData, nodeData) + + const mongoClient = new MongoClient(mongoDBConnectUrl) + const collection = mongoClient.db(databaseName).collection(collectionName) + + if (!textKey || textKey === '') textKey = 'text' + if (!embeddingKey || embeddingKey === '') embeddingKey = 'embedding' + + const vectorStore = new MongoDBAtlasVectorSearch(embeddings, { + collection, + indexName, + textKey, + embeddingKey + }) + + if (output === 'retriever') { + return vectorStore.asRetriever(k) + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +module.exports = { nodeClass: MongoDBAtlas_VectorStores } diff --git a/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDBSearchBase.ts b/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDBSearchBase.ts new file mode 100644 index 00000000..95930e4a --- /dev/null +++ b/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDBSearchBase.ts @@ -0,0 +1,147 @@ +import { + getBaseClasses, + getCredentialData, + getCredentialParam, + ICommonObject, + INodeData, + INodeOutputsValue, + INodeParams +} from '../../../src' + +import { Embeddings } from 'langchain/embeddings/base' +import { VectorStore } from 'langchain/vectorstores/base' +import { Document } from 'langchain/document' +import { MongoDBAtlasVectorSearch } from 'langchain/vectorstores/mongodb_atlas' +import { Collection, MongoClient } from 'mongodb' + +export abstract class MongoDBSearchBase { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + mongoClient: MongoClient + + protected constructor() { + this.type = 'MongoDB Atlas' + this.icon = 'mongodb.png' + this.category = 'Vector Stores' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['mongoDBUrlApi'] + } + this.inputs = [ + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Database', + name: 'databaseName', + placeholder: '', + type: 'string' + }, + { + label: 'Collection Name', + name: 'collectionName', + placeholder: '', + type: 'string' + }, + { + label: 'Index Name', + name: 'indexName', + placeholder: '', + type: 'string' + }, + { + label: 'Content Field', + name: 'textKey', + description: 'Name of the field (column) that contains the actual content', + type: 'string', + default: 'text', + additionalParams: true, + optional: true + }, + { + label: 'Embedded Field', + name: 'embeddingKey', + description: 'Name of the field (column) that contains the Embedding', + type: 'string', + default: 'embedding', + additionalParams: true, + optional: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'MongoDB Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'MongoDB Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(MongoDBAtlasVectorSearch)] + } + ] + } + + abstract constructVectorStore( + embeddings: Embeddings, + collection: Collection, + indexName: string, + textKey: string, + embeddingKey: string, + docs: Document>[] | undefined + ): Promise + + async init(nodeData: INodeData, _: string, options: ICommonObject, docs: Document>[] | undefined): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const databaseName = nodeData.inputs?.databaseName as string + const collectionName = nodeData.inputs?.collectionName as string + const indexName = nodeData.inputs?.indexName as string + let textKey = nodeData.inputs?.textKey as string + let embeddingKey = nodeData.inputs?.embeddingKey as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + const output = nodeData.outputs?.output as string + + let mongoDBConnectUrl = getCredentialParam('mongoDBConnectUrl', credentialData, nodeData) + + this.mongoClient = new MongoClient(mongoDBConnectUrl) + const collection = this.mongoClient.db(databaseName).collection(collectionName) + if (!textKey || textKey === '') textKey = 'text' + if (!embeddingKey || embeddingKey === '') embeddingKey = 'embedding' + const vectorStore = await this.constructVectorStore(embeddings, collection, indexName, textKey, embeddingKey, docs) + + if (output === 'retriever') { + return vectorStore.asRetriever(k) + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} diff --git a/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDB_Existing.ts b/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDB_Existing.ts new file mode 100644 index 00000000..7b06814a --- /dev/null +++ b/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDB_Existing.ts @@ -0,0 +1,39 @@ +import { Collection } from 'mongodb' +import { MongoDBAtlasVectorSearch } from 'langchain/vectorstores/mongodb_atlas' +import { Embeddings } from 'langchain/embeddings/base' +import { VectorStore } from 'langchain/vectorstores/base' +import { Document } from 'langchain/document' +import { MongoDBSearchBase } from './MongoDBSearchBase' +import { ICommonObject, INode, INodeData } from '../../../src/Interface' + +class MongoDBExisting_VectorStores extends MongoDBSearchBase implements INode { + constructor() { + super() + this.label = 'MongoDB Atlas Load Existing Index' + this.name = 'MongoDBIndex' + this.version = 1.0 + this.description = 'Load existing data from MongoDB Atlas (i.e: Document has been upserted)' + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + return super.init(nodeData, _, options, undefined) + } + + async constructVectorStore( + embeddings: Embeddings, + collection: Collection, + indexName: string, + textKey: string, + embeddingKey: string, + _: Document>[] | undefined + ): Promise { + return new MongoDBAtlasVectorSearch(embeddings, { + collection: collection, + indexName: indexName, + textKey: textKey, + embeddingKey: embeddingKey + }) + } +} + +module.exports = { nodeClass: MongoDBExisting_VectorStores } diff --git a/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDB_Upsert.ts b/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDB_Upsert.ts new file mode 100644 index 00000000..d9287243 --- /dev/null +++ b/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDB_Upsert.ts @@ -0,0 +1,59 @@ +import { flatten } from 'lodash' +import { Collection } from 'mongodb' +import { Embeddings } from 'langchain/embeddings/base' +import { Document } from 'langchain/document' +import { VectorStore } from 'langchain/vectorstores/base' +import { MongoDBAtlasVectorSearch } from 'langchain/vectorstores/mongodb_atlas' +import { ICommonObject, INode, INodeData } from '../../../src/Interface' +import { MongoDBSearchBase } from './MongoDBSearchBase' + +class MongoDBUpsert_VectorStores extends MongoDBSearchBase implements INode { + constructor() { + super() + this.label = 'MongoDB Atlas Upsert Document' + this.name = 'MongoDBUpsert' + this.version = 1.0 + this.description = 'Upsert documents to MongoDB Atlas' + this.inputs.unshift({ + label: 'Document', + name: 'document', + type: 'Document', + list: true + }) + } + + async constructVectorStore( + embeddings: Embeddings, + collection: Collection, + indexName: string, + textKey: string, + embeddingKey: string, + docs: Document>[] + ): Promise { + const mongoDBAtlasVectorSearch = new MongoDBAtlasVectorSearch(embeddings, { + collection: collection, + indexName: indexName, + textKey: textKey, + embeddingKey: embeddingKey + }) + await mongoDBAtlasVectorSearch.addDocuments(docs) + return mongoDBAtlasVectorSearch + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const docs = nodeData.inputs?.document as Document[] + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + const document = new Document(flattenDocs[i]) + finalDocs.push(document) + } + } + + return super.init(nodeData, _, options, finalDocs) + } +} + +module.exports = { nodeClass: MongoDBUpsert_VectorStores } diff --git a/packages/components/nodes/vectorstores/MongoDBAtlas/mongodb.png b/packages/components/nodes/vectorstores/MongoDBAtlas/mongodb.png new file mode 100644 index 00000000..5586fe0a Binary files /dev/null and b/packages/components/nodes/vectorstores/MongoDBAtlas/mongodb.png differ diff --git a/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts new file mode 100644 index 00000000..e3e18ce1 --- /dev/null +++ b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts @@ -0,0 +1,139 @@ +import { flatten } from 'lodash' +import { Client } from '@opensearch-project/opensearch' +import { Document } from 'langchain/document' +import { OpenSearchVectorStore } from 'langchain/vectorstores/opensearch' +import { Embeddings } from 'langchain/embeddings/base' +import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses } from '../../../src/utils' + +class OpenSearch_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'OpenSearch' + this.name = 'openSearch' + this.version = 1.0 + this.type = 'OpenSearch' + this.icon = 'opensearch.png' + this.category = 'Vector Stores' + this.description = `Upsert embedded data and perform similarity search upon query using OpenSearch, an open-source, all-in-one vector database` + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'OpenSearch URL', + name: 'opensearchURL', + type: 'string', + placeholder: 'http://127.0.0.1:9200' + }, + { + label: 'Index Name', + name: 'indexName', + type: 'string' + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'OpenSearch Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'OpenSearch Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(OpenSearchVectorStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData): Promise { + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + const opensearchURL = nodeData.inputs?.opensearchURL as string + const indexName = nodeData.inputs?.indexName as string + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + const client = new Client({ + nodes: [opensearchURL] + }) + + try { + await OpenSearchVectorStore.fromDocuments(finalDocs, embeddings, { + client, + indexName: indexName + }) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData): Promise { + const embeddings = nodeData.inputs?.embeddings as Embeddings + const opensearchURL = nodeData.inputs?.opensearchURL as string + const indexName = nodeData.inputs?.indexName as string + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + const client = new Client({ + nodes: [opensearchURL] + }) + + const vectorStore = new OpenSearchVectorStore(embeddings, { + client, + indexName + }) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +module.exports = { nodeClass: OpenSearch_VectorStores } diff --git a/packages/components/nodes/vectorstores/OpenSearch_Upsert/OpenSearch_Upsert.ts b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch_Upsert.ts similarity index 98% rename from packages/components/nodes/vectorstores/OpenSearch_Upsert/OpenSearch_Upsert.ts rename to packages/components/nodes/vectorstores/OpenSearch/OpenSearch_Upsert.ts index da123581..2eb47316 100644 --- a/packages/components/nodes/vectorstores/OpenSearch_Upsert/OpenSearch_Upsert.ts +++ b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch_Upsert.ts @@ -14,6 +14,7 @@ class OpenSearchUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] outputs: INodeOutputsValue[] @@ -27,6 +28,7 @@ class OpenSearchUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to OpenSearch' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.inputs = [ { label: 'Document', diff --git a/packages/components/nodes/vectorstores/OpenSearch_Existing/OpenSearch_existing.ts b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch_existing.ts similarity index 98% rename from packages/components/nodes/vectorstores/OpenSearch_Existing/OpenSearch_existing.ts rename to packages/components/nodes/vectorstores/OpenSearch/OpenSearch_existing.ts index c8d09470..a012a2e5 100644 --- a/packages/components/nodes/vectorstores/OpenSearch_Existing/OpenSearch_existing.ts +++ b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch_existing.ts @@ -12,6 +12,7 @@ class OpenSearch_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] outputs: INodeOutputsValue[] @@ -25,6 +26,7 @@ class OpenSearch_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from OpenSearch (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.inputs = [ { label: 'Embeddings', diff --git a/packages/components/nodes/vectorstores/OpenSearch_Existing/opensearch.png b/packages/components/nodes/vectorstores/OpenSearch/opensearch.png similarity index 100% rename from packages/components/nodes/vectorstores/OpenSearch_Existing/opensearch.png rename to packages/components/nodes/vectorstores/OpenSearch/opensearch.png diff --git a/packages/components/nodes/vectorstores/OpenSearch_Upsert/opensearch.png b/packages/components/nodes/vectorstores/OpenSearch_Upsert/opensearch.png deleted file mode 100644 index 3fdcfd3f..00000000 Binary files a/packages/components/nodes/vectorstores/OpenSearch_Upsert/opensearch.png and /dev/null differ diff --git a/packages/components/nodes/vectorstores/Pinecone/Pinecone.ts b/packages/components/nodes/vectorstores/Pinecone/Pinecone.ts new file mode 100644 index 00000000..4ece4720 --- /dev/null +++ b/packages/components/nodes/vectorstores/Pinecone/Pinecone.ts @@ -0,0 +1,189 @@ +import { flatten } from 'lodash' +import { Pinecone } from '@pinecone-database/pinecone' +import { PineconeLibArgs, PineconeStore } from 'langchain/vectorstores/pinecone' +import { Embeddings } from 'langchain/embeddings/base' +import { Document } from 'langchain/document' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class Pinecone_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Pinecone' + this.name = 'pinecone' + this.version = 1.0 + this.type = 'Pinecone' + this.icon = 'pinecone.png' + this.category = 'Vector Stores' + this.description = `Upsert embedded data and perform similarity search upon query using Pinecone, a leading fully managed hosted vector database` + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['pineconeApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Pinecone Index', + name: 'pineconeIndex', + type: 'string' + }, + { + label: 'Pinecone Namespace', + name: 'pineconeNamespace', + type: 'string', + placeholder: 'my-first-namespace', + additionalParams: true, + optional: true + }, + { + label: 'Pinecone Metadata Filter', + name: 'pineconeMetadataFilter', + type: 'json', + optional: true, + additionalParams: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Pinecone Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Pinecone Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(PineconeStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const index = nodeData.inputs?.pineconeIndex as string + const pineconeNamespace = nodeData.inputs?.pineconeNamespace as string + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const pineconeApiKey = getCredentialParam('pineconeApiKey', credentialData, nodeData) + const pineconeEnv = getCredentialParam('pineconeEnv', credentialData, nodeData) + + const client = new Pinecone({ + apiKey: pineconeApiKey, + environment: pineconeEnv + }) + + const pineconeIndex = client.Index(index) + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + const obj: PineconeLibArgs = { + pineconeIndex + } + + if (pineconeNamespace) obj.namespace = pineconeNamespace + + try { + await PineconeStore.fromDocuments(finalDocs, embeddings, obj) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const index = nodeData.inputs?.pineconeIndex as string + const pineconeNamespace = nodeData.inputs?.pineconeNamespace as string + const pineconeMetadataFilter = nodeData.inputs?.pineconeMetadataFilter + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const pineconeApiKey = getCredentialParam('pineconeApiKey', credentialData, nodeData) + const pineconeEnv = getCredentialParam('pineconeEnv', credentialData, nodeData) + + const client = new Pinecone({ + apiKey: pineconeApiKey, + environment: pineconeEnv + }) + + const pineconeIndex = client.Index(index) + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + const obj: PineconeLibArgs = { + pineconeIndex + } + + if (pineconeNamespace) obj.namespace = pineconeNamespace + if (pineconeMetadataFilter) { + const metadatafilter = typeof pineconeMetadataFilter === 'object' ? pineconeMetadataFilter : JSON.parse(pineconeMetadataFilter) + obj.filter = metadatafilter + } + + const vectorStore = await PineconeStore.fromExistingIndex(embeddings, obj) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +module.exports = { nodeClass: Pinecone_VectorStores } diff --git a/packages/components/nodes/vectorstores/Pinecone/Pinecone_Existing.ts b/packages/components/nodes/vectorstores/Pinecone/Pinecone_Existing.ts index e8536d8d..ee2db071 100644 --- a/packages/components/nodes/vectorstores/Pinecone/Pinecone_Existing.ts +++ b/packages/components/nodes/vectorstores/Pinecone/Pinecone_Existing.ts @@ -12,6 +12,7 @@ class Pinecone_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -26,6 +27,7 @@ class Pinecone_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from Pinecone (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Pinecone/Pinecone_Upsert.ts b/packages/components/nodes/vectorstores/Pinecone/Pinecone_Upsert.ts index 0851fa3e..0c63ce7b 100644 --- a/packages/components/nodes/vectorstores/Pinecone/Pinecone_Upsert.ts +++ b/packages/components/nodes/vectorstores/Pinecone/Pinecone_Upsert.ts @@ -1,10 +1,10 @@ -import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { flatten } from 'lodash' import { Pinecone } from '@pinecone-database/pinecone' import { PineconeLibArgs, PineconeStore } from 'langchain/vectorstores/pinecone' import { Embeddings } from 'langchain/embeddings/base' import { Document } from 'langchain/document' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' -import { flatten } from 'lodash' class PineconeUpsert_VectorStores implements INode { label: string @@ -14,6 +14,7 @@ class PineconeUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -28,6 +29,7 @@ class PineconeUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Pinecone' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Postgres/Postgres.ts b/packages/components/nodes/vectorstores/Postgres/Postgres.ts new file mode 100644 index 00000000..ac4b80c3 --- /dev/null +++ b/packages/components/nodes/vectorstores/Postgres/Postgres.ts @@ -0,0 +1,268 @@ +import { Pool } from 'pg' +import { flatten } from 'lodash' +import { DataSourceOptions } from 'typeorm' +import { Embeddings } from 'langchain/embeddings/base' +import { Document } from 'langchain/document' +import { TypeORMVectorStore, TypeORMVectorStoreDocument } from 'langchain/vectorstores/typeorm' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class Postgres_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Postgres' + this.name = 'postgres' + this.version = 1.0 + this.type = 'Postgres' + this.icon = 'postgres.svg' + this.category = 'Vector Stores' + this.description = 'Upsert embedded data and perform similarity search upon query using pgvector on Postgres' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['PostgresApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Host', + name: 'host', + type: 'string' + }, + { + label: 'Database', + name: 'database', + type: 'string' + }, + { + label: 'Port', + name: 'port', + type: 'number', + placeholder: '6432', + optional: true + }, + { + label: 'Table Name', + name: 'tableName', + type: 'string', + placeholder: 'documents', + additionalParams: true, + optional: true + }, + { + label: 'Additional Configuration', + name: 'additionalConfig', + type: 'json', + additionalParams: true, + optional: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Postgres Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Postgres Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(TypeORMVectorStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const user = getCredentialParam('user', credentialData, nodeData) + const password = getCredentialParam('password', credentialData, nodeData) + const _tableName = nodeData.inputs?.tableName as string + const tableName = _tableName ? _tableName : 'documents' + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + const additionalConfig = nodeData.inputs?.additionalConfig as string + + let additionalConfiguration = {} + if (additionalConfig) { + try { + additionalConfiguration = typeof additionalConfig === 'object' ? additionalConfig : JSON.parse(additionalConfig) + } catch (exception) { + throw new Error('Invalid JSON in the Additional Configuration: ' + exception) + } + } + + const postgresConnectionOptions = { + ...additionalConfiguration, + type: 'postgres', + host: nodeData.inputs?.host as string, + port: nodeData.inputs?.port as number, + username: user, + password: password, + database: nodeData.inputs?.database as string + } + + const args = { + postgresConnectionOptions: postgresConnectionOptions as DataSourceOptions, + tableName: tableName + } + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + try { + const vectorStore = await TypeORMVectorStore.fromDocuments(finalDocs, embeddings, args) + + // Avoid Illegal invocation error + vectorStore.similaritySearchVectorWithScore = async (query: number[], k: number, filter?: any) => { + return await similaritySearchVectorWithScore(query, k, tableName, postgresConnectionOptions, filter) + } + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const user = getCredentialParam('user', credentialData, nodeData) + const password = getCredentialParam('password', credentialData, nodeData) + const _tableName = nodeData.inputs?.tableName as string + const tableName = _tableName ? _tableName : 'documents' + const embeddings = nodeData.inputs?.embeddings as Embeddings + const additionalConfig = nodeData.inputs?.additionalConfig as string + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + let additionalConfiguration = {} + if (additionalConfig) { + try { + additionalConfiguration = typeof additionalConfig === 'object' ? additionalConfig : JSON.parse(additionalConfig) + } catch (exception) { + throw new Error('Invalid JSON in the Additional Configuration: ' + exception) + } + } + + const postgresConnectionOptions = { + ...additionalConfiguration, + type: 'postgres', + host: nodeData.inputs?.host as string, + port: nodeData.inputs?.port as number, + username: user, + password: password, + database: nodeData.inputs?.database as string + } + + const args = { + postgresConnectionOptions: postgresConnectionOptions as DataSourceOptions, + tableName: tableName + } + + const vectorStore = await TypeORMVectorStore.fromDataSource(embeddings, args) + + // Rewrite the method to use pg pool connection instead of the default connection + /* Otherwise a connection error is displayed when the chain tries to execute the function + [chain/start] [1:chain:ConversationalRetrievalQAChain] Entering Chain run with input: { "question": "what the document is about", "chat_history": [] } + [retriever/start] [1:chain:ConversationalRetrievalQAChain > 2:retriever:VectorStoreRetriever] Entering Retriever run with input: { "query": "what the document is about" } + [ERROR]: uncaughtException: Illegal invocation TypeError: Illegal invocation at Socket.ref (node:net:1524:18) at Connection.ref (.../node_modules/pg/lib/connection.js:183:17) at Client.ref (.../node_modules/pg/lib/client.js:591:21) at BoundPool._pulseQueue (/node_modules/pg-pool/index.js:148:28) at .../node_modules/pg-pool/index.js:184:37 at process.processTicksAndRejections (node:internal/process/task_queues:77:11) + */ + vectorStore.similaritySearchVectorWithScore = async (query: number[], k: number, filter?: any) => { + return await similaritySearchVectorWithScore(query, k, tableName, postgresConnectionOptions, filter) + } + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +const similaritySearchVectorWithScore = async ( + query: number[], + k: number, + tableName: string, + postgresConnectionOptions: ICommonObject, + filter?: any +) => { + const embeddingString = `[${query.join(',')}]` + const _filter = filter ?? '{}' + + const queryString = ` + SELECT *, embedding <=> $1 as "_distance" + FROM ${tableName} + WHERE metadata @> $2 + ORDER BY "_distance" ASC + LIMIT $3;` + + const poolOptions = { + host: postgresConnectionOptions.host, + port: postgresConnectionOptions.port, + user: postgresConnectionOptions.username, + password: postgresConnectionOptions.password, + database: postgresConnectionOptions.database + } + const pool = new Pool(poolOptions) + const conn = await pool.connect() + + const documents = await conn.query(queryString, [embeddingString, _filter, k]) + + conn.release() + + const results = [] as [TypeORMVectorStoreDocument, number][] + for (const doc of documents.rows) { + if (doc._distance != null && doc.pageContent != null) { + const document = new Document(doc) as TypeORMVectorStoreDocument + document.id = doc.id + results.push([document, doc._distance]) + } + } + + return results +} + +module.exports = { nodeClass: Postgres_VectorStores } diff --git a/packages/components/nodes/vectorstores/Postgres_Existing/Postgres_Exisiting.ts b/packages/components/nodes/vectorstores/Postgres/Postgres_Exisiting.ts similarity index 99% rename from packages/components/nodes/vectorstores/Postgres_Existing/Postgres_Exisiting.ts rename to packages/components/nodes/vectorstores/Postgres/Postgres_Exisiting.ts index c0887432..99794a0d 100644 --- a/packages/components/nodes/vectorstores/Postgres_Existing/Postgres_Exisiting.ts +++ b/packages/components/nodes/vectorstores/Postgres/Postgres_Exisiting.ts @@ -14,6 +14,7 @@ class Postgres_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -28,6 +29,7 @@ class Postgres_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from Postgres using pgvector (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Postgres_Upsert/Postgres_Upsert.ts b/packages/components/nodes/vectorstores/Postgres/Postgres_Upsert.ts similarity index 99% rename from packages/components/nodes/vectorstores/Postgres_Upsert/Postgres_Upsert.ts rename to packages/components/nodes/vectorstores/Postgres/Postgres_Upsert.ts index 8ea3501d..f706cbe8 100644 --- a/packages/components/nodes/vectorstores/Postgres_Upsert/Postgres_Upsert.ts +++ b/packages/components/nodes/vectorstores/Postgres/Postgres_Upsert.ts @@ -15,6 +15,7 @@ class PostgresUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -29,6 +30,7 @@ class PostgresUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Postgres using pgvector' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Postgres_Existing/postgres.svg b/packages/components/nodes/vectorstores/Postgres/postgres.svg similarity index 100% rename from packages/components/nodes/vectorstores/Postgres_Existing/postgres.svg rename to packages/components/nodes/vectorstores/Postgres/postgres.svg diff --git a/packages/components/nodes/vectorstores/Postgres_Upsert/postgres.svg b/packages/components/nodes/vectorstores/Postgres_Upsert/postgres.svg deleted file mode 100644 index f631e7a8..00000000 --- a/packages/components/nodes/vectorstores/Postgres_Upsert/postgres.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/components/nodes/vectorstores/Qdrant/Qdrant.ts b/packages/components/nodes/vectorstores/Qdrant/Qdrant.ts new file mode 100644 index 00000000..6413f8bf --- /dev/null +++ b/packages/components/nodes/vectorstores/Qdrant/Qdrant.ts @@ -0,0 +1,247 @@ +import { flatten } from 'lodash' +import { QdrantClient } from '@qdrant/js-client-rest' +import { VectorStoreRetrieverInput } from 'langchain/vectorstores/base' +import { Document } from 'langchain/document' +import { QdrantVectorStore, QdrantLibArgs } from 'langchain/vectorstores/qdrant' +import { Embeddings } from 'langchain/embeddings/base' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +type RetrieverConfig = Partial> + +class Qdrant_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Qdrant' + this.name = 'qdrant' + this.version = 1.0 + this.type = 'Qdrant' + this.icon = 'qdrant.png' + this.category = 'Vector Stores' + this.description = + 'Upsert embedded data and perform similarity search upon query using Qdrant, a scalable open source vector database written in Rust' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + description: 'Only needed when using Qdrant cloud hosted', + optional: true, + credentialNames: ['qdrantApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Qdrant Server URL', + name: 'qdrantServerUrl', + type: 'string', + placeholder: 'http://localhost:6333' + }, + { + label: 'Qdrant Collection Name', + name: 'qdrantCollection', + type: 'string' + }, + { + label: 'Vector Dimension', + name: 'qdrantVectorDimension', + type: 'number', + default: 1536, + additionalParams: true + }, + { + label: 'Similarity', + name: 'qdrantSimilarity', + description: 'Similarity measure used in Qdrant.', + type: 'options', + default: 'Cosine', + options: [ + { + label: 'Cosine', + name: 'Cosine' + }, + { + label: 'Euclid', + name: 'Euclid' + }, + { + label: 'Dot', + name: 'Dot' + } + ], + additionalParams: true + }, + { + label: 'Additional Collection Cofiguration', + name: 'qdrantCollectionConfiguration', + description: + 'Refer to collection docs for more reference', + type: 'json', + optional: true, + additionalParams: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + }, + { + label: 'Qdrant Search Filter', + name: 'qdrantFilter', + description: 'Only return points which satisfy the conditions', + type: 'json', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Qdrant Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Qdrant Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(QdrantVectorStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const qdrantServerUrl = nodeData.inputs?.qdrantServerUrl as string + const collectionName = nodeData.inputs?.qdrantCollection as string + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + const qdrantSimilarity = nodeData.inputs?.qdrantSimilarity + const qdrantVectorDimension = nodeData.inputs?.qdrantVectorDimension + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const qdrantApiKey = getCredentialParam('qdrantApiKey', credentialData, nodeData) + + const client = new QdrantClient({ + url: qdrantServerUrl, + apiKey: qdrantApiKey + }) + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + const dbConfig: QdrantLibArgs = { + client, + url: qdrantServerUrl, + collectionName, + collectionConfig: { + vectors: { + size: qdrantVectorDimension ? parseInt(qdrantVectorDimension, 10) : 1536, + distance: qdrantSimilarity ?? 'Cosine' + } + } + } + + try { + await QdrantVectorStore.fromDocuments(finalDocs, embeddings, dbConfig) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const qdrantServerUrl = nodeData.inputs?.qdrantServerUrl as string + const collectionName = nodeData.inputs?.qdrantCollection as string + let qdrantCollectionConfiguration = nodeData.inputs?.qdrantCollectionConfiguration + const embeddings = nodeData.inputs?.embeddings as Embeddings + const qdrantSimilarity = nodeData.inputs?.qdrantSimilarity + const qdrantVectorDimension = nodeData.inputs?.qdrantVectorDimension + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + let queryFilter = nodeData.inputs?.queryFilter + + const k = topK ? parseFloat(topK) : 4 + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const qdrantApiKey = getCredentialParam('qdrantApiKey', credentialData, nodeData) + + const client = new QdrantClient({ + url: qdrantServerUrl, + apiKey: qdrantApiKey + }) + + const dbConfig: QdrantLibArgs = { + client, + collectionName + } + + const retrieverConfig: RetrieverConfig = { + k + } + + if (qdrantCollectionConfiguration) { + qdrantCollectionConfiguration = + typeof qdrantCollectionConfiguration === 'object' + ? qdrantCollectionConfiguration + : JSON.parse(qdrantCollectionConfiguration) + dbConfig.collectionConfig = { + ...qdrantCollectionConfiguration, + vectors: { + ...qdrantCollectionConfiguration.vectors, + size: qdrantVectorDimension ? parseInt(qdrantVectorDimension, 10) : 1536, + distance: qdrantSimilarity ?? 'Cosine' + } + } + } + + if (queryFilter) { + retrieverConfig.filter = typeof queryFilter === 'object' ? queryFilter : JSON.parse(queryFilter) + } + + const vectorStore = await QdrantVectorStore.fromExistingCollection(embeddings, dbConfig) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(retrieverConfig) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +module.exports = { nodeClass: Qdrant_VectorStores } diff --git a/packages/components/nodes/vectorstores/Qdrant_Existing/Qdrant_Existing.ts b/packages/components/nodes/vectorstores/Qdrant/Qdrant_Existing.ts similarity index 99% rename from packages/components/nodes/vectorstores/Qdrant_Existing/Qdrant_Existing.ts rename to packages/components/nodes/vectorstores/Qdrant/Qdrant_Existing.ts index c16e8f54..fb114402 100644 --- a/packages/components/nodes/vectorstores/Qdrant_Existing/Qdrant_Existing.ts +++ b/packages/components/nodes/vectorstores/Qdrant/Qdrant_Existing.ts @@ -15,6 +15,7 @@ class Qdrant_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -29,6 +30,7 @@ class Qdrant_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from Qdrant (i.e., documents have been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Qdrant_Upsert/Qdrant_Upsert.ts b/packages/components/nodes/vectorstores/Qdrant/Qdrant_Upsert.ts similarity index 99% rename from packages/components/nodes/vectorstores/Qdrant_Upsert/Qdrant_Upsert.ts rename to packages/components/nodes/vectorstores/Qdrant/Qdrant_Upsert.ts index 183271f7..c43a0c8d 100644 --- a/packages/components/nodes/vectorstores/Qdrant_Upsert/Qdrant_Upsert.ts +++ b/packages/components/nodes/vectorstores/Qdrant/Qdrant_Upsert.ts @@ -17,6 +17,7 @@ class QdrantUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -31,6 +32,7 @@ class QdrantUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Qdrant' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Qdrant_Existing/qdrant.png b/packages/components/nodes/vectorstores/Qdrant/qdrant.png similarity index 100% rename from packages/components/nodes/vectorstores/Qdrant_Existing/qdrant.png rename to packages/components/nodes/vectorstores/Qdrant/qdrant.png diff --git a/packages/components/nodes/vectorstores/Qdrant_Upsert/qdrant.png b/packages/components/nodes/vectorstores/Qdrant_Upsert/qdrant.png deleted file mode 100644 index ecb2a56d..00000000 Binary files a/packages/components/nodes/vectorstores/Qdrant_Upsert/qdrant.png and /dev/null differ diff --git a/packages/components/nodes/vectorstores/Redis/Redis.ts b/packages/components/nodes/vectorstores/Redis/Redis.ts new file mode 100644 index 00000000..dc993b86 --- /dev/null +++ b/packages/components/nodes/vectorstores/Redis/Redis.ts @@ -0,0 +1,327 @@ +import { flatten } from 'lodash' +import { createClient, SearchOptions } from 'redis' +import { Embeddings } from 'langchain/embeddings/base' +import { RedisVectorStore, RedisVectorStoreConfig } from 'langchain/vectorstores/redis' +import { Document } from 'langchain/document' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' +import { escapeAllStrings, escapeSpecialChars, unEscapeSpecialChars } from './utils' + +class Redis_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Redis' + this.name = 'redis' + this.version = 1.0 + this.description = + 'Upsert embedded data and perform similarity search upon query using Redis, an open source, in-memory data structure store' + this.type = 'Redis' + this.icon = 'redis.svg' + this.category = 'Vector Stores' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['redisCacheUrlApi', 'redisCacheApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Index Name', + name: 'indexName', + placeholder: '', + type: 'string' + }, + { + label: 'Replace Index on Upsert', + name: 'replaceIndex', + description: 'Selecting this option will delete the existing index and recreate a new one when upserting', + default: false, + type: 'boolean' + }, + { + label: 'Content Field', + name: 'contentKey', + description: 'Name of the field (column) that contains the actual content', + type: 'string', + default: 'content', + additionalParams: true, + optional: true + }, + { + label: 'Metadata Field', + name: 'metadataKey', + description: 'Name of the field (column) that contains the metadata of the document', + type: 'string', + default: 'metadata', + additionalParams: true, + optional: true + }, + { + label: 'Vector Field', + name: 'vectorKey', + description: 'Name of the field (column) that contains the vector', + type: 'string', + default: 'content_vector', + additionalParams: true, + optional: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Redis Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Redis Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(RedisVectorStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const indexName = nodeData.inputs?.indexName as string + let contentKey = nodeData.inputs?.contentKey as string + let metadataKey = nodeData.inputs?.metadataKey as string + let vectorKey = nodeData.inputs?.vectorKey as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const replaceIndex = nodeData.inputs?.replaceIndex as boolean + + let redisUrl = getCredentialParam('redisUrl', credentialData, nodeData) + if (!redisUrl || redisUrl === '') { + const username = getCredentialParam('redisCacheUser', credentialData, nodeData) + const password = getCredentialParam('redisCachePwd', credentialData, nodeData) + const portStr = getCredentialParam('redisCachePort', credentialData, nodeData) + const host = getCredentialParam('redisCacheHost', credentialData, nodeData) + + redisUrl = 'redis://' + username + ':' + password + '@' + host + ':' + portStr + } + + const docs = nodeData.inputs?.document as Document[] + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + const document = new Document(flattenDocs[i]) + escapeAllStrings(document.metadata) + finalDocs.push(document) + } + } + + const redisClient = createClient({ url: redisUrl }) + await redisClient.connect() + + try { + const storeConfig: RedisVectorStoreConfig = { + redisClient: redisClient, + indexName: indexName + } + const isIndexExists = await checkIndexExists(redisClient, indexName) + if (replaceIndex && isIndexExists) { + let response = await redisClient.ft.dropIndex(indexName) + if (process.env.DEBUG === 'true') { + // eslint-disable-next-line no-console + console.log(`Redis Vector Store :: Dropping index [${indexName}], Received Response [${response}]`) + } + } + const vectorStore = await RedisVectorStore.fromDocuments(finalDocs, embeddings, storeConfig) + + if (!contentKey || contentKey === '') contentKey = 'content' + if (!metadataKey || metadataKey === '') metadataKey = 'metadata' + if (!vectorKey || vectorKey === '') vectorKey = 'content_vector' + + // Avoid Illegal invocation error + vectorStore.similaritySearchVectorWithScore = async (query: number[], k: number, filter?: any) => { + return await similaritySearchVectorWithScore( + query, + k, + indexName, + metadataKey, + vectorKey, + contentKey, + redisClient, + filter + ) + } + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const indexName = nodeData.inputs?.indexName as string + let contentKey = nodeData.inputs?.contentKey as string + let metadataKey = nodeData.inputs?.metadataKey as string + let vectorKey = nodeData.inputs?.vectorKey as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + const output = nodeData.outputs?.output as string + + let redisUrl = getCredentialParam('redisUrl', credentialData, nodeData) + if (!redisUrl || redisUrl === '') { + const username = getCredentialParam('redisCacheUser', credentialData, nodeData) + const password = getCredentialParam('redisCachePwd', credentialData, nodeData) + const portStr = getCredentialParam('redisCachePort', credentialData, nodeData) + const host = getCredentialParam('redisCacheHost', credentialData, nodeData) + + redisUrl = 'redis://' + username + ':' + password + '@' + host + ':' + portStr + } + + const redisClient = createClient({ url: redisUrl }) + await redisClient.connect() + + const storeConfig: RedisVectorStoreConfig = { + redisClient: redisClient, + indexName: indexName + } + + const vectorStore = new RedisVectorStore(embeddings, storeConfig) + + if (!contentKey || contentKey === '') contentKey = 'content' + if (!metadataKey || metadataKey === '') metadataKey = 'metadata' + if (!vectorKey || vectorKey === '') vectorKey = 'content_vector' + + // Avoid Illegal invocation error + vectorStore.similaritySearchVectorWithScore = async (query: number[], k: number, filter?: any) => { + return await similaritySearchVectorWithScore(query, k, indexName, metadataKey, vectorKey, contentKey, redisClient, filter) + } + + if (output === 'retriever') { + return vectorStore.asRetriever(k) + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +const checkIndexExists = async (redisClient: ReturnType, indexName: string) => { + try { + await redisClient.ft.info(indexName) + } catch (err: any) { + if (err?.message.includes('unknown command')) { + throw new Error( + 'Failed to run FT.INFO command. Please ensure that you are running a RediSearch-capable Redis instance: https://js.langchain.com/docs/modules/data_connection/vectorstores/integrations/redis#setup' + ) + } + // index doesn't exist + return false + } + + return true +} + +const buildQuery = ( + query: number[], + k: number, + metadataKey: string, + vectorKey: string, + contentKey: string, + filter?: string[] +): [string, SearchOptions] => { + const vectorScoreField = 'vector_score' + + let hybridFields = '*' + // if a filter is set, modify the hybrid query + if (filter && filter.length) { + // `filter` is a list of strings, then it's applied using the OR operator in the metadata key + hybridFields = `@${metadataKey}:(${filter.map(escapeSpecialChars).join('|')})` + } + + const baseQuery = `${hybridFields} => [KNN ${k} @${vectorKey} $vector AS ${vectorScoreField}]` + const returnFields = [metadataKey, contentKey, vectorScoreField] + + const options: SearchOptions = { + PARAMS: { + vector: Buffer.from(new Float32Array(query).buffer) + }, + RETURN: returnFields, + SORTBY: vectorScoreField, + DIALECT: 2, + LIMIT: { + from: 0, + size: k + } + } + + return [baseQuery, options] +} + +const similaritySearchVectorWithScore = async ( + query: number[], + k: number, + indexName: string, + metadataKey: string, + vectorKey: string, + contentKey: string, + redisClient: ReturnType, + filter?: string[] +): Promise<[Document, number][]> => { + const results = await redisClient.ft.search(indexName, ...buildQuery(query, k, metadataKey, vectorKey, contentKey, filter)) + const result: [Document, number][] = [] + + if (results.total) { + for (const res of results.documents) { + if (res.value) { + const document = res.value + if (document.vector_score) { + const metadataString = unEscapeSpecialChars(document[metadataKey] as string) + result.push([ + new Document({ + pageContent: document[contentKey] as string, + metadata: JSON.parse(metadataString) + }), + Number(document.vector_score) + ]) + } + } + } + } + return result +} + +module.exports = { nodeClass: Redis_VectorStores } diff --git a/packages/components/nodes/vectorstores/Redis/RedisSearchBase.ts b/packages/components/nodes/vectorstores/Redis/RedisSearchBase.ts index 9d1c2ea1..b6aa6ebb 100644 --- a/packages/components/nodes/vectorstores/Redis/RedisSearchBase.ts +++ b/packages/components/nodes/vectorstores/Redis/RedisSearchBase.ts @@ -23,6 +23,7 @@ export abstract class RedisSearchBase { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -34,6 +35,7 @@ export abstract class RedisSearchBase { this.icon = 'redis.svg' this.category = 'Vector Stores' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Redis/Redis_Existing.ts b/packages/components/nodes/vectorstores/Redis/Redis_Existing.ts index 9ad472a8..e8848d33 100644 --- a/packages/components/nodes/vectorstores/Redis/Redis_Existing.ts +++ b/packages/components/nodes/vectorstores/Redis/Redis_Existing.ts @@ -14,8 +14,8 @@ class RedisExisting_VectorStores extends RedisSearchBase implements INode { this.version = 1.0 this.description = 'Load existing index from Redis (i.e: Document has been upserted)' - // Remove deleteIndex from inputs as it is not applicable while fetching data from Redis - let input = this.inputs.find((i) => i.name === 'deleteIndex') + // Remove replaceIndex from inputs as it is not applicable while fetching data from Redis + let input = this.inputs.find((i) => i.name === 'replaceIndex') if (input) this.inputs.splice(this.inputs.indexOf(input), 1) } diff --git a/packages/components/nodes/vectorstores/Redis/Redis_Upsert.ts b/packages/components/nodes/vectorstores/Redis/Redis_Upsert.ts index 9d1a4f45..4da58eaf 100644 --- a/packages/components/nodes/vectorstores/Redis/Redis_Upsert.ts +++ b/packages/components/nodes/vectorstores/Redis/Redis_Upsert.ts @@ -56,7 +56,7 @@ class RedisUpsert_VectorStores extends RedisSearchBase implements INode { } } - return super.init(nodeData, _, options, flattenDocs) + return super.init(nodeData, _, options, finalDocs) } } diff --git a/packages/components/nodes/vectorstores/Singlestore/Singlestore.ts b/packages/components/nodes/vectorstores/Singlestore/Singlestore.ts new file mode 100644 index 00000000..d16252ac --- /dev/null +++ b/packages/components/nodes/vectorstores/Singlestore/Singlestore.ts @@ -0,0 +1,197 @@ +import { flatten } from 'lodash' +import { Embeddings } from 'langchain/embeddings/base' +import { SingleStoreVectorStore, SingleStoreVectorStoreConfig } from 'langchain/vectorstores/singlestore' +import { Document } from 'langchain/document' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class SingleStore_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'SingleStore' + this.name = 'singlestore' + this.version = 1.0 + this.type = 'SingleStore' + this.icon = 'singlestore.svg' + this.category = 'Vector Stores' + this.description = + 'Upsert embedded data and perform similarity search upon query using SingleStore, a fast and distributed cloud relational database' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + description: 'Needed when using SingleStore cloud hosted', + optional: true, + credentialNames: ['singleStoreApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Host', + name: 'host', + type: 'string' + }, + { + label: 'Database', + name: 'database', + type: 'string' + }, + { + label: 'Table Name', + name: 'tableName', + type: 'string', + placeholder: 'embeddings', + additionalParams: true, + optional: true + }, + { + label: 'Content Column Name', + name: 'contentColumnName', + type: 'string', + placeholder: 'content', + additionalParams: true, + optional: true + }, + { + label: 'Vector Column Name', + name: 'vectorColumnName', + type: 'string', + placeholder: 'vector', + additionalParams: true, + optional: true + }, + { + label: 'Metadata Column Name', + name: 'metadataColumnName', + type: 'string', + placeholder: 'metadata', + additionalParams: true, + optional: true + }, + { + label: 'Top K', + name: 'topK', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'SingleStore Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'SingleStore Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(SingleStoreVectorStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const user = getCredentialParam('user', credentialData, nodeData) + const password = getCredentialParam('password', credentialData, nodeData) + + const singleStoreConnectionConfig = { + connectionOptions: { + host: nodeData.inputs?.host as string, + port: 3306, + user, + password, + database: nodeData.inputs?.database as string + }, + ...(nodeData.inputs?.tableName ? { tableName: nodeData.inputs.tableName as string } : {}), + ...(nodeData.inputs?.contentColumnName ? { contentColumnName: nodeData.inputs.contentColumnName as string } : {}), + ...(nodeData.inputs?.vectorColumnName ? { vectorColumnName: nodeData.inputs.vectorColumnName as string } : {}), + ...(nodeData.inputs?.metadataColumnName ? { metadataColumnName: nodeData.inputs.metadataColumnName as string } : {}) + } as SingleStoreVectorStoreConfig + + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + try { + const vectorStore = new SingleStoreVectorStore(embeddings, singleStoreConnectionConfig) + vectorStore.addDocuments.bind(vectorStore)(finalDocs) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const user = getCredentialParam('user', credentialData, nodeData) + const password = getCredentialParam('password', credentialData, nodeData) + + const singleStoreConnectionConfig = { + connectionOptions: { + host: nodeData.inputs?.host as string, + port: 3306, + user, + password, + database: nodeData.inputs?.database as string + }, + ...(nodeData.inputs?.tableName ? { tableName: nodeData.inputs.tableName as string } : {}), + ...(nodeData.inputs?.contentColumnName ? { contentColumnName: nodeData.inputs.contentColumnName as string } : {}), + ...(nodeData.inputs?.vectorColumnName ? { vectorColumnName: nodeData.inputs.vectorColumnName as string } : {}), + ...(nodeData.inputs?.metadataColumnName ? { metadataColumnName: nodeData.inputs.metadataColumnName as string } : {}) + } as SingleStoreVectorStoreConfig + + const embeddings = nodeData.inputs?.embeddings as Embeddings + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + const vectorStore = new SingleStoreVectorStore(embeddings, singleStoreConnectionConfig) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +module.exports = { nodeClass: SingleStore_VectorStores } diff --git a/packages/components/nodes/vectorstores/Singlestore_Existing/Singlestore_Existing.ts b/packages/components/nodes/vectorstores/Singlestore/Singlestore_Existing.ts similarity index 99% rename from packages/components/nodes/vectorstores/Singlestore_Existing/Singlestore_Existing.ts rename to packages/components/nodes/vectorstores/Singlestore/Singlestore_Existing.ts index c5f6fbce..34061764 100644 --- a/packages/components/nodes/vectorstores/Singlestore_Existing/Singlestore_Existing.ts +++ b/packages/components/nodes/vectorstores/Singlestore/Singlestore_Existing.ts @@ -11,6 +11,7 @@ class SingleStoreExisting_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -25,6 +26,7 @@ class SingleStoreExisting_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing document from SingleStore' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Singlestore_Upsert/Singlestore_Upsert.ts b/packages/components/nodes/vectorstores/Singlestore/Singlestore_Upsert.ts similarity index 99% rename from packages/components/nodes/vectorstores/Singlestore_Upsert/Singlestore_Upsert.ts rename to packages/components/nodes/vectorstores/Singlestore/Singlestore_Upsert.ts index d8edc8d4..f158f9e8 100644 --- a/packages/components/nodes/vectorstores/Singlestore_Upsert/Singlestore_Upsert.ts +++ b/packages/components/nodes/vectorstores/Singlestore/Singlestore_Upsert.ts @@ -13,6 +13,7 @@ class SingleStoreUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -27,6 +28,7 @@ class SingleStoreUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to SingleStore' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Singlestore_Existing/singlestore.svg b/packages/components/nodes/vectorstores/Singlestore/singlestore.svg similarity index 100% rename from packages/components/nodes/vectorstores/Singlestore_Existing/singlestore.svg rename to packages/components/nodes/vectorstores/Singlestore/singlestore.svg diff --git a/packages/components/nodes/vectorstores/Singlestore_Upsert/singlestore.svg b/packages/components/nodes/vectorstores/Singlestore_Upsert/singlestore.svg deleted file mode 100644 index bd8dc817..00000000 --- a/packages/components/nodes/vectorstores/Singlestore_Upsert/singlestore.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - SingleStore - - - - - - - - - - - - - - - - - diff --git a/packages/components/nodes/vectorstores/Supabase/Supabase.ts b/packages/components/nodes/vectorstores/Supabase/Supabase.ts new file mode 100644 index 00000000..13840ab7 --- /dev/null +++ b/packages/components/nodes/vectorstores/Supabase/Supabase.ts @@ -0,0 +1,171 @@ +import { flatten } from 'lodash' +import { createClient } from '@supabase/supabase-js' +import { Document } from 'langchain/document' +import { Embeddings } from 'langchain/embeddings/base' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' +import { SupabaseLibArgs, SupabaseVectorStore } from 'langchain/vectorstores/supabase' + +class Supabase_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Supabase' + this.name = 'supabase' + this.version = 1.0 + this.type = 'Supabase' + this.icon = 'supabase.svg' + this.category = 'Vector Stores' + this.description = 'Upsert embedded data and perform similarity search upon query using Supabase via pgvector extension' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['supabaseApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Supabase Project URL', + name: 'supabaseProjUrl', + type: 'string' + }, + { + label: 'Table Name', + name: 'tableName', + type: 'string' + }, + { + label: 'Query Name', + name: 'queryName', + type: 'string' + }, + { + label: 'Supabase Metadata Filter', + name: 'supabaseMetadataFilter', + type: 'json', + optional: true, + additionalParams: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Supabase Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Supabase Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(SupabaseVectorStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const supabaseProjUrl = nodeData.inputs?.supabaseProjUrl as string + const tableName = nodeData.inputs?.tableName as string + const queryName = nodeData.inputs?.queryName as string + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const supabaseApiKey = getCredentialParam('supabaseApiKey', credentialData, nodeData) + + const client = createClient(supabaseProjUrl, supabaseApiKey) + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + try { + await SupabaseVectorStore.fromDocuments(finalDocs, embeddings, { + client, + tableName: tableName, + queryName: queryName + }) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const supabaseProjUrl = nodeData.inputs?.supabaseProjUrl as string + const tableName = nodeData.inputs?.tableName as string + const queryName = nodeData.inputs?.queryName as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const supabaseMetadataFilter = nodeData.inputs?.supabaseMetadataFilter + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const supabaseApiKey = getCredentialParam('supabaseApiKey', credentialData, nodeData) + + const client = createClient(supabaseProjUrl, supabaseApiKey) + + const obj: SupabaseLibArgs = { + client, + tableName, + queryName + } + + if (supabaseMetadataFilter) { + const metadatafilter = typeof supabaseMetadataFilter === 'object' ? supabaseMetadataFilter : JSON.parse(supabaseMetadataFilter) + obj.filter = metadatafilter + } + + const vectorStore = await SupabaseVectorStore.fromExistingIndex(embeddings, obj) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +module.exports = { nodeClass: Supabase_VectorStores } diff --git a/packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts b/packages/components/nodes/vectorstores/Supabase/Supabase_Exisiting.ts similarity index 98% rename from packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts rename to packages/components/nodes/vectorstores/Supabase/Supabase_Exisiting.ts index ed6febb5..8f135cf7 100644 --- a/packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts +++ b/packages/components/nodes/vectorstores/Supabase/Supabase_Exisiting.ts @@ -12,6 +12,7 @@ class Supabase_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -26,6 +27,7 @@ class Supabase_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from Supabase (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts b/packages/components/nodes/vectorstores/Supabase/Supabase_Upsert.ts similarity index 98% rename from packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts rename to packages/components/nodes/vectorstores/Supabase/Supabase_Upsert.ts index 90fe2121..9e97f48f 100644 --- a/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts +++ b/packages/components/nodes/vectorstores/Supabase/Supabase_Upsert.ts @@ -14,6 +14,7 @@ class SupabaseUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -28,6 +29,7 @@ class SupabaseUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Supabase' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Supabase_Existing/supabase.svg b/packages/components/nodes/vectorstores/Supabase/supabase.svg similarity index 100% rename from packages/components/nodes/vectorstores/Supabase_Existing/supabase.svg rename to packages/components/nodes/vectorstores/Supabase/supabase.svg diff --git a/packages/components/nodes/vectorstores/Supabase_Upsert/supabase.svg b/packages/components/nodes/vectorstores/Supabase_Upsert/supabase.svg deleted file mode 100644 index 884d6449..00000000 --- a/packages/components/nodes/vectorstores/Supabase_Upsert/supabase.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/components/nodes/vectorstores/Vectara/Vectara.ts b/packages/components/nodes/vectorstores/Vectara/Vectara.ts new file mode 100644 index 00000000..7460c586 --- /dev/null +++ b/packages/components/nodes/vectorstores/Vectara/Vectara.ts @@ -0,0 +1,242 @@ +import { flatten } from 'lodash' +import { VectaraStore, VectaraLibArgs, VectaraFilter, VectaraContextConfig, VectaraFile } from 'langchain/vectorstores/vectara' +import { Document } from 'langchain/document' +import { Embeddings } from 'langchain/embeddings/base' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class Vectara_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Vectara' + this.name = 'vectara' + this.version = 1.0 + this.type = 'Vectara' + this.icon = 'vectara.png' + this.category = 'Vector Stores' + this.description = 'Upsert embedded data and perform similarity search upon query using Vectara, a LLM-powered search-as-a-service' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['vectaraApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'File', + name: 'file', + description: + 'File to upload to Vectara. Supported file types: https://docs.vectara.com/docs/api-reference/indexing-apis/file-upload/file-upload-filetypes', + type: 'file', + optional: true + }, + { + label: 'Metadata Filter', + name: 'filter', + description: + 'Filter to apply to Vectara metadata. Refer to the documentation on how to use Vectara filters with Flowise.', + type: 'string', + additionalParams: true, + optional: true + }, + { + label: 'Sentences Before', + name: 'sentencesBefore', + description: 'Number of sentences to fetch before the matched sentence. Defaults to 2.', + type: 'number', + default: 2, + additionalParams: true, + optional: true + }, + { + label: 'Sentences After', + name: 'sentencesAfter', + description: 'Number of sentences to fetch after the matched sentence. Defaults to 2.', + type: 'number', + default: 2, + additionalParams: true, + optional: true + }, + { + label: 'Lambda', + name: 'lambda', + description: + 'Improves retrieval accuracy by adjusting the balance (from 0 to 1) between neural search and keyword-based search factors.', + type: 'number', + additionalParams: true, + optional: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Defaults to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Vectara Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Vectara Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(VectaraStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const apiKey = getCredentialParam('apiKey', credentialData, nodeData) + const customerId = getCredentialParam('customerID', credentialData, nodeData) + const corpusId = getCredentialParam('corpusID', credentialData, nodeData).split(',') + + const docs = nodeData.inputs?.document as Document[] + const embeddings = {} as Embeddings + const vectaraMetadataFilter = nodeData.inputs?.filter as string + const sentencesBefore = nodeData.inputs?.sentencesBefore as number + const sentencesAfter = nodeData.inputs?.sentencesAfter as number + const lambda = nodeData.inputs?.lambda as number + const fileBase64 = nodeData.inputs?.file + + const vectaraArgs: VectaraLibArgs = { + apiKey: apiKey, + customerId: customerId, + corpusId: corpusId, + source: 'flowise' + } + + const vectaraFilter: VectaraFilter = {} + if (vectaraMetadataFilter) vectaraFilter.filter = vectaraMetadataFilter + if (lambda) vectaraFilter.lambda = lambda + + const vectaraContextConfig: VectaraContextConfig = {} + if (sentencesBefore) vectaraContextConfig.sentencesBefore = sentencesBefore + if (sentencesAfter) vectaraContextConfig.sentencesAfter = sentencesAfter + vectaraFilter.contextConfig = vectaraContextConfig + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + let files: string[] = [] + if (fileBase64.startsWith('[') && fileBase64.endsWith(']')) { + files = JSON.parse(fileBase64) + } else { + files = [fileBase64] + } + + const vectaraFiles: VectaraFile[] = [] + for (const file of files) { + const splitDataURI = file.split(',') + splitDataURI.pop() + const bf = Buffer.from(splitDataURI.pop() || '', 'base64') + const blob = new Blob([bf]) + vectaraFiles.push({ blob: blob, fileName: getFileName(file) }) + } + + try { + if (finalDocs.length) await VectaraStore.fromDocuments(finalDocs, embeddings, vectaraArgs) + if (vectaraFiles.length) { + const vectorStore = new VectaraStore(vectaraArgs) + await vectorStore.addFiles(vectaraFiles) + } + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const apiKey = getCredentialParam('apiKey', credentialData, nodeData) + const customerId = getCredentialParam('customerID', credentialData, nodeData) + const corpusId = getCredentialParam('corpusID', credentialData, nodeData).split(',') + + const vectaraMetadataFilter = nodeData.inputs?.filter as string + const sentencesBefore = nodeData.inputs?.sentencesBefore as number + const sentencesAfter = nodeData.inputs?.sentencesAfter as number + const lambda = nodeData.inputs?.lambda as number + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + const vectaraArgs: VectaraLibArgs = { + apiKey: apiKey, + customerId: customerId, + corpusId: corpusId, + source: 'flowise' + } + + const vectaraFilter: VectaraFilter = {} + if (vectaraMetadataFilter) vectaraFilter.filter = vectaraMetadataFilter + if (lambda) vectaraFilter.lambda = lambda + + const vectaraContextConfig: VectaraContextConfig = {} + if (sentencesBefore) vectaraContextConfig.sentencesBefore = sentencesBefore + if (sentencesAfter) vectaraContextConfig.sentencesAfter = sentencesAfter + vectaraFilter.contextConfig = vectaraContextConfig + + const vectorStore = new VectaraStore(vectaraArgs) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k, vectaraFilter) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +const getFileName = (fileBase64: string) => { + let fileNames = [] + if (fileBase64.startsWith('[') && fileBase64.endsWith(']')) { + const files = JSON.parse(fileBase64) + for (const file of files) { + const splitDataURI = file.split(',') + const filename = splitDataURI[splitDataURI.length - 1].split(':')[1] + fileNames.push(filename) + } + return fileNames.join(', ') + } else { + const splitDataURI = fileBase64.split(',') + const filename = splitDataURI[splitDataURI.length - 1].split(':')[1] + return filename + } +} + +module.exports = { nodeClass: Vectara_VectorStores } diff --git a/packages/components/nodes/vectorstores/Vectara/Vectara_Existing.ts b/packages/components/nodes/vectorstores/Vectara/Vectara_Existing.ts index 4448aa5c..dda6b8da 100644 --- a/packages/components/nodes/vectorstores/Vectara/Vectara_Existing.ts +++ b/packages/components/nodes/vectorstores/Vectara/Vectara_Existing.ts @@ -10,6 +10,7 @@ class VectaraExisting_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -24,6 +25,7 @@ class VectaraExisting_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from Vectara (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Vectara/Vectara_Upload.ts b/packages/components/nodes/vectorstores/Vectara/Vectara_Upload.ts index 39104b9d..0c1e6ef3 100644 --- a/packages/components/nodes/vectorstores/Vectara/Vectara_Upload.ts +++ b/packages/components/nodes/vectorstores/Vectara/Vectara_Upload.ts @@ -10,6 +10,7 @@ class VectaraUpload_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -24,6 +25,7 @@ class VectaraUpload_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upload files to Vectara' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Vectara/Vectara_Upsert.ts b/packages/components/nodes/vectorstores/Vectara/Vectara_Upsert.ts index 376668de..6ce2ffad 100644 --- a/packages/components/nodes/vectorstores/Vectara/Vectara_Upsert.ts +++ b/packages/components/nodes/vectorstores/Vectara/Vectara_Upsert.ts @@ -13,6 +13,7 @@ class VectaraUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -27,6 +28,7 @@ class VectaraUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Vectara' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Weaviate/Weaviate.ts b/packages/components/nodes/vectorstores/Weaviate/Weaviate.ts new file mode 100644 index 00000000..5c31c737 --- /dev/null +++ b/packages/components/nodes/vectorstores/Weaviate/Weaviate.ts @@ -0,0 +1,213 @@ +import { flatten } from 'lodash' +import weaviate, { WeaviateClient, ApiKey } from 'weaviate-ts-client' +import { WeaviateLibArgs, WeaviateStore } from 'langchain/vectorstores/weaviate' +import { Document } from 'langchain/document' +import { Embeddings } from 'langchain/embeddings/base' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class Weaviate_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Weaviate' + this.name = 'weaviate' + this.version = 1.0 + this.type = 'Weaviate' + this.icon = 'weaviate.png' + this.category = 'Vector Stores' + this.description = + 'Upsert embedded data and perform similarity search upon query using Weaviate, a scalable open-source vector database' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + description: 'Only needed when using Weaviate cloud hosted', + optional: true, + credentialNames: ['weaviateApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Weaviate Scheme', + name: 'weaviateScheme', + type: 'options', + default: 'https', + options: [ + { + label: 'https', + name: 'https' + }, + { + label: 'http', + name: 'http' + } + ] + }, + { + label: 'Weaviate Host', + name: 'weaviateHost', + type: 'string', + placeholder: 'localhost:8080' + }, + { + label: 'Weaviate Index', + name: 'weaviateIndex', + type: 'string', + placeholder: 'Test' + }, + { + label: 'Weaviate Text Key', + name: 'weaviateTextKey', + type: 'string', + placeholder: 'text', + optional: true, + additionalParams: true + }, + { + label: 'Weaviate Metadata Keys', + name: 'weaviateMetadataKeys', + type: 'string', + rows: 4, + placeholder: `["foo"]`, + optional: true, + additionalParams: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Weaviate Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Weaviate Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(WeaviateStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const weaviateScheme = nodeData.inputs?.weaviateScheme as string + const weaviateHost = nodeData.inputs?.weaviateHost as string + const weaviateIndex = nodeData.inputs?.weaviateIndex as string + const weaviateTextKey = nodeData.inputs?.weaviateTextKey as string + const weaviateMetadataKeys = nodeData.inputs?.weaviateMetadataKeys as string + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const weaviateApiKey = getCredentialParam('weaviateApiKey', credentialData, nodeData) + + const clientConfig: any = { + scheme: weaviateScheme, + host: weaviateHost + } + if (weaviateApiKey) clientConfig.apiKey = new ApiKey(weaviateApiKey) + + const client: WeaviateClient = weaviate.client(clientConfig) + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + const obj: WeaviateLibArgs = { + client, + indexName: weaviateIndex + } + + if (weaviateTextKey) obj.textKey = weaviateTextKey + if (weaviateMetadataKeys) obj.metadataKeys = JSON.parse(weaviateMetadataKeys.replace(/\s/g, '')) + + try { + await WeaviateStore.fromDocuments(finalDocs, embeddings, obj) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const weaviateScheme = nodeData.inputs?.weaviateScheme as string + const weaviateHost = nodeData.inputs?.weaviateHost as string + const weaviateIndex = nodeData.inputs?.weaviateIndex as string + const weaviateTextKey = nodeData.inputs?.weaviateTextKey as string + const weaviateMetadataKeys = nodeData.inputs?.weaviateMetadataKeys as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const weaviateApiKey = getCredentialParam('weaviateApiKey', credentialData, nodeData) + + const clientConfig: any = { + scheme: weaviateScheme, + host: weaviateHost + } + if (weaviateApiKey) clientConfig.apiKey = new ApiKey(weaviateApiKey) + + const client: WeaviateClient = weaviate.client(clientConfig) + + const obj: WeaviateLibArgs = { + client, + indexName: weaviateIndex + } + + if (weaviateTextKey) obj.textKey = weaviateTextKey + if (weaviateMetadataKeys) obj.metadataKeys = JSON.parse(weaviateMetadataKeys.replace(/\s/g, '')) + + const vectorStore = await WeaviateStore.fromExistingIndex(embeddings, obj) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +module.exports = { nodeClass: Weaviate_VectorStores } diff --git a/packages/components/nodes/vectorstores/Weaviate_Existing/Weaviate_Existing.ts b/packages/components/nodes/vectorstores/Weaviate/Weaviate_Existing.ts similarity index 99% rename from packages/components/nodes/vectorstores/Weaviate_Existing/Weaviate_Existing.ts rename to packages/components/nodes/vectorstores/Weaviate/Weaviate_Existing.ts index e35a3917..d11b351f 100644 --- a/packages/components/nodes/vectorstores/Weaviate_Existing/Weaviate_Existing.ts +++ b/packages/components/nodes/vectorstores/Weaviate/Weaviate_Existing.ts @@ -12,6 +12,7 @@ class Weaviate_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -26,6 +27,7 @@ class Weaviate_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from Weaviate (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Weaviate_Upsert/Weaviate_Upsert.ts b/packages/components/nodes/vectorstores/Weaviate/Weaviate_Upsert.ts similarity index 99% rename from packages/components/nodes/vectorstores/Weaviate_Upsert/Weaviate_Upsert.ts rename to packages/components/nodes/vectorstores/Weaviate/Weaviate_Upsert.ts index 0b7f2393..14adfabd 100644 --- a/packages/components/nodes/vectorstores/Weaviate_Upsert/Weaviate_Upsert.ts +++ b/packages/components/nodes/vectorstores/Weaviate/Weaviate_Upsert.ts @@ -14,6 +14,7 @@ class WeaviateUpsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -28,6 +29,7 @@ class WeaviateUpsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Weaviate' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Weaviate_Existing/weaviate.png b/packages/components/nodes/vectorstores/Weaviate/weaviate.png similarity index 100% rename from packages/components/nodes/vectorstores/Weaviate_Existing/weaviate.png rename to packages/components/nodes/vectorstores/Weaviate/weaviate.png diff --git a/packages/components/nodes/vectorstores/Weaviate_Upsert/weaviate.png b/packages/components/nodes/vectorstores/Weaviate_Upsert/weaviate.png deleted file mode 100644 index 25a39e33..00000000 Binary files a/packages/components/nodes/vectorstores/Weaviate_Upsert/weaviate.png and /dev/null differ diff --git a/packages/components/nodes/vectorstores/Zep/Zep.ts b/packages/components/nodes/vectorstores/Zep/Zep.ts new file mode 100644 index 00000000..21c885b4 --- /dev/null +++ b/packages/components/nodes/vectorstores/Zep/Zep.ts @@ -0,0 +1,282 @@ +import { flatten } from 'lodash' +import { IDocument, ZepClient } from '@getzep/zep-js' +import { ZepVectorStore, IZepConfig } from 'langchain/vectorstores/zep' +import { Embeddings } from 'langchain/embeddings/base' +import { Document } from 'langchain/document' +import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class Zep_VectorStores implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + badge: string + baseClasses: string[] + inputs: INodeParams[] + credential: INodeParams + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Zep' + this.name = 'zep' + this.version = 1.0 + this.type = 'Zep' + this.icon = 'zep.png' + this.category = 'Vector Stores' + this.description = + 'Upsert embedded data and perform similarity search upon query using Zep, a fast and scalable building block for LLM apps' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'NEW' + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + optional: true, + description: 'Configure JWT authentication on your Zep instance (Optional)', + credentialNames: ['zepMemoryApi'] + } + this.inputs = [ + { + label: 'Document', + name: 'document', + type: 'Document', + list: true, + optional: true + }, + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Base URL', + name: 'baseURL', + type: 'string', + default: 'http://127.0.0.1:8000' + }, + { + label: 'Zep Collection', + name: 'zepCollection', + type: 'string', + placeholder: 'my-first-collection' + }, + { + label: 'Zep Metadata Filter', + name: 'zepMetadataFilter', + type: 'json', + optional: true, + additionalParams: true + }, + { + label: 'Embedding Dimension', + name: 'dimension', + type: 'number', + default: 1536, + additionalParams: true + }, + { + label: 'Top K', + name: 'topK', + description: 'Number of top results to fetch. Default to 4', + placeholder: '4', + type: 'number', + additionalParams: true, + optional: true + } + ] + this.outputs = [ + { + label: 'Zep Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Zep Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(ZepVectorStore)] + } + ] + } + + //@ts-ignore + vectorStoreMethods = { + async upsert(nodeData: INodeData, options: ICommonObject): Promise { + const baseURL = nodeData.inputs?.baseURL as string + const zepCollection = nodeData.inputs?.zepCollection as string + const dimension = (nodeData.inputs?.dimension as number) ?? 1536 + const docs = nodeData.inputs?.document as Document[] + const embeddings = nodeData.inputs?.embeddings as Embeddings + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const apiKey = getCredentialParam('apiKey', credentialData, nodeData) + + const flattenDocs = docs && docs.length ? flatten(docs) : [] + const finalDocs = [] + for (let i = 0; i < flattenDocs.length; i += 1) { + if (flattenDocs[i] && flattenDocs[i].pageContent) { + finalDocs.push(new Document(flattenDocs[i])) + } + } + + const zepConfig: IZepConfig = { + apiUrl: baseURL, + collectionName: zepCollection, + embeddingDimensions: dimension, + isAutoEmbedded: false + } + if (apiKey) zepConfig.apiKey = apiKey + + try { + await ZepVectorStore.fromDocuments(finalDocs, embeddings, zepConfig) + } catch (e) { + throw new Error(e) + } + } + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const baseURL = nodeData.inputs?.baseURL as string + const zepCollection = nodeData.inputs?.zepCollection as string + const zepMetadataFilter = nodeData.inputs?.zepMetadataFilter + const dimension = nodeData.inputs?.dimension as number + const embeddings = nodeData.inputs?.embeddings as Embeddings + const output = nodeData.outputs?.output as string + const topK = nodeData.inputs?.topK as string + const k = topK ? parseFloat(topK) : 4 + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const apiKey = getCredentialParam('apiKey', credentialData, nodeData) + + const zepConfig: IZepConfig & Partial = { + apiUrl: baseURL, + collectionName: zepCollection, + embeddingDimensions: dimension, + isAutoEmbedded: false + } + if (apiKey) zepConfig.apiKey = apiKey + if (zepMetadataFilter) { + const metadatafilter = typeof zepMetadataFilter === 'object' ? zepMetadataFilter : JSON.parse(zepMetadataFilter) + zepConfig.filter = metadatafilter + } + + const vectorStore = await ZepExistingVS.fromExistingIndex(embeddings, zepConfig) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever(k) + return retriever + } else if (output === 'vectorStore') { + ;(vectorStore as any).k = k + return vectorStore + } + return vectorStore + } +} + +interface ZepFilter { + filter: Record +} + +function zepDocsToDocumentsAndScore(results: IDocument[]): [Document, number][] { + return results.map((d) => [ + new Document({ + pageContent: d.content, + metadata: d.metadata + }), + d.score ? d.score : 0 + ]) +} + +function assignMetadata(value: string | Record | object | undefined): Record | undefined { + if (typeof value === 'object' && value !== null) { + return value as Record + } + if (value !== undefined) { + console.warn('Metadata filters must be an object, Record, or undefined.') + } + return undefined +} + +class ZepExistingVS extends ZepVectorStore { + filter?: Record + args?: IZepConfig & Partial + + constructor(embeddings: Embeddings, args: IZepConfig & Partial) { + super(embeddings, args) + this.filter = args.filter + this.args = args + } + + async initalizeCollection(args: IZepConfig & Partial) { + this.client = await ZepClient.init(args.apiUrl, args.apiKey) + try { + this.collection = await this.client.document.getCollection(args.collectionName) + } catch (err) { + if (err instanceof Error) { + if (err.name === 'NotFoundError') { + await this.createNewCollection(args) + } else { + throw err + } + } + } + } + + async createNewCollection(args: IZepConfig & Partial) { + if (!args.embeddingDimensions) { + throw new Error( + `Collection ${args.collectionName} not found. You can create a new Collection by providing embeddingDimensions.` + ) + } + + this.collection = await this.client.document.addCollection({ + name: args.collectionName, + description: args.description, + metadata: args.metadata, + embeddingDimensions: args.embeddingDimensions, + isAutoEmbedded: false + }) + } + + async similaritySearchVectorWithScore( + query: number[], + k: number, + filter?: Record | undefined + ): Promise<[Document, number][]> { + if (filter && this.filter) { + throw new Error('cannot provide both `filter` and `this.filter`') + } + const _filters = filter ?? this.filter + const ANDFilters = [] + for (const filterKey in _filters) { + let filterVal = _filters[filterKey] + if (typeof filterVal === 'string') filterVal = `"${filterVal}"` + ANDFilters.push({ jsonpath: `$[*] ? (@.${filterKey} == ${filterVal})` }) + } + const newfilter = { + where: { and: ANDFilters } + } + await this.initalizeCollection(this.args!).catch((err) => { + console.error('Error initializing collection:', err) + throw err + }) + const results = await this.collection.search( + { + embedding: new Float32Array(query), + metadata: assignMetadata(newfilter) + }, + k + ) + return zepDocsToDocumentsAndScore(results) + } + + static async fromExistingIndex(embeddings: Embeddings, dbConfig: IZepConfig & Partial): Promise { + const instance = new this(embeddings, dbConfig) + return instance + } +} + +module.exports = { nodeClass: Zep_VectorStores } diff --git a/packages/components/nodes/vectorstores/Zep/Zep_Existing.ts b/packages/components/nodes/vectorstores/Zep/Zep_Existing.ts index 9be10c19..5e9d7e1f 100644 --- a/packages/components/nodes/vectorstores/Zep/Zep_Existing.ts +++ b/packages/components/nodes/vectorstores/Zep/Zep_Existing.ts @@ -13,6 +13,7 @@ class Zep_Existing_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -27,6 +28,7 @@ class Zep_Existing_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Load existing index from Zep (i.e: Document has been upserted)' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/nodes/vectorstores/Zep/Zep_Upsert.ts b/packages/components/nodes/vectorstores/Zep/Zep_Upsert.ts index 915513b9..40b08cbd 100644 --- a/packages/components/nodes/vectorstores/Zep/Zep_Upsert.ts +++ b/packages/components/nodes/vectorstores/Zep/Zep_Upsert.ts @@ -13,6 +13,7 @@ class Zep_Upsert_VectorStores implements INode { type: string icon: string category: string + badge: string baseClasses: string[] inputs: INodeParams[] credential: INodeParams @@ -27,6 +28,7 @@ class Zep_Upsert_VectorStores implements INode { this.category = 'Vector Stores' this.description = 'Upsert documents to Zep' this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.badge = 'DEPRECATING' this.credential = { label: 'Connect Credential', name: 'credential', diff --git a/packages/components/package.json b/packages/components/package.json index 8c7c6703..bb074392 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "flowise-components", - "version": "1.4.0-rc.1", + "version": "1.4.4", "description": "Flowiseai Components", "main": "dist/src/index", "types": "dist/src/index.d.ts", @@ -22,7 +22,8 @@ "@dqbd/tiktoken": "^1.0.7", "@elastic/elasticsearch": "^8.9.0", "@getzep/zep-js": "^0.6.3", - "@gomomento/sdk": "^1.40.2", + "@gomomento/sdk": "^1.51.1", + "@gomomento/sdk-core": "^1.51.1", "@google-ai/generativelanguage": "^0.2.1", "@huggingface/inference": "^2.6.1", "@notionhq/client": "^2.2.8", @@ -47,14 +48,16 @@ "google-auth-library": "^9.0.0", "graphql": "^16.6.0", "html-to-text": "^9.0.5", + "husky": "^8.0.3", "ioredis": "^5.3.2", - "langchain": "^0.0.165", - "langfuse-langchain": "^1.0.14-alpha.0", + "langchain": "^0.0.196", + "langfuse-langchain": "^1.0.31", "langsmith": "^0.0.32", "linkifyjs": "^4.1.1", "llmonitor": "^0.5.5", "mammoth": "^1.5.1", "moment": "^2.29.3", + "mongodb": "^6.2.0", "mysql2": "^3.5.1", "node-fetch": "^2.6.11", "node-html-markdown": "^1.3.0", @@ -81,6 +84,9 @@ "@types/object-hash": "^3.0.2", "@types/pg": "^8.10.2", "@types/ws": "^8.5.3", + "eslint-plugin-markdown": "^3.0.1", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-react-hooks": "^4.6.0", "gulp": "^4.0.2", "typescript": "^4.8.4" } diff --git a/packages/components/src/Interface.ts b/packages/components/src/Interface.ts index 15b98770..af304272 100644 --- a/packages/components/src/Interface.ts +++ b/packages/components/src/Interface.ts @@ -72,6 +72,7 @@ export interface INodeParams { fileType?: string additionalParams?: boolean loadMethod?: string + hidden?: boolean } export interface INodeExecutionData { @@ -92,6 +93,7 @@ export interface INodeProperties { baseClasses: string[] description?: string filePath?: string + badge?: string } export interface INode extends INodeProperties { @@ -100,6 +102,11 @@ export interface INode extends INodeProperties { loadMethods?: { [key: string]: (nodeData: INodeData, options?: ICommonObject) => Promise } + vectorStoreMethods?: { + upsert: (nodeData: INodeData, options?: ICommonObject) => Promise + search: (nodeData: INodeData, options?: ICommonObject) => Promise + delete: (nodeData: INodeData, options?: ICommonObject) => Promise + } init?(nodeData: INodeData, input: string, options?: ICommonObject): Promise run?(nodeData: INodeData, input: string, options?: ICommonObject): Promise clearSessionMemory?(nodeData: INodeData, options?: ICommonObject): Promise diff --git a/packages/components/src/handler.ts b/packages/components/src/handler.ts index 37075342..456cf39c 100644 --- a/packages/components/src/handler.ts +++ b/packages/components/src/handler.ts @@ -250,6 +250,7 @@ export const additionalCallbacks = async (nodeData: INodeData, options: ICommonO baseUrl: langFuseEndpoint ?? 'https://cloud.langfuse.com' } if (release) langFuseOptions.release = release + if (options.chatId) langFuseOptions.userId = options.chatId const handler = new CallbackHandler(langFuseOptions) callbacks.push(handler) diff --git a/packages/server/marketplaces/chatflows/API Agent OpenAI.json b/packages/server/marketplaces/chatflows/API Agent OpenAI.json index b2ff977b..0e9aa091 100644 --- a/packages/server/marketplaces/chatflows/API Agent OpenAI.json +++ b/packages/server/marketplaces/chatflows/API Agent OpenAI.json @@ -3,7 +3,7 @@ "nodes": [ { "width": 300, - "height": 510, + "height": 491, "id": "openApiChain_1", "position": { "x": 1203.1825726424859, @@ -13,8 +13,8 @@ "data": { "id": "openApiChain_1", "label": "OpenAPI Chain", - "name": "openApiChain", "version": 1, + "name": "openApiChain", "type": "OpenAPIChain", "baseClasses": ["OpenAPIChain", "BaseChain"], "category": "Chains", @@ -78,7 +78,7 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_1", "position": { "x": 792.3201947594027, @@ -88,8 +88,8 @@ "data": { "id": "chatOpenAI_1", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -199,6 +199,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_1-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-baseOptions-json" } ], "inputAnchors": [ @@ -218,7 +226,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -250,8 +259,8 @@ "data": { "id": "chainTool_0", "label": "Chain Tool", - "name": "chainTool", "version": 1, + "name": "chainTool", "type": "ChainTool", "baseClasses": ["ChainTool", "DynamicTool", "Tool", "StructuredTool"], "category": "Tools", @@ -324,8 +333,8 @@ "data": { "id": "openAIFunctionAgent_0", "label": "OpenAI Function Agent", + "version": 2, "name": "openAIFunctionAgent", - "version": 1, "type": "AgentExecutor", "baseClasses": ["AgentExecutor", "BaseChain"], "category": "Agents", @@ -356,11 +365,10 @@ "id": "openAIFunctionAgent_0-input-memory-BaseChatMemory" }, { - "label": "OpenAI Chat Model", + "label": "OpenAI/Azure Chat Model", "name": "model", - "description": "Only works with gpt-3.5-turbo-0613 and gpt-4-0613. Refer docs for more info", - "type": "BaseChatModel", - "id": "openAIFunctionAgent_0-input-model-BaseChatModel" + "type": "ChatOpenAI | AzureChatOpenAI", + "id": "openAIFunctionAgent_0-input-model-ChatOpenAI | AzureChatOpenAI" } ], "inputs": { @@ -389,7 +397,7 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_2", "position": { "x": 1645.450699499575, @@ -399,8 +407,8 @@ "data": { "id": "chatOpenAI_2", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -510,6 +518,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_2-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_2-input-baseOptions-json" } ], "inputAnchors": [ @@ -529,7 +545,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -561,8 +578,8 @@ "data": { "id": "bufferMemory_0", "label": "Buffer Memory", - "name": "bufferMemory", "version": 1, + "name": "bufferMemory", "type": "BufferMemory", "baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"], "category": "Memory", @@ -640,17 +657,6 @@ "label": "" } }, - { - "source": "chatOpenAI_2", - "sourceHandle": "chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-model-BaseChatModel", - "type": "buttonedge", - "id": "chatOpenAI_2-chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-openAIFunctionAgent_0-openAIFunctionAgent_0-input-model-BaseChatModel", - "data": { - "label": "" - } - }, { "source": "bufferMemory_0", "sourceHandle": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", @@ -661,6 +667,17 @@ "data": { "label": "" } + }, + { + "source": "chatOpenAI_2", + "sourceHandle": "chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", + "target": "openAIFunctionAgent_0", + "targetHandle": "openAIFunctionAgent_0-input-model-ChatOpenAI | AzureChatOpenAI", + "type": "buttonedge", + "id": "chatOpenAI_2-chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-openAIFunctionAgent_0-openAIFunctionAgent_0-input-model-ChatOpenAI | AzureChatOpenAI", + "data": { + "label": "" + } } ] } diff --git a/packages/server/marketplaces/chatflows/API Agent.json b/packages/server/marketplaces/chatflows/API Agent.json index c37aaff2..93270848 100644 --- a/packages/server/marketplaces/chatflows/API Agent.json +++ b/packages/server/marketplaces/chatflows/API Agent.json @@ -13,8 +13,8 @@ "data": { "id": "getApiChain_0", "label": "GET API Chain", - "name": "getApiChain", "version": 1, + "name": "getApiChain", "type": "GETApiChain", "baseClasses": ["GETApiChain", "BaseChain", "BaseLangChain"], "category": "Chains", @@ -24,7 +24,7 @@ "label": "API Documentation", "name": "apiDocs", "type": "string", - "description": "Description of how API works. Please refer to more examples", + "description": "Description of how API works. Please refer to more examples", "rows": 4, "id": "getApiChain_0-input-apiDocs-string" }, @@ -102,8 +102,8 @@ "data": { "id": "chainTool_0", "label": "Chain Tool", - "name": "chainTool", "version": 1, + "name": "chainTool", "type": "ChainTool", "baseClasses": ["ChainTool", "DynamicTool", "Tool", "StructuredTool", "BaseLangChain"], "category": "Tools", @@ -176,8 +176,8 @@ "data": { "id": "bufferMemory_0", "label": "Buffer Memory", - "name": "bufferMemory", "version": 1, + "name": "bufferMemory", "type": "BufferMemory", "baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"], "category": "Memory", @@ -233,8 +233,8 @@ "data": { "id": "chainTool_1", "label": "Chain Tool", - "name": "chainTool", "version": 1, + "name": "chainTool", "type": "ChainTool", "baseClasses": ["ChainTool", "DynamicTool", "Tool", "StructuredTool", "BaseLangChain"], "category": "Tools", @@ -307,8 +307,8 @@ "data": { "id": "postApiChain_0", "label": "POST API Chain", - "name": "postApiChain", "version": 1, + "name": "postApiChain", "type": "POSTApiChain", "baseClasses": ["POSTApiChain", "BaseChain", "BaseLangChain"], "category": "Chains", @@ -318,7 +318,7 @@ "label": "API Documentation", "name": "apiDocs", "type": "string", - "description": "Description of how API works. Please refer to more examples", + "description": "Description of how API works. Please refer to more examples", "rows": 4, "id": "postApiChain_0-input-apiDocs-string" }, @@ -386,7 +386,7 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_2", "position": { "x": 572.8941615312035, @@ -396,8 +396,8 @@ "data": { "id": "chatOpenAI_2", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -507,6 +507,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_2-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_2-input-baseOptions-json" } ], "inputAnchors": [ @@ -526,7 +534,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -548,7 +557,7 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_1", "position": { "x": 828.7788305309582, @@ -558,8 +567,8 @@ "data": { "id": "chatOpenAI_1", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -669,6 +678,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_1-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-baseOptions-json" } ], "inputAnchors": [ @@ -688,7 +705,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -710,7 +728,7 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_3", "position": { "x": 1148.338912314111, @@ -720,8 +738,8 @@ "data": { "id": "chatOpenAI_3", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -831,6 +849,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_3-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_3-input-baseOptions-json" } ], "inputAnchors": [ @@ -843,14 +869,15 @@ } ], "inputs": { - "modelName": "gpt-3.5-turbo", + "modelName": "gpt-3.5-turbo-16k", "temperature": 0.9, "maxTokens": "", "topP": "", "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -875,17 +902,17 @@ "height": 383, "id": "conversationalAgent_0", "position": { - "x": 2114.071431691489, - "y": 941.7926368551367 + "x": 2090.570467632979, + "y": 969.5131357270544 }, "type": "customNode", "data": { "id": "conversationalAgent_0", "label": "Conversational Agent", + "version": 2, "name": "conversationalAgent", - "version": 1, "type": "AgentExecutor", - "baseClasses": ["AgentExecutor", "BaseChain"], + "baseClasses": ["AgentExecutor", "BaseChain", "Runnable"], "category": "Agents", "description": "Conversational agent for a chat model. It will utilize chat specific prompts", "inputParams": [ @@ -911,8 +938,8 @@ { "label": "Language Model", "name": "model", - "type": "BaseLanguageModel", - "id": "conversationalAgent_0-input-model-BaseLanguageModel" + "type": "BaseChatModel", + "id": "conversationalAgent_0-input-model-BaseChatModel" }, { "label": "Memory", @@ -929,21 +956,21 @@ }, "outputAnchors": [ { - "id": "conversationalAgent_0-output-conversationalAgent-AgentExecutor|BaseChain", + "id": "conversationalAgent_0-output-conversationalAgent-AgentExecutor|BaseChain|Runnable", "name": "conversationalAgent", "label": "AgentExecutor", - "type": "AgentExecutor | BaseChain" + "type": "AgentExecutor | BaseChain | Runnable" } ], "outputs": {}, "selected": false }, "selected": false, - "dragging": false, "positionAbsolute": { - "x": 2114.071431691489, - "y": 941.7926368551367 - } + "x": 2090.570467632979, + "y": 969.5131357270544 + }, + "dragging": false } ], "edges": [ @@ -1017,9 +1044,9 @@ "source": "chatOpenAI_3", "sourceHandle": "chatOpenAI_3-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", "target": "conversationalAgent_0", - "targetHandle": "conversationalAgent_0-input-model-BaseLanguageModel", + "targetHandle": "conversationalAgent_0-input-model-BaseChatModel", "type": "buttonedge", - "id": "chatOpenAI_3-chatOpenAI_3-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalAgent_0-conversationalAgent_0-input-model-BaseLanguageModel", + "id": "chatOpenAI_3-chatOpenAI_3-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalAgent_0-conversationalAgent_0-input-model-BaseChatModel", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/Antonym.json b/packages/server/marketplaces/chatflows/Antonym.json index 059ab6c1..85cd5e4c 100644 --- a/packages/server/marketplaces/chatflows/Antonym.json +++ b/packages/server/marketplaces/chatflows/Antonym.json @@ -286,6 +286,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -305,7 +313,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { diff --git a/packages/server/marketplaces/chatflows/AutoGPT.json b/packages/server/marketplaces/chatflows/AutoGPT.json index 4fb706ab..150fe17e 100644 --- a/packages/server/marketplaces/chatflows/AutoGPT.json +++ b/packages/server/marketplaces/chatflows/AutoGPT.json @@ -13,8 +13,8 @@ "data": { "id": "autoGPT_0", "label": "AutoGPT", - "name": "autoGPT", "version": 1, + "name": "autoGPT", "type": "AutoGPT", "baseClasses": ["AutoGPT"], "category": "Agents", @@ -69,7 +69,7 @@ "inputs": { "tools": ["{{readFile_0.data.instance}}", "{{writeFile_1.data.instance}}", "{{serpAPI_0.data.instance}}"], "model": "{{chatOpenAI_0.data.instance}}", - "vectorStoreRetriever": "{{pineconeExistingIndex_0.data.instance}}", + "vectorStoreRetriever": "{{pinecone_0.data.instance}}", "aiName": "", "aiRole": "", "maxLoop": 5 @@ -104,8 +104,8 @@ "data": { "id": "writeFile_1", "label": "Write File", - "name": "writeFile", "version": 1, + "name": "writeFile", "type": "WriteFile", "baseClasses": ["WriteFile", "Tool", "StructuredTool", "BaseLangChain"], "category": "Tools", @@ -154,8 +154,8 @@ "data": { "id": "readFile_0", "label": "Read File", - "name": "readFile", "version": 1, + "name": "readFile", "type": "ReadFile", "baseClasses": ["ReadFile", "Tool", "StructuredTool", "BaseLangChain"], "category": "Tools", @@ -204,8 +204,8 @@ "data": { "id": "serpAPI_0", "label": "Serp API", - "name": "serpAPI", "version": 1, + "name": "serpAPI", "type": "SerpAPI", "baseClasses": ["SerpAPI", "Tool", "StructuredTool"], "category": "Tools", @@ -241,7 +241,7 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_0", "position": { "x": 176.69787776192283, @@ -251,8 +251,8 @@ "data": { "id": "chatOpenAI_0", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -362,6 +362,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -381,7 +389,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -413,8 +422,8 @@ "data": { "id": "openAIEmbeddings_0", "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", "version": 1, + "name": "openAIEmbeddings", "type": "OpenAIEmbeddings", "baseClasses": ["OpenAIEmbeddings", "Embeddings"], "category": "Embeddings", @@ -487,35 +496,35 @@ }, { "width": 300, - "height": 505, - "id": "pineconeExistingIndex_0", + "height": 555, + "id": "pinecone_0", "position": { - "x": 1001.3784758268554, - "y": 415.24072209485803 + "x": 1061.413729190394, + "y": 387.9611693492896 }, "type": "customNode", "data": { - "id": "pineconeExistingIndex_0", - "label": "Pinecone Load Existing Index", - "name": "pineconeExistingIndex", + "id": "pinecone_0", + "label": "Pinecone", "version": 1, + "name": "pinecone", "type": "Pinecone", "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], "category": "Vector Stores", - "description": "Load existing index from Pinecone (i.e: Document has been upserted)", + "description": "Upsert embedded data and perform similarity search upon query using Pinecone, a leading fully managed hosted vector database", "inputParams": [ { "label": "Connect Credential", "name": "credential", "type": "credential", "credentialNames": ["pineconeApi"], - "id": "pineconeExistingIndex_0-input-credential-credential" + "id": "pinecone_0-input-credential-credential" }, { "label": "Pinecone Index", "name": "pineconeIndex", "type": "string", - "id": "pineconeExistingIndex_0-input-pineconeIndex-string" + "id": "pinecone_0-input-pineconeIndex-string" }, { "label": "Pinecone Namespace", @@ -524,7 +533,7 @@ "placeholder": "my-first-namespace", "additionalParams": true, "optional": true, - "id": "pineconeExistingIndex_0-input-pineconeNamespace-string" + "id": "pinecone_0-input-pineconeNamespace-string" }, { "label": "Pinecone Metadata Filter", @@ -532,7 +541,7 @@ "type": "json", "optional": true, "additionalParams": true, - "id": "pineconeExistingIndex_0-input-pineconeMetadataFilter-json" + "id": "pinecone_0-input-pineconeMetadataFilter-json" }, { "label": "Top K", @@ -542,18 +551,27 @@ "type": "number", "additionalParams": true, "optional": true, - "id": "pineconeExistingIndex_0-input-topK-number" + "id": "pinecone_0-input-topK-number" } ], "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "pinecone_0-input-document-Document" + }, { "label": "Embeddings", "name": "embeddings", "type": "Embeddings", - "id": "pineconeExistingIndex_0-input-embeddings-Embeddings" + "id": "pinecone_0-input-embeddings-Embeddings" } ], "inputs": { + "document": "", "embeddings": "{{openAIEmbeddings_0.data.instance}}", "pineconeIndex": "", "pineconeNamespace": "", @@ -567,13 +585,13 @@ "type": "options", "options": [ { - "id": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "id": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", "name": "retriever", "label": "Pinecone Retriever", "type": "Pinecone | VectorStoreRetriever | BaseRetriever" }, { - "id": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", + "id": "pinecone_0-output-vectorStore-Pinecone|VectorStore", "name": "vectorStore", "label": "Pinecone Vector Store", "type": "Pinecone | VectorStore" @@ -588,11 +606,11 @@ "selected": false }, "selected": false, - "dragging": false, "positionAbsolute": { - "x": 1001.3784758268554, - "y": 415.24072209485803 - } + "x": 1061.413729190394, + "y": 387.9611693492896 + }, + "dragging": false } ], "edges": [ @@ -618,28 +636,6 @@ "label": "" } }, - { - "source": "pineconeExistingIndex_0", - "sourceHandle": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "target": "autoGPT_0", - "targetHandle": "autoGPT_0-input-vectorStoreRetriever-BaseRetriever", - "type": "buttonedge", - "id": "pineconeExistingIndex_0-pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-autoGPT_0-autoGPT_0-input-vectorStoreRetriever-BaseRetriever", - "data": { - "label": "" - } - }, - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeExistingIndex_0", - "targetHandle": "pineconeExistingIndex_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeExistingIndex_0-pineconeExistingIndex_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, { "source": "chatOpenAI_0", "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", @@ -661,6 +657,28 @@ "data": { "label": "" } + }, + { + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-embeddings-Embeddings", + "type": "buttonedge", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pinecone_0-pinecone_0-input-embeddings-Embeddings", + "data": { + "label": "" + } + }, + { + "source": "pinecone_0", + "sourceHandle": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "target": "autoGPT_0", + "targetHandle": "autoGPT_0-input-vectorStoreRetriever-BaseRetriever", + "type": "buttonedge", + "id": "pinecone_0-pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-autoGPT_0-autoGPT_0-input-vectorStoreRetriever-BaseRetriever", + "data": { + "label": "" + } } ] } diff --git a/packages/server/marketplaces/chatflows/BabyAGI.json b/packages/server/marketplaces/chatflows/BabyAGI.json index 04410b82..ab387205 100644 --- a/packages/server/marketplaces/chatflows/BabyAGI.json +++ b/packages/server/marketplaces/chatflows/BabyAGI.json @@ -13,8 +13,8 @@ "data": { "id": "babyAGI_1", "label": "BabyAGI", - "name": "babyAGI", "version": 1, + "name": "babyAGI", "type": "BabyAGI", "baseClasses": ["BabyAGI"], "category": "Agents", @@ -44,7 +44,7 @@ ], "inputs": { "model": "{{chatOpenAI_0.data.instance}}", - "vectorStore": "{{pineconeExistingIndex_0.data.instance}}", + "vectorStore": "{{pinecone_0.data.instance}}", "taskLoop": 3 }, "outputAnchors": [ @@ -65,168 +65,6 @@ "y": 66.00028106865324 } }, - { - "width": 300, - "height": 523, - "id": "chatOpenAI_0", - "position": { - "x": 587.1798180512677, - "y": -355.9845878719703 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_0", - "label": "ChatOpenAI", - "name": "chatOpenAI", - "version": 2, - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.9, - "optional": true, - "id": "chatOpenAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo", - "temperature": 0.9, - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 587.1798180512677, - "y": -355.9845878719703 - }, - "dragging": false - }, { "width": 300, "height": 329, @@ -239,8 +77,8 @@ "data": { "id": "openAIEmbeddings_0", "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", "version": 1, + "name": "openAIEmbeddings", "type": "OpenAIEmbeddings", "baseClasses": ["OpenAIEmbeddings", "Embeddings"], "category": "Embeddings", @@ -313,35 +151,35 @@ }, { "width": 300, - "height": 505, - "id": "pineconeExistingIndex_0", + "height": 555, + "id": "pinecone_0", "position": { - "x": 241.78764591331816, - "y": -38.438460915613945 + "x": 238.1350223788262, + "y": -133.38073692212225 }, "type": "customNode", "data": { - "id": "pineconeExistingIndex_0", - "label": "Pinecone Load Existing Index", - "name": "pineconeExistingIndex", + "id": "pinecone_0", + "label": "Pinecone", "version": 1, + "name": "pinecone", "type": "Pinecone", "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], "category": "Vector Stores", - "description": "Load existing index from Pinecone (i.e: Document has been upserted)", + "description": "Upsert embedded data and perform similarity search upon query using Pinecone, a leading fully managed hosted vector database", "inputParams": [ { "label": "Connect Credential", "name": "credential", "type": "credential", "credentialNames": ["pineconeApi"], - "id": "pineconeExistingIndex_0-input-credential-credential" + "id": "pinecone_0-input-credential-credential" }, { "label": "Pinecone Index", "name": "pineconeIndex", "type": "string", - "id": "pineconeExistingIndex_0-input-pineconeIndex-string" + "id": "pinecone_0-input-pineconeIndex-string" }, { "label": "Pinecone Namespace", @@ -350,7 +188,7 @@ "placeholder": "my-first-namespace", "additionalParams": true, "optional": true, - "id": "pineconeExistingIndex_0-input-pineconeNamespace-string" + "id": "pinecone_0-input-pineconeNamespace-string" }, { "label": "Pinecone Metadata Filter", @@ -358,7 +196,7 @@ "type": "json", "optional": true, "additionalParams": true, - "id": "pineconeExistingIndex_0-input-pineconeMetadataFilter-json" + "id": "pinecone_0-input-pineconeMetadataFilter-json" }, { "label": "Top K", @@ -368,20 +206,29 @@ "type": "number", "additionalParams": true, "optional": true, - "id": "pineconeExistingIndex_0-input-topK-number" + "id": "pinecone_0-input-topK-number" } ], "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "pinecone_0-input-document-Document" + }, { "label": "Embeddings", "name": "embeddings", "type": "Embeddings", - "id": "pineconeExistingIndex_0-input-embeddings-Embeddings" + "id": "pinecone_0-input-embeddings-Embeddings" } ], "inputs": { + "document": "", "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "pineconeIndex": "newindex", + "pineconeIndex": "", "pineconeNamespace": "", "pineconeMetadataFilter": "", "topK": "" @@ -393,13 +240,13 @@ "type": "options", "options": [ { - "id": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "id": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", "name": "retriever", "label": "Pinecone Retriever", "type": "Pinecone | VectorStoreRetriever | BaseRetriever" }, { - "id": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", + "id": "pinecone_0-output-vectorStore-Pinecone|VectorStore", "name": "vectorStore", "label": "Pinecone Vector Store", "type": "Pinecone | VectorStore" @@ -415,42 +262,232 @@ }, "selected": false, "positionAbsolute": { - "x": 241.78764591331816, - "y": -38.438460915613945 + "x": 238.1350223788262, + "y": -133.38073692212225 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_0", + "position": { + "x": 600.5963052289515, + "y": -359.24280496678995 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_0-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_0-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo", + "temperature": 0.9, + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 600.5963052289515, + "y": -359.24280496678995 }, "dragging": false } ], "edges": [ { - "source": "pineconeExistingIndex_0", - "sourceHandle": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", - "target": "babyAGI_1", - "targetHandle": "babyAGI_1-input-vectorStore-VectorStore", + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-embeddings-Embeddings", "type": "buttonedge", - "id": "pineconeExistingIndex_0-pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore-babyAGI_1-babyAGI_1-input-vectorStore-VectorStore", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pinecone_0-pinecone_0-input-embeddings-Embeddings", "data": { "label": "" } }, { "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", "target": "babyAGI_1", "targetHandle": "babyAGI_1-input-model-BaseChatModel", "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-babyAGI_1-babyAGI_1-input-model-BaseChatModel", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-babyAGI_1-babyAGI_1-input-model-BaseChatModel", "data": { "label": "" } }, { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeExistingIndex_0", - "targetHandle": "pineconeExistingIndex_0-input-embeddings-Embeddings", + "source": "pinecone_0", + "sourceHandle": "pinecone_0-output-vectorStore-Pinecone|VectorStore", + "target": "babyAGI_1", + "targetHandle": "babyAGI_1-input-vectorStore-VectorStore", "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeExistingIndex_0-pineconeExistingIndex_0-input-embeddings-Embeddings", + "id": "pinecone_0-pinecone_0-output-vectorStore-Pinecone|VectorStore-babyAGI_1-babyAGI_1-input-vectorStore-VectorStore", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/CSV Agent.json b/packages/server/marketplaces/chatflows/CSV Agent.json index 37764a53..61d97c4d 100644 --- a/packages/server/marketplaces/chatflows/CSV Agent.json +++ b/packages/server/marketplaces/chatflows/CSV Agent.json @@ -180,6 +180,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -199,7 +207,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { diff --git a/packages/server/marketplaces/chatflows/ChatGPTPlugin.json b/packages/server/marketplaces/chatflows/ChatGPTPlugin.json index 1f00ff5f..b8e2cf01 100644 --- a/packages/server/marketplaces/chatflows/ChatGPTPlugin.json +++ b/packages/server/marketplaces/chatflows/ChatGPTPlugin.json @@ -325,6 +325,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -344,7 +352,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { diff --git a/packages/server/marketplaces/chatflows/Claude LLM.json b/packages/server/marketplaces/chatflows/Claude LLM.json index b7989815..0ead3dd8 100644 --- a/packages/server/marketplaces/chatflows/Claude LLM.json +++ b/packages/server/marketplaces/chatflows/Claude LLM.json @@ -1,5 +1,5 @@ { - "description": "Use Anthropic Claude with 100k context window to ingest whole document for QnA", + "description": "Use Anthropic Claude with 200k context window to ingest whole document for QnA", "nodes": [ { "width": 300, @@ -148,7 +148,7 @@ "id": "chatAnthropic_0", "label": "ChatAnthropic", "name": "chatAnthropic", - "version": 2, + "version": 3, "type": "ChatAnthropic", "baseClasses": ["ChatAnthropic", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -171,6 +171,11 @@ "name": "claude-2", "description": "Claude 2 latest major version, automatically get updates to the model as they are released" }, + { + "label": "claude-2.1", + "name": "claude-2.1", + "description": "Claude 2 latest full version" + }, { "label": "claude-instant-1", "name": "claude-instant-1", @@ -268,7 +273,7 @@ } ], "inputs": { - "modelName": "claude-2", + "modelName": "claude-2.1", "temperature": 0.9, "maxTokensToSample": "", "topP": "", diff --git a/packages/server/marketplaces/chatflows/Conversational Agent.json b/packages/server/marketplaces/chatflows/Conversational Agent.json index d18f2ac0..8994594a 100644 --- a/packages/server/marketplaces/chatflows/Conversational Agent.json +++ b/packages/server/marketplaces/chatflows/Conversational Agent.json @@ -13,8 +13,8 @@ "data": { "id": "calculator_1", "label": "Calculator", - "name": "calculator", "version": 1, + "name": "calculator", "type": "Calculator", "baseClasses": ["Calculator", "Tool", "StructuredTool", "BaseLangChain"], "category": "Tools", @@ -52,8 +52,8 @@ "data": { "id": "bufferMemory_1", "label": "Buffer Memory", - "name": "bufferMemory", "version": 1, + "name": "bufferMemory", "type": "BufferMemory", "baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"], "category": "Memory", @@ -109,8 +109,8 @@ "data": { "id": "serpAPI_0", "label": "Serp API", - "name": "serpAPI", "version": 1, + "name": "serpAPI", "type": "SerpAPI", "baseClasses": ["SerpAPI", "Tool", "StructuredTool"], "category": "Tools", @@ -146,7 +146,7 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_0", "position": { "x": 97.01321406237057, @@ -156,8 +156,8 @@ "data": { "id": "chatOpenAI_0", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -267,6 +267,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -279,14 +287,15 @@ } ], "inputs": { - "modelName": "gpt-3.5-turbo", + "modelName": "gpt-3.5-turbo-16k", "temperature": 0.9, "maxTokens": "", "topP": "", "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -311,17 +320,17 @@ "height": 383, "id": "conversationalAgent_0", "position": { - "x": 1164.4550359451973, - "y": 283.40041124403075 + "x": 1191.1524476753796, + "y": 324.2479396683294 }, "type": "customNode", "data": { "id": "conversationalAgent_0", "label": "Conversational Agent", + "version": 2, "name": "conversationalAgent", - "version": 1, "type": "AgentExecutor", - "baseClasses": ["AgentExecutor", "BaseChain"], + "baseClasses": ["AgentExecutor", "BaseChain", "Runnable"], "category": "Agents", "description": "Conversational agent for a chat model. It will utilize chat specific prompts", "inputParams": [ @@ -347,8 +356,8 @@ { "label": "Language Model", "name": "model", - "type": "BaseLanguageModel", - "id": "conversationalAgent_0-input-model-BaseLanguageModel" + "type": "BaseChatModel", + "id": "conversationalAgent_0-input-model-BaseChatModel" }, { "label": "Memory", @@ -365,10 +374,10 @@ }, "outputAnchors": [ { - "id": "conversationalAgent_0-output-conversationalAgent-AgentExecutor|BaseChain", + "id": "conversationalAgent_0-output-conversationalAgent-AgentExecutor|BaseChain|Runnable", "name": "conversationalAgent", "label": "AgentExecutor", - "type": "AgentExecutor | BaseChain" + "type": "AgentExecutor | BaseChain | Runnable" } ], "outputs": {}, @@ -376,8 +385,8 @@ }, "selected": false, "positionAbsolute": { - "x": 1164.4550359451973, - "y": 283.40041124403075 + "x": 1191.1524476753796, + "y": 324.2479396683294 }, "dragging": false } @@ -409,9 +418,9 @@ "source": "chatOpenAI_0", "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", "target": "conversationalAgent_0", - "targetHandle": "conversationalAgent_0-input-model-BaseLanguageModel", + "targetHandle": "conversationalAgent_0-input-model-BaseChatModel", "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalAgent_0-conversationalAgent_0-input-model-BaseLanguageModel", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalAgent_0-conversationalAgent_0-input-model-BaseChatModel", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/Conversational Retrieval Agent.json b/packages/server/marketplaces/chatflows/Conversational Retrieval Agent.json index ede7215d..68618a63 100644 --- a/packages/server/marketplaces/chatflows/Conversational Retrieval Agent.json +++ b/packages/server/marketplaces/chatflows/Conversational Retrieval Agent.json @@ -2,168 +2,6 @@ "description": "Agent optimized for vector retrieval during conversation and answering questions based on previous dialogue.", "badge": "POPULAR", "nodes": [ - { - "width": 300, - "height": 523, - "id": "chatOpenAI_0", - "position": { - "x": 1381.867549919116, - "y": 212.76900895393834 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_0", - "label": "ChatOpenAI", - "version": 2, - "name": "chatOpenAI", - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.9, - "optional": true, - "id": "chatOpenAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo-16k", - "temperature": "0", - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1381.867549919116, - "y": 212.76900895393834 - }, - "dragging": false - }, { "width": 300, "height": 329, @@ -248,115 +86,6 @@ }, "dragging": false }, - { - "width": 300, - "height": 505, - "id": "pineconeExistingIndex_0", - "position": { - "x": 1362.0018461011314, - "y": -334.0373537488481 - }, - "type": "customNode", - "data": { - "id": "pineconeExistingIndex_0", - "label": "Pinecone Load Existing Index", - "version": 1, - "name": "pineconeExistingIndex", - "type": "Pinecone", - "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Load existing index from Pinecone (i.e: Document has been upserted)", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["pineconeApi"], - "id": "pineconeExistingIndex_0-input-credential-credential" - }, - { - "label": "Pinecone Index", - "name": "pineconeIndex", - "type": "string", - "id": "pineconeExistingIndex_0-input-pineconeIndex-string" - }, - { - "label": "Pinecone Namespace", - "name": "pineconeNamespace", - "type": "string", - "placeholder": "my-first-namespace", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-pineconeNamespace-string" - }, - { - "label": "Pinecone Metadata Filter", - "name": "pineconeMetadataFilter", - "type": "json", - "optional": true, - "additionalParams": true, - "id": "pineconeExistingIndex_0-input-pineconeMetadataFilter-json" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "pineconeExistingIndex_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "pineconeIndex": "newindex", - "pineconeNamespace": "", - "pineconeMetadataFilter": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Pinecone Retriever", - "type": "Pinecone | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", - "name": "vectorStore", - "label": "Pinecone Vector Store", - "type": "Pinecone | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "retriever" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1362.0018461011314, - "y": -334.0373537488481 - }, - "dragging": false - }, { "width": 300, "height": 383, @@ -369,7 +98,7 @@ "data": { "id": "conversationalRetrievalAgent_0", "label": "Conversational Retrieval Agent", - "version": 1, + "version": 2, "name": "conversationalRetrievalAgent", "type": "AgentExecutor", "baseClasses": ["AgentExecutor", "BaseChain", "Runnable"], @@ -401,10 +130,10 @@ "id": "conversationalRetrievalAgent_0-input-memory-BaseChatMemory" }, { - "label": "OpenAI Chat Model", + "label": "OpenAI/Azure Chat Model", "name": "model", - "type": "ChatOpenAI", - "id": "conversationalRetrievalAgent_0-input-model-ChatOpenAI" + "type": "ChatOpenAI | AzureChatOpenAI", + "id": "conversationalRetrievalAgent_0-input-model-ChatOpenAI | AzureChatOpenAI" } ], "inputs": { @@ -478,7 +207,7 @@ "inputs": { "name": "search_website", "description": "Searches and return documents regarding Jane - a culinary institution that offers top quality coffee, pastries, breakfast, lunch, and a variety of baked goods. They have multiple locations, including Jane on Fillmore, Jane on Larkin, Jane the Bakery, Toy Boat By Jane, and Little Jane on Grant. They emphasize healthy eating with a focus on flavor and quality ingredients. They bake everything in-house and work with local suppliers to source ingredients directly from farmers. They also offer catering services and delivery options.", - "retriever": "{{pineconeExistingIndex_0.data.instance}}" + "retriever": "{{pinecone_0.data.instance}}" }, "outputAnchors": [ { @@ -554,31 +283,317 @@ "y": 216.94151328212496 }, "dragging": false + }, + { + "width": 300, + "height": 555, + "id": "pinecone_0", + "position": { + "x": 1376.1277183738853, + "y": -366.1202264629863 + }, + "type": "customNode", + "data": { + "id": "pinecone_0", + "label": "Pinecone", + "version": 1, + "name": "pinecone", + "type": "Pinecone", + "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Pinecone, a leading fully managed hosted vector database", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["pineconeApi"], + "id": "pinecone_0-input-credential-credential" + }, + { + "label": "Pinecone Index", + "name": "pineconeIndex", + "type": "string", + "id": "pinecone_0-input-pineconeIndex-string" + }, + { + "label": "Pinecone Namespace", + "name": "pineconeNamespace", + "type": "string", + "placeholder": "my-first-namespace", + "additionalParams": true, + "optional": true, + "id": "pinecone_0-input-pineconeNamespace-string" + }, + { + "label": "Pinecone Metadata Filter", + "name": "pineconeMetadataFilter", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "pinecone_0-input-pineconeMetadataFilter-json" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Default to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "pinecone_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "pinecone_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "pinecone_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": "", + "embeddings": "{{openAIEmbeddings_0.data.instance}}", + "pineconeIndex": "", + "pineconeNamespace": "", + "pineconeMetadataFilter": "", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Pinecone Retriever", + "type": "Pinecone | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "pinecone_0-output-vectorStore-Pinecone|VectorStore", + "name": "vectorStore", + "label": "Pinecone Vector Store", + "type": "Pinecone | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "retriever" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1376.1277183738853, + "y": -366.1202264629863 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_0", + "position": { + "x": 1379.1468417698134, + "y": 220.8323181063672 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_0-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_0-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo-16k", + "temperature": 0.9, + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1379.1468417698134, + "y": 220.8323181063672 + }, + "dragging": false } ], "edges": [ - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeExistingIndex_0", - "targetHandle": "pineconeExistingIndex_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeExistingIndex_0-pineconeExistingIndex_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, - { - "source": "pineconeExistingIndex_0", - "sourceHandle": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "target": "retrieverTool_0", - "targetHandle": "retrieverTool_0-input-retriever-BaseRetriever", - "type": "buttonedge", - "id": "pineconeExistingIndex_0-pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-retrieverTool_0-retrieverTool_0-input-retriever-BaseRetriever", - "data": { - "label": "" - } - }, { "source": "retrieverTool_0", "sourceHandle": "retrieverTool_0-output-retrieverTool-RetrieverTool|DynamicTool|Tool|StructuredTool|Runnable", @@ -590,17 +605,6 @@ "label": "" } }, - { - "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "conversationalRetrievalAgent_0", - "targetHandle": "conversationalRetrievalAgent_0-input-model-ChatOpenAI", - "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalRetrievalAgent_0-conversationalRetrievalAgent_0-input-model-ChatOpenAI", - "data": { - "label": "" - } - }, { "source": "bufferMemory_0", "sourceHandle": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", @@ -611,6 +615,39 @@ "data": { "label": "" } + }, + { + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-embeddings-Embeddings", + "type": "buttonedge", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pinecone_0-pinecone_0-input-embeddings-Embeddings", + "data": { + "label": "" + } + }, + { + "source": "pinecone_0", + "sourceHandle": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "target": "retrieverTool_0", + "targetHandle": "retrieverTool_0-input-retriever-BaseRetriever", + "type": "buttonedge", + "id": "pinecone_0-pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-retrieverTool_0-retrieverTool_0-input-retriever-BaseRetriever", + "data": { + "label": "" + } + }, + { + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "conversationalRetrievalAgent_0", + "targetHandle": "conversationalRetrievalAgent_0-input-model-ChatOpenAI | AzureChatOpenAI", + "type": "buttonedge", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationalRetrievalAgent_0-conversationalRetrievalAgent_0-input-model-ChatOpenAI | AzureChatOpenAI", + "data": { + "label": "" + } } ] } diff --git a/packages/server/marketplaces/chatflows/Conversational Retrieval QA Chain.json b/packages/server/marketplaces/chatflows/Conversational Retrieval QA Chain.json index ba6c90b7..5c55d833 100644 --- a/packages/server/marketplaces/chatflows/Conversational Retrieval QA Chain.json +++ b/packages/server/marketplaces/chatflows/Conversational Retrieval QA Chain.json @@ -4,169 +4,7 @@ "nodes": [ { "width": 300, - "height": 522, - "id": "chatOpenAI_0", - "position": { - "x": 1184.1176114500388, - "y": -74.15535835370571 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_0", - "label": "ChatOpenAI", - "name": "chatOpenAI", - "version": 2, - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.9, - "optional": true, - "id": "chatOpenAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo", - "temperature": "0", - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel" - } - ], - "outputs": {}, - "selected": false - }, - "positionAbsolute": { - "x": 1184.1176114500388, - "y": -74.15535835370571 - }, - "selected": false, - "dragging": false - }, - { - "width": 300, - "height": 328, + "height": 329, "id": "openAIEmbeddings_0", "position": { "x": 795.6162477805387, @@ -176,8 +14,8 @@ "data": { "id": "openAIEmbeddings_0", "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", "version": 1, + "name": "openAIEmbeddings", "type": "OpenAIEmbeddings", "baseClasses": ["OpenAIEmbeddings", "Embeddings"], "category": "Embeddings", @@ -250,115 +88,7 @@ }, { "width": 300, - "height": 554, - "id": "pineconeUpsert_0", - "position": { - "x": 1191.1792786926865, - "y": 514.2126330994578 - }, - "type": "customNode", - "data": { - "id": "pineconeUpsert_0", - "label": "Pinecone Upsert Document", - "name": "pineconeUpsert", - "version": 1, - "type": "Pinecone", - "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Upsert documents to Pinecone", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["pineconeApi"], - "id": "pineconeUpsert_0-input-credential-credential" - }, - { - "label": "Pinecone Index", - "name": "pineconeIndex", - "type": "string", - "id": "pineconeUpsert_0-input-pineconeIndex-string" - }, - { - "label": "Pinecone Namespace", - "name": "pineconeNamespace", - "type": "string", - "placeholder": "my-first-namespace", - "additionalParams": true, - "optional": true, - "id": "pineconeUpsert_0-input-pineconeNamespace-string" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pineconeUpsert_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Document", - "name": "document", - "type": "Document", - "list": true, - "id": "pineconeUpsert_0-input-document-Document" - }, - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "pineconeUpsert_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "document": ["{{textFile_0.data.instance}}"], - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "pineconeIndex": "", - "pineconeNamespace": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "pineconeUpsert_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Pinecone Retriever", - "type": "Pinecone | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "pineconeUpsert_0-output-vectorStore-Pinecone|VectorStore", - "name": "vectorStore", - "label": "Pinecone Vector Store", - "type": "Pinecone | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "retriever" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1191.1792786926865, - "y": 514.2126330994578 - }, - "dragging": false - }, - { - "width": 300, - "height": 376, + "height": 429, "id": "recursiveCharacterTextSplitter_0", "position": { "x": 406.08456707531263, @@ -368,8 +98,8 @@ "data": { "id": "recursiveCharacterTextSplitter_0", "label": "Recursive Character Text Splitter", - "name": "recursiveCharacterTextSplitter", "version": 2, + "name": "recursiveCharacterTextSplitter", "type": "RecursiveCharacterTextSplitter", "baseClasses": ["RecursiveCharacterTextSplitter", "TextSplitter"], "category": "Text Splitters", @@ -427,7 +157,7 @@ }, { "width": 300, - "height": 410, + "height": 419, "id": "textFile_0", "position": { "x": 786.5497697231324, @@ -437,8 +167,8 @@ "data": { "id": "textFile_0", "label": "Text File", - "name": "textFile", "version": 3, + "name": "textFile", "type": "Document", "baseClasses": ["Document"], "category": "Document Loaders", @@ -509,7 +239,7 @@ }, { "width": 300, - "height": 479, + "height": 480, "id": "conversationalRetrievalQAChain_0", "position": { "x": 1558.6564094656787, @@ -519,8 +249,8 @@ "data": { "id": "conversationalRetrievalQAChain_0", "label": "Conversational Retrieval QA Chain", - "name": "conversationalRetrievalQAChain", "version": 1, + "name": "conversationalRetrievalQAChain", "type": "ConversationalRetrievalQAChain", "baseClasses": ["ConversationalRetrievalQAChain", "BaseChain"], "category": "Chains", @@ -593,7 +323,7 @@ ], "inputs": { "model": "{{chatOpenAI_0.data.instance}}", - "vectorStoreRetriever": "{{pineconeUpsert_0.data.instance}}", + "vectorStoreRetriever": "{{pinecone_0.data.instance}}", "memory": "", "returnSourceDocuments": "", "systemMessagePrompt": "", @@ -615,20 +345,317 @@ "y": 386.60217819991124 }, "selected": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_0", + "position": { + "x": 1194.3554779412727, + "y": -46.74877201166788 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_0-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_0-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo-16k", + "temperature": 0.9, + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1194.3554779412727, + "y": -46.74877201166788 + }, + "dragging": false + }, + { + "width": 300, + "height": 555, + "id": "pinecone_0", + "position": { + "x": 1192.4771449209463, + "y": 552.43946147251 + }, + "type": "customNode", + "data": { + "id": "pinecone_0", + "label": "Pinecone", + "version": 1, + "name": "pinecone", + "type": "Pinecone", + "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Pinecone, a leading fully managed hosted vector database", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["pineconeApi"], + "id": "pinecone_0-input-credential-credential" + }, + { + "label": "Pinecone Index", + "name": "pineconeIndex", + "type": "string", + "id": "pinecone_0-input-pineconeIndex-string" + }, + { + "label": "Pinecone Namespace", + "name": "pineconeNamespace", + "type": "string", + "placeholder": "my-first-namespace", + "additionalParams": true, + "optional": true, + "id": "pinecone_0-input-pineconeNamespace-string" + }, + { + "label": "Pinecone Metadata Filter", + "name": "pineconeMetadataFilter", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "pinecone_0-input-pineconeMetadataFilter-json" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Default to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "pinecone_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "pinecone_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "pinecone_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": ["{{textFile_0.data.instance}}"], + "embeddings": "{{openAIEmbeddings_0.data.instance}}", + "pineconeIndex": "", + "pineconeNamespace": "", + "pineconeMetadataFilter": "", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Pinecone Retriever", + "type": "Pinecone | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "pinecone_0-output-vectorStore-Pinecone|VectorStore", + "name": "vectorStore", + "label": "Pinecone Vector Store", + "type": "Pinecone | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "retriever" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1192.4771449209463, + "y": 552.43946147251 + }, + "dragging": false } ], "edges": [ - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeUpsert_0", - "targetHandle": "pineconeUpsert_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeUpsert_0-pineconeUpsert_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, { "source": "recursiveCharacterTextSplitter_0", "sourceHandle": "recursiveCharacterTextSplitter_0-output-recursiveCharacterTextSplitter-RecursiveCharacterTextSplitter|TextSplitter", @@ -642,33 +669,44 @@ }, { "source": "textFile_0", - "sourceHandle": "textFile_0-output-textFile-Document", - "target": "pineconeUpsert_0", - "targetHandle": "pineconeUpsert_0-input-document-Document", + "sourceHandle": "textFile_0-output-document-Document", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-document-Document", "type": "buttonedge", - "id": "textFile_0-textFile_0-output-textFile-Document-pineconeUpsert_0-pineconeUpsert_0-input-document-Document", + "id": "textFile_0-textFile_0-output-document-Document-pinecone_0-pinecone_0-input-document-Document", + "data": { + "label": "" + } + }, + { + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-embeddings-Embeddings", + "type": "buttonedge", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pinecone_0-pinecone_0-input-embeddings-Embeddings", + "data": { + "label": "" + } + }, + { + "source": "pinecone_0", + "sourceHandle": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "target": "conversationalRetrievalQAChain_0", + "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "type": "buttonedge", + "id": "pinecone_0-pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", "data": { "label": "" } }, { "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", "target": "conversationalRetrievalQAChain_0", "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "data": { - "label": "" - } - }, - { - "source": "pineconeUpsert_0", - "sourceHandle": "pineconeUpsert_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "type": "buttonedge", - "id": "pineconeUpsert_0-pineconeUpsert_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/Flowise Docs QnA.json b/packages/server/marketplaces/chatflows/Flowise Docs QnA.json index 31a7df07..ac84cf56 100644 --- a/packages/server/marketplaces/chatflows/Flowise Docs QnA.json +++ b/packages/server/marketplaces/chatflows/Flowise Docs QnA.json @@ -497,6 +497,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -516,7 +524,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { diff --git a/packages/server/marketplaces/chatflows/Image Generation.json b/packages/server/marketplaces/chatflows/Image Generation.json new file mode 100644 index 00000000..98d12238 --- /dev/null +++ b/packages/server/marketplaces/chatflows/Image Generation.json @@ -0,0 +1,671 @@ +{ + "description": "Generate image using Replicate Stability text-to-image generative AI model", + "badge": "NEW", + "nodes": [ + { + "width": 300, + "height": 475, + "id": "promptTemplate_0", + "position": { + "x": 366.28009688480114, + "y": 183.05394484895152 + }, + "type": "customNode", + "data": { + "id": "promptTemplate_0", + "label": "Prompt Template", + "version": 1, + "name": "promptTemplate", + "type": "PromptTemplate", + "baseClasses": ["PromptTemplate", "BaseStringPromptTemplate", "BasePromptTemplate"], + "category": "Prompts", + "description": "Schema to represent a basic prompt for an LLM", + "inputParams": [ + { + "label": "Template", + "name": "template", + "type": "string", + "rows": 4, + "placeholder": "What is a good name for a company that makes {product}?", + "id": "promptTemplate_0-input-template-string" + }, + { + "label": "Format Prompt Values", + "name": "promptValues", + "type": "json", + "optional": true, + "acceptVariable": true, + "list": true, + "id": "promptTemplate_0-input-promptValues-json" + } + ], + "inputAnchors": [], + "inputs": { + "template": "{query}", + "promptValues": "{\"query\":\"{{question}}\"}" + }, + "outputAnchors": [ + { + "id": "promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate", + "name": "promptTemplate", + "label": "PromptTemplate", + "type": "PromptTemplate | BaseStringPromptTemplate | BasePromptTemplate" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 366.28009688480114, + "y": 183.05394484895152 + }, + "dragging": false + }, + { + "width": 300, + "height": 475, + "id": "promptTemplate_1", + "position": { + "x": 1391.1872909364881, + "y": 274.0360952991433 + }, + "type": "customNode", + "data": { + "id": "promptTemplate_1", + "label": "Prompt Template", + "version": 1, + "name": "promptTemplate", + "type": "PromptTemplate", + "baseClasses": ["PromptTemplate", "BaseStringPromptTemplate", "BasePromptTemplate", "Runnable"], + "category": "Prompts", + "description": "Schema to represent a basic prompt for an LLM", + "inputParams": [ + { + "label": "Template", + "name": "template", + "type": "string", + "rows": 4, + "placeholder": "What is a good name for a company that makes {product}?", + "id": "promptTemplate_1-input-template-string" + }, + { + "label": "Format Prompt Values", + "name": "promptValues", + "type": "json", + "optional": true, + "acceptVariable": true, + "list": true, + "id": "promptTemplate_1-input-promptValues-json" + } + ], + "inputAnchors": [], + "inputs": { + "template": "Reply with nothing else but the following:\n![]({text})", + "promptValues": "{\"text\":\"{{llmChain_0.data.instance}}\"}" + }, + "outputAnchors": [ + { + "id": "promptTemplate_1-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate|Runnable", + "name": "promptTemplate", + "label": "PromptTemplate", + "type": "PromptTemplate | BaseStringPromptTemplate | BasePromptTemplate | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1391.1872909364881, + "y": 274.0360952991433 + }, + "dragging": false + }, + { + "width": 300, + "height": 577, + "id": "replicate_0", + "position": { + "x": 700.5657822436667, + "y": -192.57827891379952 + }, + "type": "customNode", + "data": { + "id": "replicate_0", + "label": "Replicate", + "version": 2, + "name": "replicate", + "type": "Replicate", + "baseClasses": ["Replicate", "BaseChatModel", "LLM", "BaseLLM", "BaseLanguageModel", "Runnable"], + "category": "LLMs", + "description": "Use Replicate to run open source models on cloud", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["replicateApi"], + "id": "replicate_0-input-credential-credential" + }, + { + "label": "Model", + "name": "model", + "type": "string", + "placeholder": "a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5", + "optional": true, + "id": "replicate_0-input-model-string" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "description": "Adjusts randomness of outputs, greater than 1 is random and 0 is deterministic, 0.75 is a good starting value.", + "default": 0.7, + "optional": true, + "id": "replicate_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "description": "Maximum number of tokens to generate. A word is generally 2-3 tokens", + "optional": true, + "additionalParams": true, + "id": "replicate_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "description": "When decoding text, samples from the top p percentage of most likely tokens; lower to ignore less likely tokens", + "optional": true, + "additionalParams": true, + "id": "replicate_0-input-topP-number" + }, + { + "label": "Repetition Penalty", + "name": "repetitionPenalty", + "type": "number", + "step": 0.1, + "description": "Penalty for repeated words in generated text; 1 is no penalty, values greater than 1 discourage repetition, less than 1 encourage it. (minimum: 0.01; maximum: 5)", + "optional": true, + "additionalParams": true, + "id": "replicate_0-input-repetitionPenalty-number" + }, + { + "label": "Additional Inputs", + "name": "additionalInputs", + "type": "json", + "description": "Each model has different parameters, refer to the specific model accepted inputs. For example: llama13b-v2", + "additionalParams": true, + "optional": true, + "id": "replicate_0-input-additionalInputs-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "replicate_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "model": "stability-ai/sdxl:af1a68a271597604546c09c64aabcd7782c114a63539a4a8d14d1eeda5630c33", + "temperature": 0.7, + "maxTokens": "", + "topP": "", + "repetitionPenalty": "", + "additionalInputs": "" + }, + "outputAnchors": [ + { + "id": "replicate_0-output-replicate-Replicate|BaseChatModel|LLM|BaseLLM|BaseLanguageModel|Runnable", + "name": "replicate", + "label": "Replicate", + "type": "Replicate | BaseChatModel | LLM | BaseLLM | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 700.5657822436667, + "y": -192.57827891379952 + }, + "dragging": false + }, + { + "width": 300, + "height": 456, + "id": "llmChain_0", + "position": { + "x": 1045.7783277092838, + "y": 242.08205161173464 + }, + "type": "customNode", + "data": { + "id": "llmChain_0", + "label": "LLM Chain", + "version": 3, + "name": "llmChain", + "type": "LLMChain", + "baseClasses": ["LLMChain", "BaseChain", "Runnable"], + "category": "Chains", + "description": "Chain to run queries against LLMs", + "inputParams": [ + { + "label": "Chain Name", + "name": "chainName", + "type": "string", + "placeholder": "Name Your Chain", + "optional": true, + "id": "llmChain_0-input-chainName-string" + } + ], + "inputAnchors": [ + { + "label": "Language Model", + "name": "model", + "type": "BaseLanguageModel", + "id": "llmChain_0-input-model-BaseLanguageModel" + }, + { + "label": "Prompt", + "name": "prompt", + "type": "BasePromptTemplate", + "id": "llmChain_0-input-prompt-BasePromptTemplate" + }, + { + "label": "Output Parser", + "name": "outputParser", + "type": "BaseLLMOutputParser", + "optional": true, + "id": "llmChain_0-input-outputParser-BaseLLMOutputParser" + } + ], + "inputs": { + "model": "{{replicate_0.data.instance}}", + "prompt": "{{promptTemplate_0.data.instance}}", + "outputParser": "", + "chainName": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "llmChain_0-output-llmChain-LLMChain|BaseChain|Runnable", + "name": "llmChain", + "label": "LLM Chain", + "type": "LLMChain | BaseChain | Runnable" + }, + { + "id": "llmChain_0-output-outputPrediction-string|json", + "name": "outputPrediction", + "label": "Output Prediction", + "type": "string | json" + } + ], + "default": "llmChain" + } + ], + "outputs": { + "output": "outputPrediction" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1045.7783277092838, + "y": 242.08205161173464 + }, + "dragging": false + }, + { + "width": 300, + "height": 456, + "id": "llmChain_1", + "position": { + "x": 1769.7463380379868, + "y": 194.56291579865376 + }, + "type": "customNode", + "data": { + "id": "llmChain_1", + "label": "LLM Chain", + "version": 3, + "name": "llmChain", + "type": "LLMChain", + "baseClasses": ["LLMChain", "BaseChain", "Runnable"], + "category": "Chains", + "description": "Chain to run queries against LLMs", + "inputParams": [ + { + "label": "Chain Name", + "name": "chainName", + "type": "string", + "placeholder": "Name Your Chain", + "optional": true, + "id": "llmChain_1-input-chainName-string" + } + ], + "inputAnchors": [ + { + "label": "Language Model", + "name": "model", + "type": "BaseLanguageModel", + "id": "llmChain_1-input-model-BaseLanguageModel" + }, + { + "label": "Prompt", + "name": "prompt", + "type": "BasePromptTemplate", + "id": "llmChain_1-input-prompt-BasePromptTemplate" + }, + { + "label": "Output Parser", + "name": "outputParser", + "type": "BaseLLMOutputParser", + "optional": true, + "id": "llmChain_1-input-outputParser-BaseLLMOutputParser" + } + ], + "inputs": { + "model": "{{chatOpenAI_0.data.instance}}", + "prompt": "{{promptTemplate_1.data.instance}}", + "outputParser": "", + "chainName": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "llmChain_1-output-llmChain-LLMChain|BaseChain|Runnable", + "name": "llmChain", + "label": "LLM Chain", + "type": "LLMChain | BaseChain | Runnable" + }, + { + "id": "llmChain_1-output-outputPrediction-string|json", + "name": "outputPrediction", + "label": "Output Prediction", + "type": "string | json" + } + ], + "default": "llmChain" + } + ], + "outputs": { + "output": "llmChain" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1769.7463380379868, + "y": 194.56291579865376 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_0", + "position": { + "x": 1390.9908731749008, + "y": -332.0609187416074 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_0-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_0-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo", + "temperature": "0", + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1390.9908731749008, + "y": -332.0609187416074 + }, + "dragging": false + } + ], + "edges": [ + { + "source": "promptTemplate_0", + "sourceHandle": "promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate", + "target": "llmChain_0", + "targetHandle": "llmChain_0-input-prompt-BasePromptTemplate", + "type": "buttonedge", + "id": "promptTemplate_0-promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate-llmChain_0-llmChain_0-input-prompt-BasePromptTemplate", + "data": { + "label": "" + } + }, + { + "source": "replicate_0", + "sourceHandle": "replicate_0-output-replicate-Replicate|BaseChatModel|LLM|BaseLLM|BaseLanguageModel|Runnable", + "target": "llmChain_0", + "targetHandle": "llmChain_0-input-model-BaseLanguageModel", + "type": "buttonedge", + "id": "replicate_0-replicate_0-output-replicate-Replicate|BaseChatModel|LLM|BaseLLM|BaseLanguageModel|Runnable-llmChain_0-llmChain_0-input-model-BaseLanguageModel", + "data": { + "label": "" + } + }, + { + "source": "promptTemplate_1", + "sourceHandle": "promptTemplate_1-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate|Runnable", + "target": "llmChain_1", + "targetHandle": "llmChain_1-input-prompt-BasePromptTemplate", + "type": "buttonedge", + "id": "promptTemplate_1-promptTemplate_1-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate|Runnable-llmChain_1-llmChain_1-input-prompt-BasePromptTemplate", + "data": { + "label": "" + } + }, + { + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "llmChain_1", + "targetHandle": "llmChain_1-input-model-BaseLanguageModel", + "type": "buttonedge", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-llmChain_1-llmChain_1-input-model-BaseLanguageModel", + "data": { + "label": "" + } + }, + { + "source": "llmChain_0", + "sourceHandle": "llmChain_0-output-outputPrediction-string|json", + "target": "promptTemplate_1", + "targetHandle": "promptTemplate_1-input-promptValues-json", + "type": "buttonedge", + "id": "llmChain_0-llmChain_0-output-outputPrediction-string|json-promptTemplate_1-promptTemplate_1-input-promptValues-json", + "data": { + "label": "" + } + } + ] +} diff --git a/packages/server/marketplaces/chatflows/Input Moderation.json b/packages/server/marketplaces/chatflows/Input Moderation.json new file mode 100644 index 00000000..1f6cc624 --- /dev/null +++ b/packages/server/marketplaces/chatflows/Input Moderation.json @@ -0,0 +1,441 @@ +{ + "description": "Detect text that could generate harmful output and prevent it from being sent to the language model", + "badge": "NEW", + "nodes": [ + { + "width": 300, + "height": 356, + "id": "inputModerationOpenAI_0", + "position": { + "x": 334.36040624369247, + "y": 467.88081727992824 + }, + "type": "customNode", + "data": { + "id": "inputModerationOpenAI_0", + "label": "OpenAI Moderation", + "version": 1, + "name": "inputModerationOpenAI", + "type": "Moderation", + "baseClasses": ["Moderation"], + "category": "Moderation", + "description": "Check whether content complies with OpenAI usage policies.", + "inputParams": [ + { + "label": "Error Message", + "name": "moderationErrorMessage", + "type": "string", + "rows": 2, + "default": "Cannot Process! Input violates OpenAI's content moderation policies.", + "optional": true, + "id": "inputModerationOpenAI_0-input-moderationErrorMessage-string" + } + ], + "inputAnchors": [], + "inputs": { + "moderationErrorMessage": "Cannot Process! Input violates OpenAI's content moderation policies." + }, + "outputAnchors": [ + { + "id": "inputModerationOpenAI_0-output-inputModerationOpenAI-Moderation|Moderation", + "name": "inputModerationOpenAI", + "label": "Moderation", + "type": "Moderation" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 334.36040624369247, + "y": 467.88081727992824 + }, + "dragging": false + }, + { + "width": 300, + "height": 507, + "id": "llmChain_0", + "position": { + "x": 859.216454729136, + "y": 154.86846618352752 + }, + "type": "customNode", + "data": { + "id": "llmChain_0", + "label": "LLM Chain", + "version": 3, + "name": "llmChain", + "type": "LLMChain", + "baseClasses": ["LLMChain", "BaseChain", "Runnable"], + "category": "Chains", + "description": "Chain to run queries against LLMs", + "inputParams": [ + { + "label": "Chain Name", + "name": "chainName", + "type": "string", + "placeholder": "Name Your Chain", + "optional": true, + "id": "llmChain_0-input-chainName-string" + } + ], + "inputAnchors": [ + { + "label": "Language Model", + "name": "model", + "type": "BaseLanguageModel", + "id": "llmChain_0-input-model-BaseLanguageModel" + }, + { + "label": "Prompt", + "name": "prompt", + "type": "BasePromptTemplate", + "id": "llmChain_0-input-prompt-BasePromptTemplate" + }, + { + "label": "Output Parser", + "name": "outputParser", + "type": "BaseLLMOutputParser", + "optional": true, + "id": "llmChain_0-input-outputParser-BaseLLMOutputParser" + }, + { + "label": "Input Moderation", + "description": "Detect text that could generate harmful output and prevent it from being sent to the language model", + "name": "inputModeration", + "type": "Moderation", + "optional": true, + "list": true, + "id": "llmChain_0-input-inputModeration-Moderation" + } + ], + "inputs": { + "model": "{{chatOpenAI_0.data.instance}}", + "prompt": "{{promptTemplate_0.data.instance}}", + "outputParser": "", + "inputModeration": ["{{inputModerationOpenAI_0.data.instance}}"], + "chainName": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "llmChain_0-output-llmChain-LLMChain|BaseChain|Runnable", + "name": "llmChain", + "label": "LLM Chain", + "type": "LLMChain | BaseChain | Runnable" + }, + { + "id": "llmChain_0-output-outputPrediction-string|json", + "name": "outputPrediction", + "label": "Output Prediction", + "type": "string | json" + } + ], + "default": "llmChain" + } + ], + "outputs": { + "output": "llmChain" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 859.216454729136, + "y": 154.86846618352752 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_0", + "position": { + "x": 424.69244822381864, + "y": -271.138349609141 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_0-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_0-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo", + "temperature": 0.9, + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 424.69244822381864, + "y": -271.138349609141 + }, + "dragging": false + }, + { + "width": 300, + "height": 475, + "id": "promptTemplate_0", + "position": { + "x": -17.005933033720936, + "y": -20.829788775850602 + }, + "type": "customNode", + "data": { + "id": "promptTemplate_0", + "label": "Prompt Template", + "version": 1, + "name": "promptTemplate", + "type": "PromptTemplate", + "baseClasses": ["PromptTemplate", "BaseStringPromptTemplate", "BasePromptTemplate", "Runnable"], + "category": "Prompts", + "description": "Schema to represent a basic prompt for an LLM", + "inputParams": [ + { + "label": "Template", + "name": "template", + "type": "string", + "rows": 4, + "placeholder": "What is a good name for a company that makes {product}?", + "id": "promptTemplate_0-input-template-string" + }, + { + "label": "Format Prompt Values", + "name": "promptValues", + "type": "json", + "optional": true, + "acceptVariable": true, + "list": true, + "id": "promptTemplate_0-input-promptValues-json" + } + ], + "inputAnchors": [], + "inputs": { + "template": "Answer user question:\n{text}", + "promptValues": "{\"history\":\"{{chat_history}}\"}" + }, + "outputAnchors": [ + { + "id": "promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate|Runnable", + "name": "promptTemplate", + "label": "PromptTemplate", + "type": "PromptTemplate | BaseStringPromptTemplate | BasePromptTemplate | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": -17.005933033720936, + "y": -20.829788775850602 + }, + "dragging": false + } + ], + "edges": [ + { + "source": "inputModerationOpenAI_0", + "sourceHandle": "inputModerationOpenAI_0-output-inputModerationOpenAI-Moderation|Moderation", + "target": "llmChain_0", + "targetHandle": "llmChain_0-input-inputModeration-Moderation", + "type": "buttonedge", + "id": "inputModerationOpenAI_0-inputModerationOpenAI_0-output-inputModerationOpenAI-Moderation|Moderation-llmChain_0-llmChain_0-input-inputModeration-Moderation", + "data": { + "label": "" + } + }, + { + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "llmChain_0", + "targetHandle": "llmChain_0-input-model-BaseLanguageModel", + "type": "buttonedge", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-llmChain_0-llmChain_0-input-model-BaseLanguageModel", + "data": { + "label": "" + } + }, + { + "source": "promptTemplate_0", + "sourceHandle": "promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate|Runnable", + "target": "llmChain_0", + "targetHandle": "llmChain_0-input-prompt-BasePromptTemplate", + "type": "buttonedge", + "id": "promptTemplate_0-promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate|Runnable-llmChain_0-llmChain_0-input-prompt-BasePromptTemplate", + "data": { + "label": "" + } + } + ] +} diff --git a/packages/server/marketplaces/chatflows/Local QnA.json b/packages/server/marketplaces/chatflows/Local QnA.json index 78ce16f6..e24ad7ca 100644 --- a/packages/server/marketplaces/chatflows/Local QnA.json +++ b/packages/server/marketplaces/chatflows/Local QnA.json @@ -1,20 +1,21 @@ { - "description": "QnA chain using local LLM, Embedding models, and Faiss local vector store", + "description": "QnA chain using Ollama local LLM, LocalAI embedding model, and Faiss local vector store", + "badge": "POPULAR", "nodes": [ { "width": 300, - "height": 376, + "height": 429, "id": "recursiveCharacterTextSplitter_1", "position": { - "x": 422.81091375202413, + "x": 424.5721426652516, "y": 122.99825010325736 }, "type": "customNode", "data": { "id": "recursiveCharacterTextSplitter_1", "label": "Recursive Character Text Splitter", - "name": "recursiveCharacterTextSplitter", "version": 2, + "name": "recursiveCharacterTextSplitter", "type": "RecursiveCharacterTextSplitter", "baseClasses": ["RecursiveCharacterTextSplitter", "TextSplitter"], "category": "Text Splitters", @@ -65,25 +66,25 @@ }, "selected": false, "positionAbsolute": { - "x": 422.81091375202413, + "x": 424.5721426652516, "y": 122.99825010325736 }, "dragging": false }, { "width": 300, - "height": 428, + "height": 480, "id": "conversationalRetrievalQAChain_0", "position": { - "x": 1634.455879160561, - "y": 428.77742668929807 + "x": 1604.8865818627112, + "y": 329.6333122200366 }, "type": "customNode", "data": { "id": "conversationalRetrievalQAChain_0", "label": "Conversational Retrieval QA Chain", - "name": "conversationalRetrievalQAChain", "version": 1, + "name": "conversationalRetrievalQAChain", "type": "ConversationalRetrievalQAChain", "baseClasses": ["ConversationalRetrievalQAChain", "BaseChain", "BaseLangChain"], "category": "Chains", @@ -155,8 +156,8 @@ } ], "inputs": { - "model": "{{chatLocalAI_0.data.instance}}", - "vectorStoreRetriever": "{{faissUpsert_0.data.instance}}", + "model": "{{chatOllama_0.data.instance}}", + "vectorStoreRetriever": "{{faiss_0.data.instance}}", "memory": "" }, "outputAnchors": [ @@ -172,208 +173,14 @@ }, "selected": false, "positionAbsolute": { - "x": 1634.455879160561, - "y": 428.77742668929807 + "x": 1604.8865818627112, + "y": 329.6333122200366 }, "dragging": false }, { "width": 300, - "height": 456, - "id": "faissUpsert_0", - "position": { - "x": 1204.6898035516715, - "y": 521.0933926644659 - }, - "type": "customNode", - "data": { - "id": "faissUpsert_0", - "label": "Faiss Upsert Document", - "name": "faissUpsert", - "version": 1, - "type": "Faiss", - "baseClasses": ["Faiss", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Upsert documents to Faiss", - "inputParams": [ - { - "label": "Base Path to store", - "name": "basePath", - "description": "Path to store faiss.index file", - "placeholder": "C:\\Users\\User\\Desktop", - "type": "string", - "id": "faissUpsert_0-input-basePath-string" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "faissUpsert_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Document", - "name": "document", - "type": "Document", - "list": true, - "id": "faissUpsert_0-input-document-Document" - }, - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "faissUpsert_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "document": ["{{textFile_0.data.instance}}"], - "embeddings": "{{localAIEmbeddings_0.data.instance}}", - "basePath": "C:\\Users\\your-folder", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "faissUpsert_0-output-retriever-Faiss|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Faiss Retriever", - "type": "Faiss | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "faissUpsert_0-output-vectorStore-Faiss|SaveableVectorStore|VectorStore", - "name": "vectorStore", - "label": "Faiss Vector Store", - "type": "Faiss | SaveableVectorStore | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "retriever" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1204.6898035516715, - "y": 521.0933926644659 - }, - "dragging": false - }, - { - "width": 300, - "height": 526, - "id": "chatLocalAI_0", - "position": { - "x": 1191.9512064167336, - "y": -94.05401001663306 - }, - "type": "customNode", - "data": { - "id": "chatLocalAI_0", - "label": "ChatLocalAI", - "name": "chatLocalAI", - "version": 2, - "type": "ChatLocalAI", - "baseClasses": ["ChatLocalAI", "BaseChatModel", "LLM", "BaseLLM", "BaseLanguageModel", "BaseLangChain"], - "category": "Chat Models", - "description": "Use local LLMs like llama.cpp, gpt4all using LocalAI", - "inputParams": [ - { - "label": "Base Path", - "name": "basePath", - "type": "string", - "placeholder": "http://localhost:8080/v1", - "id": "chatLocalAI_0-input-basePath-string" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "string", - "placeholder": "gpt4all-lora-quantized.bin", - "id": "chatLocalAI_0-input-modelName-string" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.9, - "optional": true, - "id": "chatLocalAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatLocalAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatLocalAI_0-input-topP-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatLocalAI_0-input-timeout-number" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatLocalAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "basePath": "http://localhost:8080/v1", - "modelName": "ggml-gpt4all-j.bin", - "temperature": 0.9, - "maxTokens": "", - "topP": "", - "timeout": "" - }, - "outputAnchors": [ - { - "id": "chatLocalAI_0-output-chatLocalAI-ChatLocalAI|BaseChatModel|LLM|BaseLLM|BaseLanguageModel|BaseLangChain", - "name": "chatLocalAI", - "label": "ChatLocalAI", - "type": "ChatLocalAI | BaseChatModel | LLM | BaseLLM | BaseLanguageModel | BaseLangChain" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1191.9512064167336, - "y": -94.05401001663306 - }, - "dragging": false - }, - { - "width": 300, - "height": 410, + "height": 419, "id": "textFile_0", "position": { "x": 809.5432731751458, @@ -383,8 +190,8 @@ "data": { "id": "textFile_0", "label": "Text File", - "name": "textFile", "version": 3, + "name": "textFile", "type": "Document", "baseClasses": ["Document"], "category": "Document Loaders", @@ -465,8 +272,8 @@ "data": { "id": "localAIEmbeddings_0", "label": "LocalAI Embeddings", - "name": "localAIEmbeddings", "version": 1, + "name": "localAIEmbeddings", "type": "LocalAI Embeddings", "baseClasses": ["LocalAI Embeddings", "Embeddings"], "category": "Embeddings", @@ -509,31 +316,324 @@ "y": 507.4586304746849 }, "dragging": false + }, + { + "width": 300, + "height": 578, + "id": "chatOllama_0", + "position": { + "x": 1198.006914501795, + "y": -78.92345253481488 + }, + "type": "customNode", + "data": { + "id": "chatOllama_0", + "label": "ChatOllama", + "version": 2, + "name": "chatOllama", + "type": "ChatOllama", + "baseClasses": ["ChatOllama", "SimpleChatModel", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Chat completion using open-source LLM on Ollama", + "inputParams": [ + { + "label": "Base URL", + "name": "baseUrl", + "type": "string", + "default": "http://localhost:11434", + "id": "chatOllama_0-input-baseUrl-string" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "string", + "placeholder": "llama2", + "id": "chatOllama_0-input-modelName-string" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "description": "The temperature of the model. Increasing the temperature will make the model answer more creatively. (Default: 0.8). Refer to docs for more details", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOllama_0-input-temperature-number" + }, + { + "label": "Top P", + "name": "topP", + "type": "number", + "description": "Works together with top-k. A higher value (e.g., 0.95) will lead to more diverse text, while a lower value (e.g., 0.5) will generate more focused and conservative text. (Default: 0.9). Refer to docs for more details", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-topP-number" + }, + { + "label": "Top K", + "name": "topK", + "type": "number", + "description": "Reduces the probability of generating nonsense. A higher value (e.g. 100) will give more diverse answers, while a lower value (e.g. 10) will be more conservative. (Default: 40). Refer to docs for more details", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-topK-number" + }, + { + "label": "Mirostat", + "name": "mirostat", + "type": "number", + "description": "Enable Mirostat sampling for controlling perplexity. (default: 0, 0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0). Refer to docs for more details", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-mirostat-number" + }, + { + "label": "Mirostat ETA", + "name": "mirostatEta", + "type": "number", + "description": "Influences how quickly the algorithm responds to feedback from the generated text. A lower learning rate will result in slower adjustments, while a higher learning rate will make the algorithm more responsive. (Default: 0.1) Refer to docs for more details", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-mirostatEta-number" + }, + { + "label": "Mirostat TAU", + "name": "mirostatTau", + "type": "number", + "description": "Controls the balance between coherence and diversity of the output. A lower value will result in more focused and coherent text. (Default: 5.0) Refer to docs for more details", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-mirostatTau-number" + }, + { + "label": "Context Window Size", + "name": "numCtx", + "type": "number", + "description": "Sets the size of the context window used to generate the next token. (Default: 2048) Refer to docs for more details", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-numCtx-number" + }, + { + "label": "Number of GQA groups", + "name": "numGqa", + "type": "number", + "description": "The number of GQA groups in the transformer layer. Required for some models, for example it is 8 for llama2:70b. Refer to docs for more details", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-numGqa-number" + }, + { + "label": "Number of GPU", + "name": "numGpu", + "type": "number", + "description": "The number of layers to send to the GPU(s). On macOS it defaults to 1 to enable metal support, 0 to disable. Refer to docs for more details", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-numGpu-number" + }, + { + "label": "Number of Thread", + "name": "numThread", + "type": "number", + "description": "Sets the number of threads to use during computation. By default, Ollama will detect this for optimal performance. It is recommended to set this value to the number of physical CPU cores your system has (as opposed to the logical number of cores). Refer to docs for more details", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-numThread-number" + }, + { + "label": "Repeat Last N", + "name": "repeatLastN", + "type": "number", + "description": "Sets how far back for the model to look back to prevent repetition. (Default: 64, 0 = disabled, -1 = num_ctx). Refer to docs for more details", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-repeatLastN-number" + }, + { + "label": "Repeat Penalty", + "name": "repeatPenalty", + "type": "number", + "description": "Sets how strongly to penalize repetitions. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 0.9) will be more lenient. (Default: 1.1). Refer to docs for more details", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-repeatPenalty-number" + }, + { + "label": "Stop Sequence", + "name": "stop", + "type": "string", + "rows": 4, + "placeholder": "AI assistant:", + "description": "Sets the stop sequences to use. Use comma to seperate different sequences. Refer to docs for more details", + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-stop-string" + }, + { + "label": "Tail Free Sampling", + "name": "tfsZ", + "type": "number", + "description": "Tail free sampling is used to reduce the impact of less probable tokens from the output. A higher value (e.g., 2.0) will reduce the impact more, while a value of 1.0 disables this setting. (Default: 1). Refer to docs for more details", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOllama_0-input-tfsZ-number" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOllama_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "baseUrl": "http://localhost:11434", + "modelName": "llama2", + "temperature": 0.9, + "topP": "", + "topK": "", + "mirostat": "", + "mirostatEta": "", + "mirostatTau": "", + "numCtx": "", + "numGqa": "", + "numGpu": "", + "numThread": "", + "repeatLastN": "", + "repeatPenalty": "", + "stop": "", + "tfsZ": "" + }, + "outputAnchors": [ + { + "id": "chatOllama_0-output-chatOllama-ChatOllama|SimpleChatModel|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOllama", + "label": "ChatOllama", + "type": "ChatOllama | SimpleChatModel | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1198.006914501795, + "y": -78.92345253481488 + }, + "dragging": false + }, + { + "width": 300, + "height": 458, + "id": "faiss_0", + "position": { + "x": 1199.3135683364685, + "y": 520.9300176396024 + }, + "type": "customNode", + "data": { + "id": "faiss_0", + "label": "Faiss", + "version": 1, + "name": "faiss", + "type": "Faiss", + "baseClasses": ["Faiss", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Faiss library from Meta", + "inputParams": [ + { + "label": "Base Path to load", + "name": "basePath", + "description": "Path to load faiss.index file", + "placeholder": "C:\\Users\\User\\Desktop", + "type": "string", + "id": "faiss_0-input-basePath-string" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Default to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "faiss_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "faiss_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "faiss_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": ["{{textFile_0.data.instance}}"], + "embeddings": "{{localAIEmbeddings_0.data.instance}}", + "basePath": "C:\\Users\\your-folder", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "faiss_0-output-retriever-Faiss|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Faiss Retriever", + "type": "Faiss | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "faiss_0-output-vectorStore-Faiss|SaveableVectorStore|VectorStore", + "name": "vectorStore", + "label": "Faiss Vector Store", + "type": "Faiss | SaveableVectorStore | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "retriever" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1199.3135683364685, + "y": 520.9300176396024 + }, + "dragging": false } ], "edges": [ - { - "source": "faissUpsert_0", - "sourceHandle": "faissUpsert_0-output-retriever-Faiss|VectorStoreRetriever|BaseRetriever", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "type": "buttonedge", - "id": "faissUpsert_0-faissUpsert_0-output-retriever-Faiss|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "data": { - "label": "" - } - }, - { - "source": "chatLocalAI_0", - "sourceHandle": "chatLocalAI_0-output-chatLocalAI-ChatLocalAI|BaseChatModel|LLM|BaseLLM|BaseLanguageModel|BaseLangChain", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "type": "buttonedge", - "id": "chatLocalAI_0-chatLocalAI_0-output-chatLocalAI-ChatLocalAI|BaseChatModel|LLM|BaseLLM|BaseLanguageModel|BaseLangChain-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "data": { - "label": "" - } - }, { "source": "recursiveCharacterTextSplitter_1", "sourceHandle": "recursiveCharacterTextSplitter_1-output-recursiveCharacterTextSplitter-RecursiveCharacterTextSplitter|TextSplitter", @@ -546,12 +646,23 @@ } }, { - "source": "textFile_0", - "sourceHandle": "textFile_0-output-textFile-Document", - "target": "faissUpsert_0", - "targetHandle": "faissUpsert_0-input-document-Document", + "source": "chatOllama_0", + "sourceHandle": "chatOllama_0-output-chatOllama-ChatOllama|SimpleChatModel|BaseChatModel|BaseLanguageModel|Runnable", + "target": "conversationalRetrievalQAChain_0", + "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", "type": "buttonedge", - "id": "textFile_0-textFile_0-output-textFile-Document-faissUpsert_0-faissUpsert_0-input-document-Document", + "id": "chatOllama_0-chatOllama_0-output-chatOllama-ChatOllama|SimpleChatModel|BaseChatModel|BaseLanguageModel|Runnable-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", + "data": { + "label": "" + } + }, + { + "source": "textFile_0", + "sourceHandle": "textFile_0-output-document-Document", + "target": "faiss_0", + "targetHandle": "faiss_0-input-document-Document", + "type": "buttonedge", + "id": "textFile_0-textFile_0-output-document-Document-faiss_0-faiss_0-input-document-Document", "data": { "label": "" } @@ -559,10 +670,21 @@ { "source": "localAIEmbeddings_0", "sourceHandle": "localAIEmbeddings_0-output-localAIEmbeddings-LocalAI Embeddings|Embeddings", - "target": "faissUpsert_0", - "targetHandle": "faissUpsert_0-input-embeddings-Embeddings", + "target": "faiss_0", + "targetHandle": "faiss_0-input-embeddings-Embeddings", "type": "buttonedge", - "id": "localAIEmbeddings_0-localAIEmbeddings_0-output-localAIEmbeddings-LocalAI Embeddings|Embeddings-faissUpsert_0-faissUpsert_0-input-embeddings-Embeddings", + "id": "localAIEmbeddings_0-localAIEmbeddings_0-output-localAIEmbeddings-LocalAI Embeddings|Embeddings-faiss_0-faiss_0-input-embeddings-Embeddings", + "data": { + "label": "" + } + }, + { + "source": "faiss_0", + "sourceHandle": "faiss_0-output-retriever-Faiss|VectorStoreRetriever|BaseRetriever", + "target": "conversationalRetrievalQAChain_0", + "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "type": "buttonedge", + "id": "faiss_0-faiss_0-output-retriever-Faiss|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/Long Term Memory.json b/packages/server/marketplaces/chatflows/Long Term Memory.json index 6f22c00a..c508b480 100644 --- a/packages/server/marketplaces/chatflows/Long Term Memory.json +++ b/packages/server/marketplaces/chatflows/Long Term Memory.json @@ -1,20 +1,20 @@ { - "description": "Use long term memory Zep to differentiate conversations between users with sessionId", + "description": "Use long term memory like Zep to differentiate conversations between users with sessionId", "nodes": [ { "width": 300, "height": 480, "id": "conversationalRetrievalQAChain_0", "position": { - "x": 1999.7302950816731, - "y": 365.33064907894243 + "x": 2001.2622706097407, + "y": 360.7347224947406 }, "type": "customNode", "data": { "id": "conversationalRetrievalQAChain_0", "label": "Conversational Retrieval QA Chain", - "name": "conversationalRetrievalQAChain", "version": 1, + "name": "conversationalRetrievalQAChain", "type": "ConversationalRetrievalQAChain", "baseClasses": ["ConversationalRetrievalQAChain", "BaseChain", "BaseLangChain"], "category": "Chains", @@ -87,7 +87,7 @@ ], "inputs": { "model": "{{chatOpenAI_0.data.instance}}", - "vectorStoreRetriever": "{{pineconeExistingIndex_0.data.instance}}", + "vectorStoreRetriever": "{{qdrant_0.data.instance}}", "memory": "{{ZepMemory_0.data.instance}}", "returnSourceDocuments": true }, @@ -104,170 +104,8 @@ }, "selected": false, "positionAbsolute": { - "x": 1999.7302950816731, - "y": 365.33064907894243 - }, - "dragging": false - }, - { - "width": 300, - "height": 523, - "id": "chatOpenAI_0", - "position": { - "x": 1554.3875781165111, - "y": -74.792508259787212 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_0", - "label": "ChatOpenAI", - "name": "chatOpenAI", - "version": 2, - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.9, - "optional": true, - "id": "chatOpenAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo", - "temperature": "0", - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1554.3875781165111, - "y": -74.792508259787212 + "x": 2001.2622706097407, + "y": 360.7347224947406 }, "dragging": false }, @@ -283,8 +121,8 @@ "data": { "id": "openAIEmbeddings_0", "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", "version": 1, + "name": "openAIEmbeddings", "type": "OpenAIEmbeddings", "baseClasses": ["OpenAIEmbeddings", "Embeddings"], "category": "Embeddings", @@ -355,129 +193,20 @@ }, "dragging": false }, - { - "width": 300, - "height": 505, - "id": "pineconeExistingIndex_0", - "position": { - "x": 1167.128201355349, - "y": 71.89355115516406 - }, - "type": "customNode", - "data": { - "id": "pineconeExistingIndex_0", - "label": "Pinecone Load Existing Index", - "name": "pineconeExistingIndex", - "version": 1, - "type": "Pinecone", - "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Load existing index from Pinecone (i.e: Document has been upserted)", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["pineconeApi"], - "id": "pineconeExistingIndex_0-input-credential-credential" - }, - { - "label": "Pinecone Index", - "name": "pineconeIndex", - "type": "string", - "id": "pineconeExistingIndex_0-input-pineconeIndex-string" - }, - { - "label": "Pinecone Namespace", - "name": "pineconeNamespace", - "type": "string", - "placeholder": "my-first-namespace", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-pineconeNamespace-string" - }, - { - "label": "Pinecone Metadata Filter", - "name": "pineconeMetadataFilter", - "type": "json", - "optional": true, - "additionalParams": true, - "id": "pineconeExistingIndex_0-input-pineconeMetadataFilter-json" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "pineconeExistingIndex_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "pineconeIndex": "", - "pineconeNamespace": "", - "pineconeMetadataFilter": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Pinecone Retriever", - "type": "Pinecone | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", - "name": "vectorStore", - "label": "Pinecone Vector Store", - "type": "Pinecone | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "retriever" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1167.128201355349, - "y": 71.89355115516406 - }, - "dragging": false - }, { "width": 300, "height": 623, "id": "ZepMemory_0", "position": { - "x": 1552.2067611642792, - "y": 560.8352147865392 + "x": 420.8032935700942, + "y": 92.41976641951993 }, "type": "customNode", "data": { "id": "ZepMemory_0", "label": "Zep Memory", - "name": "ZepMemory", "version": 1, + "name": "ZepMemory", "type": "ZepMemory", "baseClasses": ["ZepMemory", "BaseChatMemory", "BaseMemory"], "category": "Memory", @@ -600,46 +329,365 @@ }, "selected": false, "positionAbsolute": { - "x": 1552.2067611642792, - "y": 560.8352147865392 + "x": 420.8032935700942, + "y": 92.41976641951993 + }, + "dragging": false + }, + { + "width": 300, + "height": 654, + "id": "qdrant_0", + "position": { + "x": 1186.2560075381377, + "y": -86.38901299105441 + }, + "type": "customNode", + "data": { + "id": "qdrant_0", + "label": "Qdrant", + "version": 1, + "name": "qdrant", + "type": "Qdrant", + "baseClasses": ["Qdrant", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Qdrant, a scalable open source vector database written in Rust", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "description": "Only needed when using Qdrant cloud hosted", + "optional": true, + "credentialNames": ["qdrantApi"], + "id": "qdrant_0-input-credential-credential" + }, + { + "label": "Qdrant Server URL", + "name": "qdrantServerUrl", + "type": "string", + "placeholder": "http://localhost:6333", + "id": "qdrant_0-input-qdrantServerUrl-string" + }, + { + "label": "Qdrant Collection Name", + "name": "qdrantCollection", + "type": "string", + "id": "qdrant_0-input-qdrantCollection-string" + }, + { + "label": "Vector Dimension", + "name": "qdrantVectorDimension", + "type": "number", + "default": 1536, + "additionalParams": true, + "id": "qdrant_0-input-qdrantVectorDimension-number" + }, + { + "label": "Similarity", + "name": "qdrantSimilarity", + "description": "Similarity measure used in Qdrant.", + "type": "options", + "default": "Cosine", + "options": [ + { + "label": "Cosine", + "name": "Cosine" + }, + { + "label": "Euclid", + "name": "Euclid" + }, + { + "label": "Dot", + "name": "Dot" + } + ], + "additionalParams": true, + "id": "qdrant_0-input-qdrantSimilarity-options" + }, + { + "label": "Additional Collection Cofiguration", + "name": "qdrantCollectionConfiguration", + "description": "Refer to collection docs for more reference", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "qdrant_0-input-qdrantCollectionConfiguration-json" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Default to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "qdrant_0-input-topK-number" + }, + { + "label": "Qdrant Search Filter", + "name": "qdrantFilter", + "description": "Only return points which satisfy the conditions", + "type": "json", + "additionalParams": true, + "optional": true, + "id": "qdrant_0-input-qdrantFilter-json" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "qdrant_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "qdrant_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": "", + "embeddings": "{{openAIEmbeddings_0.data.instance}}", + "qdrantServerUrl": "", + "qdrantCollection": "", + "qdrantVectorDimension": 1536, + "qdrantSimilarity": "Cosine", + "qdrantCollectionConfiguration": "", + "topK": "", + "qdrantFilter": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "qdrant_0-output-retriever-Qdrant|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Qdrant Retriever", + "type": "Qdrant | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "qdrant_0-output-vectorStore-Qdrant|VectorStore", + "name": "vectorStore", + "label": "Qdrant Vector Store", + "type": "Qdrant | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "retriever" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1186.2560075381377, + "y": -86.38901299105441 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_0", + "position": { + "x": 1561.0993169664887, + "y": -75.4103386563329 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_0-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_0-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo-16k", + "temperature": 0.9, + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1561.0993169664887, + "y": -75.4103386563329 }, "dragging": false } ], "edges": [ - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeExistingIndex_0", - "targetHandle": "pineconeExistingIndex_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeExistingIndex_0-pineconeExistingIndex_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, - { - "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "data": { - "label": "" - } - }, - { - "source": "pineconeExistingIndex_0", - "sourceHandle": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "type": "buttonedge", - "id": "pineconeExistingIndex_0-pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "data": { - "label": "" - } - }, { "source": "ZepMemory_0", "sourceHandle": "ZepMemory_0-output-ZepMemory-ZepMemory|BaseChatMemory|BaseMemory", @@ -650,6 +698,39 @@ "data": { "label": "" } + }, + { + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "qdrant_0", + "targetHandle": "qdrant_0-input-embeddings-Embeddings", + "type": "buttonedge", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-qdrant_0-qdrant_0-input-embeddings-Embeddings", + "data": { + "label": "" + } + }, + { + "source": "qdrant_0", + "sourceHandle": "qdrant_0-output-retriever-Qdrant|VectorStoreRetriever|BaseRetriever", + "target": "conversationalRetrievalQAChain_0", + "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "type": "buttonedge", + "id": "qdrant_0-qdrant_0-output-retriever-Qdrant|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "data": { + "label": "" + } + }, + { + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "conversationalRetrievalQAChain_0", + "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", + "type": "buttonedge", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", + "data": { + "label": "" + } } ] } diff --git a/packages/server/marketplaces/chatflows/Metadata Filter Load.json b/packages/server/marketplaces/chatflows/Metadata Filter Load.json deleted file mode 100644 index 43438d6b..00000000 --- a/packages/server/marketplaces/chatflows/Metadata Filter Load.json +++ /dev/null @@ -1,501 +0,0 @@ -{ - "description": "Load existing index with metadata filters and feed into conversational retrieval QA chain", - "nodes": [ - { - "width": 300, - "height": 480, - "id": "conversationalRetrievalQAChain_0", - "position": { - "x": 1643.035168558474, - "y": 360.96295365212774 - }, - "type": "customNode", - "data": { - "id": "conversationalRetrievalQAChain_0", - "label": "Conversational Retrieval QA Chain", - "name": "conversationalRetrievalQAChain", - "version": 1, - "type": "ConversationalRetrievalQAChain", - "baseClasses": ["ConversationalRetrievalQAChain", "BaseChain", "BaseLangChain"], - "category": "Chains", - "description": "Document QA - built on RetrievalQAChain to provide a chat history component", - "inputParams": [ - { - "label": "Return Source Documents", - "name": "returnSourceDocuments", - "type": "boolean", - "optional": true, - "id": "conversationalRetrievalQAChain_0-input-returnSourceDocuments-boolean" - }, - { - "label": "System Message", - "name": "systemMessagePrompt", - "type": "string", - "rows": 4, - "additionalParams": true, - "optional": true, - "placeholder": "I want you to act as a document that I am having a conversation with. Your name is \"AI Assistant\". You will provide me with answers from the given info. If the answer is not included, say exactly \"Hmm, I am not sure.\" and stop after that. Refuse to answer any question not about the info. Never break character.", - "id": "conversationalRetrievalQAChain_0-input-systemMessagePrompt-string" - }, - { - "label": "Chain Option", - "name": "chainOption", - "type": "options", - "options": [ - { - "label": "MapReduceDocumentsChain", - "name": "map_reduce", - "description": "Suitable for QA tasks over larger documents and can run the preprocessing step in parallel, reducing the running time" - }, - { - "label": "RefineDocumentsChain", - "name": "refine", - "description": "Suitable for QA tasks over a large number of documents." - }, - { - "label": "StuffDocumentsChain", - "name": "stuff", - "description": "Suitable for QA tasks over a small number of documents." - } - ], - "additionalParams": true, - "optional": true, - "id": "conversationalRetrievalQAChain_0-input-chainOption-options" - } - ], - "inputAnchors": [ - { - "label": "Language Model", - "name": "model", - "type": "BaseLanguageModel", - "id": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel" - }, - { - "label": "Vector Store Retriever", - "name": "vectorStoreRetriever", - "type": "BaseRetriever", - "id": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever" - }, - { - "label": "Memory", - "name": "memory", - "type": "BaseMemory", - "optional": true, - "description": "If left empty, a default BufferMemory will be used", - "id": "conversationalRetrievalQAChain_0-input-memory-BaseMemory" - } - ], - "inputs": { - "model": "{{chatOpenAI_0.data.instance}}", - "vectorStoreRetriever": "{{pineconeExistingIndex_0.data.instance}}" - }, - "outputAnchors": [ - { - "id": "conversationalRetrievalQAChain_0-output-conversationalRetrievalQAChain-ConversationalRetrievalQAChain|BaseChain|BaseLangChain", - "name": "conversationalRetrievalQAChain", - "label": "ConversationalRetrievalQAChain", - "type": "ConversationalRetrievalQAChain | BaseChain | BaseLangChain" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1643.035168558474, - "y": 360.96295365212774 - }, - "dragging": false - }, - { - "width": 300, - "height": 523, - "id": "chatOpenAI_0", - "position": { - "x": 1197.7264239788542, - "y": -76.177600120515933 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_0", - "label": "ChatOpenAI", - "name": "chatOpenAI", - "version": 2, - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.9, - "optional": true, - "id": "chatOpenAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo", - "temperature": "0", - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1197.7264239788542, - "y": -76.177600120515933 - }, - "dragging": false - }, - { - "width": 300, - "height": 329, - "id": "openAIEmbeddings_0", - "position": { - "x": 805.2662010688601, - "y": 389.3163571296623 - }, - "type": "customNode", - "data": { - "id": "openAIEmbeddings_0", - "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", - "version": 1, - "type": "OpenAIEmbeddings", - "baseClasses": ["OpenAIEmbeddings", "Embeddings"], - "category": "Embeddings", - "description": "OpenAI API to generate embeddings for a given text", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "openAIEmbeddings_0-input-credential-credential" - }, - { - "label": "Strip New Lines", - "name": "stripNewLines", - "type": "boolean", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-stripNewLines-boolean" - }, - { - "label": "Batch Size", - "name": "batchSize", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-batchSize-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-basepath-string" - } - ], - "inputAnchors": [], - "inputs": { - "stripNewLines": "", - "batchSize": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "name": "openAIEmbeddings", - "label": "OpenAIEmbeddings", - "type": "OpenAIEmbeddings | Embeddings" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 805.2662010688601, - "y": 389.3163571296623 - }, - "dragging": false - }, - { - "width": 300, - "height": 505, - "id": "pineconeExistingIndex_0", - "position": { - "x": 1194.8300385699242, - "y": 542.8247838029442 - }, - "type": "customNode", - "data": { - "id": "pineconeExistingIndex_0", - "label": "Pinecone Load Existing Index", - "name": "pineconeExistingIndex", - "version": 1, - "type": "Pinecone", - "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Load existing index from Pinecone (i.e: Document has been upserted)", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["pineconeApi"], - "id": "pineconeExistingIndex_0-input-credential-credential" - }, - { - "label": "Pinecone Index", - "name": "pineconeIndex", - "type": "string", - "id": "pineconeExistingIndex_0-input-pineconeIndex-string" - }, - { - "label": "Pinecone Namespace", - "name": "pineconeNamespace", - "type": "string", - "placeholder": "my-first-namespace", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-pineconeNamespace-string" - }, - { - "label": "Pinecone Metadata Filter", - "name": "pineconeMetadataFilter", - "type": "json", - "optional": true, - "additionalParams": true, - "id": "pineconeExistingIndex_0-input-pineconeMetadataFilter-json" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "pineconeExistingIndex_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "pineconeIndex": "", - "pineconeNamespace": "", - "pineconeMetadataFilter": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Pinecone Retriever", - "type": "Pinecone | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", - "name": "vectorStore", - "label": "Pinecone Vector Store", - "type": "Pinecone | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "retriever" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1194.8300385699242, - "y": 542.8247838029442 - }, - "dragging": false - } - ], - "edges": [ - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeExistingIndex_0", - "targetHandle": "pineconeExistingIndex_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeExistingIndex_0-pineconeExistingIndex_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, - { - "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "data": { - "label": "" - } - }, - { - "source": "pineconeExistingIndex_0", - "sourceHandle": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "type": "buttonedge", - "id": "pineconeExistingIndex_0-pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "data": { - "label": "" - } - } - ] -} diff --git a/packages/server/marketplaces/chatflows/Metadata Filter Upsert.json b/packages/server/marketplaces/chatflows/Metadata Filter.json similarity index 86% rename from packages/server/marketplaces/chatflows/Metadata Filter Upsert.json rename to packages/server/marketplaces/chatflows/Metadata Filter.json index 38cec6dd..9865ae70 100644 --- a/packages/server/marketplaces/chatflows/Metadata Filter Upsert.json +++ b/packages/server/marketplaces/chatflows/Metadata Filter.json @@ -1,9 +1,10 @@ { - "description": "Upsert multiple files with metadata filters and feed into conversational retrieval QA chain", + "description": "Upsert multiple files with metadata and filter by it using conversational retrieval QA chain", + "badge": "POPULAR", "nodes": [ { "width": 300, - "height": 376, + "height": 429, "id": "recursiveCharacterTextSplitter_1", "position": { "x": 347.5233039646277, @@ -13,8 +14,8 @@ "data": { "id": "recursiveCharacterTextSplitter_1", "label": "Recursive Character Text Splitter", - "name": "recursiveCharacterTextSplitter", "version": 2, + "name": "recursiveCharacterTextSplitter", "type": "RecursiveCharacterTextSplitter", "baseClasses": ["RecursiveCharacterTextSplitter", "TextSplitter"], "category": "Text Splitters", @@ -72,7 +73,7 @@ }, { "width": 300, - "height": 392, + "height": 419, "id": "textFile_0", "position": { "x": 756.5586098635717, @@ -82,8 +83,8 @@ "data": { "id": "textFile_0", "label": "Text File", - "name": "textFile", "version": 3, + "name": "textFile", "type": "Document", "baseClasses": ["Document"], "category": "Document Loaders", @@ -164,8 +165,8 @@ "data": { "id": "pdfFile_0", "label": "Pdf File", - "name": "pdfFile", "version": 1, + "name": "pdfFile", "type": "Document", "baseClasses": ["Document"], "category": "Document Loaders", @@ -248,8 +249,8 @@ "data": { "id": "conversationalRetrievalQAChain_0", "label": "Conversational Retrieval QA Chain", - "name": "conversationalRetrievalQAChain", "version": 1, + "name": "conversationalRetrievalQAChain", "type": "ConversationalRetrievalQAChain", "baseClasses": ["ConversationalRetrievalQAChain", "BaseChain", "BaseLangChain"], "category": "Chains", @@ -322,7 +323,7 @@ ], "inputs": { "model": "{{chatOpenAI_0.data.instance}}", - "vectorStoreRetriever": "{{pineconeUpsert_0.data.instance}}" + "vectorStoreRetriever": "{{pinecone_0.data.instance}}" }, "outputAnchors": [ { @@ -342,290 +343,20 @@ }, "dragging": false }, - { - "width": 300, - "height": 555, - "id": "pineconeUpsert_0", - "position": { - "x": 1161.2426252201622, - "y": 549.7917156049002 - }, - "type": "customNode", - "data": { - "id": "pineconeUpsert_0", - "label": "Pinecone Upsert Document", - "name": "pineconeUpsert", - "type": "Pinecone", - "version": 1, - "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Upsert documents to Pinecone", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["pineconeApi"], - "id": "pineconeUpsert_0-input-credential-credential" - }, - { - "label": "Pinecone Index", - "name": "pineconeIndex", - "type": "string", - "id": "pineconeUpsert_0-input-pineconeIndex-string" - }, - { - "label": "Pinecone Namespace", - "name": "pineconeNamespace", - "type": "string", - "placeholder": "my-first-namespace", - "additionalParams": true, - "optional": true, - "id": "pineconeUpsert_0-input-pineconeNamespace-string" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pineconeUpsert_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Document", - "name": "document", - "type": "Document", - "list": true, - "id": "pineconeUpsert_0-input-document-Document" - }, - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "pineconeUpsert_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "document": ["{{textFile_0.data.instance}}", "{{pdfFile_0.data.instance}}"], - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "pineconeIndex": "", - "pineconeNamespace": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "pineconeUpsert_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Pinecone Retriever", - "type": "Pinecone | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "pineconeUpsert_0-output-vectorStore-Pinecone|VectorStore", - "name": "vectorStore", - "label": "Pinecone Vector Store", - "type": "Pinecone | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "retriever" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1161.2426252201622, - "y": 549.7917156049002 - }, - "dragging": false - }, - { - "width": 300, - "height": 523, - "id": "chatOpenAI_0", - "position": { - "x": 1164.9667590264419, - "y": -44.2076264967032 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_0", - "label": "ChatOpenAI", - "name": "chatOpenAI", - "version": 2, - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.9, - "optional": true, - "id": "chatOpenAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo", - "temperature": 0.9, - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1164.9667590264419, - "y": -44.2076264967032 - }, - "dragging": false - }, { "width": 300, "height": 329, "id": "openAIEmbeddings_0", "position": { - "x": 772.0706424639393, - "y": 862.6189553323906 + "x": 761.6417182278027, + "y": 852.6452698684387 }, "type": "customNode", "data": { "id": "openAIEmbeddings_0", "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", "version": 1, + "name": "openAIEmbeddings", "type": "OpenAIEmbeddings", "baseClasses": ["OpenAIEmbeddings", "Embeddings"], "category": "Embeddings", @@ -691,8 +422,316 @@ }, "selected": false, "positionAbsolute": { - "x": 772.0706424639393, - "y": 862.6189553323906 + "x": 761.6417182278027, + "y": 852.6452698684387 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_0", + "position": { + "x": 1162.9449281292038, + "y": -64.39144252849331 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_0-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_0-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo-16k", + "temperature": 0.9, + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1162.9449281292038, + "y": -64.39144252849331 + }, + "dragging": false + }, + { + "width": 300, + "height": 555, + "id": "pinecone_0", + "position": { + "x": 1175.8270637283192, + "y": 569.8692882036854 + }, + "type": "customNode", + "data": { + "id": "pinecone_0", + "label": "Pinecone", + "version": 1, + "name": "pinecone", + "type": "Pinecone", + "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Pinecone, a leading fully managed hosted vector database", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["pineconeApi"], + "id": "pinecone_0-input-credential-credential" + }, + { + "label": "Pinecone Index", + "name": "pineconeIndex", + "type": "string", + "id": "pinecone_0-input-pineconeIndex-string" + }, + { + "label": "Pinecone Namespace", + "name": "pineconeNamespace", + "type": "string", + "placeholder": "my-first-namespace", + "additionalParams": true, + "optional": true, + "id": "pinecone_0-input-pineconeNamespace-string" + }, + { + "label": "Pinecone Metadata Filter", + "name": "pineconeMetadataFilter", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "pinecone_0-input-pineconeMetadataFilter-json" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Default to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "pinecone_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "pinecone_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "pinecone_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": ["{{textFile_0.data.instance}}", "{{pdfFile_0.data.instance}}"], + "embeddings": "{{openAIEmbeddings_0.data.instance}}", + "pineconeIndex": "", + "pineconeNamespace": "", + "pineconeMetadataFilter": "{\"id\":{\"$in\":[\"doc1\",\"doc2\"]}}", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Pinecone Retriever", + "type": "Pinecone | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "pinecone_0-output-vectorStore-Pinecone|VectorStore", + "name": "vectorStore", + "label": "Pinecone Vector Store", + "type": "Pinecone | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "retriever" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1175.8270637283192, + "y": 569.8692882036854 }, "dragging": false } @@ -721,23 +760,23 @@ } }, { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeUpsert_0", - "targetHandle": "pineconeUpsert_0-input-embeddings-Embeddings", + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "conversationalRetrievalQAChain_0", + "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeUpsert_0-pineconeUpsert_0-input-embeddings-Embeddings", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", "data": { "label": "" } }, { "source": "textFile_0", - "sourceHandle": "textFile_0-output-textFile-Document", - "target": "pineconeUpsert_0", - "targetHandle": "pineconeUpsert_0-input-document-Document", + "sourceHandle": "textFile_0-output-document-Document", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-document-Document", "type": "buttonedge", - "id": "textFile_0-textFile_0-output-textFile-Document-pineconeUpsert_0-pineconeUpsert_0-input-document-Document", + "id": "textFile_0-textFile_0-output-document-Document-pinecone_0-pinecone_0-input-document-Document", "data": { "label": "" } @@ -745,32 +784,32 @@ { "source": "pdfFile_0", "sourceHandle": "pdfFile_0-output-pdfFile-Document", - "target": "pineconeUpsert_0", - "targetHandle": "pineconeUpsert_0-input-document-Document", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-document-Document", "type": "buttonedge", - "id": "pdfFile_0-pdfFile_0-output-pdfFile-Document-pineconeUpsert_0-pineconeUpsert_0-input-document-Document", + "id": "pdfFile_0-pdfFile_0-output-pdfFile-Document-pinecone_0-pinecone_0-input-document-Document", "data": { "label": "" } }, { - "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-embeddings-Embeddings", "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pinecone_0-pinecone_0-input-embeddings-Embeddings", "data": { "label": "" } }, { - "source": "pineconeUpsert_0", - "sourceHandle": "pineconeUpsert_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "source": "pinecone_0", + "sourceHandle": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", "target": "conversationalRetrievalQAChain_0", "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", "type": "buttonedge", - "id": "pineconeUpsert_0-pineconeUpsert_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "id": "pinecone_0-pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/Multi Prompt Chain.json b/packages/server/marketplaces/chatflows/Multi Prompt Chain.json index e1063dcf..0a888a6b 100644 --- a/packages/server/marketplaces/chatflows/Multi Prompt Chain.json +++ b/packages/server/marketplaces/chatflows/Multi Prompt Chain.json @@ -388,6 +388,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -407,7 +415,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { diff --git a/packages/server/marketplaces/chatflows/Multi Retrieval QA Chain.json b/packages/server/marketplaces/chatflows/Multi Retrieval QA Chain.json index 36240e39..5388d965 100644 --- a/packages/server/marketplaces/chatflows/Multi Retrieval QA Chain.json +++ b/packages/server/marketplaces/chatflows/Multi Retrieval QA Chain.json @@ -13,8 +13,8 @@ "data": { "id": "vectorStoreRetriever_0", "label": "Vector Store Retriever", - "name": "vectorStoreRetriever", "version": 1, + "name": "vectorStoreRetriever", "type": "VectorStoreRetriever", "baseClasses": ["VectorStoreRetriever"], "category": "Retrievers", @@ -46,7 +46,7 @@ } ], "inputs": { - "vectorStore": "{{supabaseExistingIndex_0.data.instance}}", + "vectorStore": "{{supabase_0.data.instance}}", "name": "aqua teen", "description": "Good for answering questions about Aqua Teen Hunger Force theme song" }, @@ -80,8 +80,8 @@ "data": { "id": "multiRetrievalQAChain_0", "label": "Multi Retrieval QA Chain", - "name": "multiRetrievalQAChain", "version": 1, + "name": "multiRetrievalQAChain", "type": "MultiRetrievalQAChain", "baseClasses": ["MultiRetrievalQAChain", "MultiRouteChain", "BaseChain", "BaseLangChain"], "category": "Chains", @@ -147,8 +147,8 @@ "data": { "id": "vectorStoreRetriever_1", "label": "Vector Store Retriever", - "name": "vectorStoreRetriever", "version": 1, + "name": "vectorStoreRetriever", "type": "VectorStoreRetriever", "baseClasses": ["VectorStoreRetriever"], "category": "Retrievers", @@ -180,7 +180,7 @@ } ], "inputs": { - "vectorStore": "{{chromaExistingIndex_0.data.instance}}", + "vectorStore": "{{chroma_0.data.instance}}", "name": "mst3k", "description": "Good for answering questions about Mystery Science Theater 3000 theme song" }, @@ -214,8 +214,8 @@ "data": { "id": "vectorStoreRetriever_2", "label": "Vector Store Retriever", - "name": "vectorStoreRetriever", "version": 1, + "name": "vectorStoreRetriever", "type": "VectorStoreRetriever", "baseClasses": ["VectorStoreRetriever"], "category": "Retrievers", @@ -247,7 +247,7 @@ } ], "inputs": { - "vectorStore": "{{pineconeExistingIndex_0.data.instance}}", + "vectorStore": "{{pinecone_0.data.instance}}", "name": "animaniacs", "description": "Good for answering questions about Animaniacs theme song" }, @@ -269,206 +269,6 @@ }, "dragging": false }, - { - "width": 300, - "height": 505, - "id": "pineconeExistingIndex_0", - "position": { - "x": 267.45589163840236, - "y": -300.13817634747346 - }, - "type": "customNode", - "data": { - "id": "pineconeExistingIndex_0", - "label": "Pinecone Load Existing Index", - "name": "pineconeExistingIndex", - "version": 1, - "type": "Pinecone", - "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Load existing index from Pinecone (i.e: Document has been upserted)", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["pineconeApi"], - "id": "pineconeExistingIndex_0-input-credential-credential" - }, - { - "label": "Pinecone Index", - "name": "pineconeIndex", - "type": "string", - "id": "pineconeExistingIndex_0-input-pineconeIndex-string" - }, - { - "label": "Pinecone Namespace", - "name": "pineconeNamespace", - "type": "string", - "placeholder": "my-first-namespace", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-pineconeNamespace-string" - }, - { - "label": "Pinecone Metadata Filter", - "name": "pineconeMetadataFilter", - "type": "json", - "optional": true, - "additionalParams": true, - "id": "pineconeExistingIndex_0-input-pineconeMetadataFilter-json" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "pineconeExistingIndex_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "pineconeIndex": "", - "pineconeNamespace": "", - "pineconeMetadataFilter": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Pinecone Retriever", - "type": "Pinecone | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", - "name": "vectorStore", - "label": "Pinecone Vector Store", - "type": "Pinecone | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "vectorStore" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 267.45589163840236, - "y": -300.13817634747346 - }, - "dragging": false - }, - { - "width": 300, - "height": 506, - "id": "chromaExistingIndex_0", - "position": { - "x": 264.5271545331116, - "y": 246.32716342844174 - }, - "type": "customNode", - "data": { - "id": "chromaExistingIndex_0", - "label": "Chroma Load Existing Index", - "name": "chromaExistingIndex", - "version": 1, - "type": "Chroma", - "baseClasses": ["Chroma", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Load existing index from Chroma (i.e: Document has been upserted)", - "inputParams": [ - { - "label": "Collection Name", - "name": "collectionName", - "type": "string", - "id": "chromaExistingIndex_0-input-collectionName-string" - }, - { - "label": "Chroma URL", - "name": "chromaURL", - "type": "string", - "optional": true, - "id": "chromaExistingIndex_0-input-chromaURL-string" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "chromaExistingIndex_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "chromaExistingIndex_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "collectionName": "", - "chromaURL": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "chromaExistingIndex_0-output-retriever-Chroma|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Chroma Retriever", - "type": "Chroma | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "chromaExistingIndex_0-output-vectorStore-Chroma|VectorStore", - "name": "vectorStore", - "label": "Chroma Vector Store", - "type": "Chroma | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "vectorStore" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 264.5271545331116, - "y": 246.32716342844174 - }, - "dragging": false - }, { "width": 300, "height": 329, @@ -481,8 +281,8 @@ "data": { "id": "openAIEmbeddings_0", "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", "version": 1, + "name": "openAIEmbeddings", "type": "OpenAIEmbeddings", "baseClasses": ["OpenAIEmbeddings", "Embeddings"], "category": "Embeddings", @@ -555,133 +355,20 @@ }, { "width": 300, - "height": 702, - "id": "supabaseExistingIndex_0", - "position": { - "x": 270.90499551102573, - "y": 783.5053782099461 - }, - "type": "customNode", - "data": { - "id": "supabaseExistingIndex_0", - "label": "Supabase Load Existing Index", - "name": "supabaseExistingIndex", - "version": 1, - "type": "Supabase", - "baseClasses": ["Supabase", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Load existing index from Supabase (i.e: Document has been upserted)", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["supabaseApi"], - "id": "supabaseExistingIndex_0-input-credential-credential" - }, - { - "label": "Supabase Project URL", - "name": "supabaseProjUrl", - "type": "string", - "id": "supabaseExistingIndex_0-input-supabaseProjUrl-string" - }, - { - "label": "Table Name", - "name": "tableName", - "type": "string", - "id": "supabaseExistingIndex_0-input-tableName-string" - }, - { - "label": "Query Name", - "name": "queryName", - "type": "string", - "id": "supabaseExistingIndex_0-input-queryName-string" - }, - { - "label": "Supabase Metadata Filter", - "name": "supabaseMetadataFilter", - "type": "json", - "optional": true, - "additionalParams": true, - "id": "supabaseExistingIndex_0-input-supabaseMetadataFilter-json" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "supabaseExistingIndex_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "supabaseExistingIndex_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "supabaseProjUrl": "", - "tableName": "", - "queryName": "", - "supabaseMetadataFilter": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "supabaseExistingIndex_0-output-retriever-Supabase|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Supabase Retriever", - "type": "Supabase | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "supabaseExistingIndex_0-output-vectorStore-Supabase|VectorStore", - "name": "vectorStore", - "label": "Supabase Vector Store", - "type": "Supabase | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "vectorStore" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 270.90499551102573, - "y": 783.5053782099461 - }, - "dragging": false - }, - { - "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_0", "position": { - "x": 1154.0989175770958, - "y": -255.77769163789395 + "x": 1166.929741805626, + "y": -297.9691758089252 }, "type": "customNode", "data": { "id": "chatOpenAI_0", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], "category": "Chat Models", "description": "Wrapper around OpenAI large language models that use the Chat endpoint", "inputParams": [ @@ -701,6 +388,14 @@ "label": "gpt-4", "name": "gpt-4" }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, { "label": "gpt-4-0613", "name": "gpt-4-0613" @@ -717,6 +412,10 @@ "label": "gpt-3.5-turbo", "name": "gpt-3.5-turbo" }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, { "label": "gpt-3.5-turbo-0613", "name": "gpt-3.5-turbo-0613" @@ -738,6 +437,7 @@ "label": "Temperature", "name": "temperature", "type": "number", + "step": 0.1, "default": 0.9, "optional": true, "id": "chatOpenAI_0-input-temperature-number" @@ -746,6 +446,7 @@ "label": "Max Tokens", "name": "maxTokens", "type": "number", + "step": 1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-maxTokens-number" @@ -754,6 +455,7 @@ "label": "Top Probability", "name": "topP", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-topP-number" @@ -762,6 +464,7 @@ "label": "Frequency Penalty", "name": "frequencyPenalty", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-frequencyPenalty-number" @@ -770,6 +473,7 @@ "label": "Presence Penalty", "name": "presencePenalty", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-presencePenalty-number" @@ -778,6 +482,7 @@ "label": "Timeout", "name": "timeout", "type": "number", + "step": 1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-timeout-number" @@ -789,6 +494,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -801,6 +514,7 @@ } ], "inputs": { + "cache": "", "modelName": "gpt-3.5-turbo", "temperature": 0.9, "maxTokens": "", @@ -808,14 +522,15 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", "name": "chatOpenAI", "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel" + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" } ], "outputs": {}, @@ -823,8 +538,366 @@ }, "selected": false, "positionAbsolute": { - "x": 1154.0989175770958, - "y": -255.77769163789395 + "x": 1166.929741805626, + "y": -297.9691758089252 + }, + "dragging": false + }, + { + "width": 300, + "height": 555, + "id": "pinecone_0", + "position": { + "x": 261.3144465918519, + "y": -333.57075989595313 + }, + "type": "customNode", + "data": { + "id": "pinecone_0", + "label": "Pinecone", + "version": 1, + "name": "pinecone", + "type": "Pinecone", + "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Pinecone, a leading fully managed hosted vector database", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["pineconeApi"], + "id": "pinecone_0-input-credential-credential" + }, + { + "label": "Pinecone Index", + "name": "pineconeIndex", + "type": "string", + "id": "pinecone_0-input-pineconeIndex-string" + }, + { + "label": "Pinecone Namespace", + "name": "pineconeNamespace", + "type": "string", + "placeholder": "my-first-namespace", + "additionalParams": true, + "optional": true, + "id": "pinecone_0-input-pineconeNamespace-string" + }, + { + "label": "Pinecone Metadata Filter", + "name": "pineconeMetadataFilter", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "pinecone_0-input-pineconeMetadataFilter-json" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Default to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "pinecone_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "pinecone_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "pinecone_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": "", + "embeddings": "{{openAIEmbeddings_0.data.instance}}", + "pineconeIndex": "", + "pineconeNamespace": "", + "pineconeMetadataFilter": "", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Pinecone Retriever", + "type": "Pinecone | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "pinecone_0-output-vectorStore-Pinecone|VectorStore", + "name": "vectorStore", + "label": "Pinecone Vector Store", + "type": "Pinecone | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "vectorStore" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 261.3144465918519, + "y": -333.57075989595313 + }, + "dragging": false + }, + { + "width": 300, + "height": 654, + "id": "chroma_0", + "position": { + "x": 263.5395455972911, + "y": 242.72988251281214 + }, + "type": "customNode", + "data": { + "id": "chroma_0", + "label": "Chroma", + "version": 1, + "name": "chroma", + "type": "Chroma", + "baseClasses": ["Chroma", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Chroma, an open-source embedding database", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "description": "Only needed if you have chroma on cloud services with X-Api-key", + "optional": true, + "credentialNames": ["chromaApi"], + "id": "chroma_0-input-credential-credential" + }, + { + "label": "Collection Name", + "name": "collectionName", + "type": "string", + "id": "chroma_0-input-collectionName-string" + }, + { + "label": "Chroma URL", + "name": "chromaURL", + "type": "string", + "optional": true, + "id": "chroma_0-input-chromaURL-string" + }, + { + "label": "Chroma Metadata Filter", + "name": "chromaMetadataFilter", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chroma_0-input-chromaMetadataFilter-json" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Default to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "chroma_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "chroma_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "chroma_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": "", + "embeddings": "{{openAIEmbeddings_0.data.instance}}", + "collectionName": "", + "chromaURL": "", + "chromaMetadataFilter": "", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "chroma_0-output-retriever-Chroma|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Chroma Retriever", + "type": "Chroma | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "chroma_0-output-vectorStore-Chroma|VectorStore", + "name": "vectorStore", + "label": "Chroma Vector Store", + "type": "Chroma | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "vectorStore" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 263.5395455972911, + "y": 242.72988251281214 + }, + "dragging": false + }, + { + "width": 300, + "height": 753, + "id": "supabase_0", + "position": { + "x": 263.16882559270005, + "y": 920.6999513218148 + }, + "type": "customNode", + "data": { + "id": "supabase_0", + "label": "Supabase", + "version": 1, + "name": "supabase", + "type": "Supabase", + "baseClasses": ["Supabase", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Supabase via pgvector extension", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["supabaseApi"], + "id": "supabase_0-input-credential-credential" + }, + { + "label": "Supabase Project URL", + "name": "supabaseProjUrl", + "type": "string", + "id": "supabase_0-input-supabaseProjUrl-string" + }, + { + "label": "Table Name", + "name": "tableName", + "type": "string", + "id": "supabase_0-input-tableName-string" + }, + { + "label": "Query Name", + "name": "queryName", + "type": "string", + "id": "supabase_0-input-queryName-string" + }, + { + "label": "Supabase Metadata Filter", + "name": "supabaseMetadataFilter", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "supabase_0-input-supabaseMetadataFilter-json" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Default to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "supabase_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "supabase_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "supabase_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": "", + "embeddings": "{{openAIEmbeddings_0.data.instance}}", + "supabaseProjUrl": "", + "tableName": "", + "queryName": "", + "supabaseMetadataFilter": "", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "supabase_0-output-retriever-Supabase|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Supabase Retriever", + "type": "Supabase | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "supabase_0-output-vectorStore-Supabase|VectorStore", + "name": "vectorStore", + "label": "Supabase Vector Store", + "type": "Supabase | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "vectorStore" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 263.16882559270005, + "y": 920.6999513218148 }, "dragging": false } @@ -863,79 +936,79 @@ "label": "" } }, - { - "source": "pineconeExistingIndex_0", - "sourceHandle": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", - "target": "vectorStoreRetriever_2", - "targetHandle": "vectorStoreRetriever_2-input-vectorStore-VectorStore", - "type": "buttonedge", - "id": "pineconeExistingIndex_0-pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore-vectorStoreRetriever_2-vectorStoreRetriever_2-input-vectorStore-VectorStore", - "data": { - "label": "" - } - }, - { - "source": "chromaExistingIndex_0", - "sourceHandle": "chromaExistingIndex_0-output-vectorStore-Chroma|VectorStore", - "target": "vectorStoreRetriever_1", - "targetHandle": "vectorStoreRetriever_1-input-vectorStore-VectorStore", - "type": "buttonedge", - "id": "chromaExistingIndex_0-chromaExistingIndex_0-output-vectorStore-Chroma|VectorStore-vectorStoreRetriever_1-vectorStoreRetriever_1-input-vectorStore-VectorStore", - "data": { - "label": "" - } - }, - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeExistingIndex_0", - "targetHandle": "pineconeExistingIndex_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeExistingIndex_0-pineconeExistingIndex_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "chromaExistingIndex_0", - "targetHandle": "chromaExistingIndex_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-chromaExistingIndex_0-chromaExistingIndex_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "supabaseExistingIndex_0", - "targetHandle": "supabaseExistingIndex_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-supabaseExistingIndex_0-supabaseExistingIndex_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, - { - "source": "supabaseExistingIndex_0", - "sourceHandle": "supabaseExistingIndex_0-output-vectorStore-Supabase|VectorStore", - "target": "vectorStoreRetriever_0", - "targetHandle": "vectorStoreRetriever_0-input-vectorStore-VectorStore", - "type": "buttonedge", - "id": "supabaseExistingIndex_0-supabaseExistingIndex_0-output-vectorStore-Supabase|VectorStore-vectorStoreRetriever_0-vectorStoreRetriever_0-input-vectorStore-VectorStore", - "data": { - "label": "" - } - }, { "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", "target": "multiRetrievalQAChain_0", "targetHandle": "multiRetrievalQAChain_0-input-model-BaseLanguageModel", "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-multiRetrievalQAChain_0-multiRetrievalQAChain_0-input-model-BaseLanguageModel", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-multiRetrievalQAChain_0-multiRetrievalQAChain_0-input-model-BaseLanguageModel", + "data": { + "label": "" + } + }, + { + "source": "pinecone_0", + "sourceHandle": "pinecone_0-output-vectorStore-Pinecone|VectorStore", + "target": "vectorStoreRetriever_2", + "targetHandle": "vectorStoreRetriever_2-input-vectorStore-VectorStore", + "type": "buttonedge", + "id": "pinecone_0-pinecone_0-output-vectorStore-Pinecone|VectorStore-vectorStoreRetriever_2-vectorStoreRetriever_2-input-vectorStore-VectorStore", + "data": { + "label": "" + } + }, + { + "source": "chroma_0", + "sourceHandle": "chroma_0-output-vectorStore-Chroma|VectorStore", + "target": "vectorStoreRetriever_1", + "targetHandle": "vectorStoreRetriever_1-input-vectorStore-VectorStore", + "type": "buttonedge", + "id": "chroma_0-chroma_0-output-vectorStore-Chroma|VectorStore-vectorStoreRetriever_1-vectorStoreRetriever_1-input-vectorStore-VectorStore", + "data": { + "label": "" + } + }, + { + "source": "supabase_0", + "sourceHandle": "supabase_0-output-vectorStore-Supabase|VectorStore", + "target": "vectorStoreRetriever_0", + "targetHandle": "vectorStoreRetriever_0-input-vectorStore-VectorStore", + "type": "buttonedge", + "id": "supabase_0-supabase_0-output-vectorStore-Supabase|VectorStore-vectorStoreRetriever_0-vectorStoreRetriever_0-input-vectorStore-VectorStore", + "data": { + "label": "" + } + }, + { + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "supabase_0", + "targetHandle": "supabase_0-input-embeddings-Embeddings", + "type": "buttonedge", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-supabase_0-supabase_0-input-embeddings-Embeddings", + "data": { + "label": "" + } + }, + { + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "chroma_0", + "targetHandle": "chroma_0-input-embeddings-Embeddings", + "type": "buttonedge", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-chroma_0-chroma_0-input-embeddings-Embeddings", + "data": { + "label": "" + } + }, + { + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-embeddings-Embeddings", + "type": "buttonedge", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pinecone_0-pinecone_0-input-embeddings-Embeddings", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/Multiple VectorDB.json b/packages/server/marketplaces/chatflows/Multiple VectorDB.json index b4dedfdd..789b0c08 100644 --- a/packages/server/marketplaces/chatflows/Multiple VectorDB.json +++ b/packages/server/marketplaces/chatflows/Multiple VectorDB.json @@ -13,8 +13,8 @@ "data": { "id": "chainTool_2", "label": "Chain Tool", - "name": "chainTool", "version": 1, + "name": "chainTool", "type": "ChainTool", "baseClasses": ["ChainTool", "DynamicTool", "Tool", "StructuredTool", "BaseLangChain"], "category": "Tools", @@ -80,15 +80,15 @@ "height": 602, "id": "chainTool_3", "position": { - "x": 1267.7142132085273, - "y": -85.7749282485849 + "x": 1255.0365190596667, + "y": -79.4360811741546 }, "type": "customNode", "data": { "id": "chainTool_3", "label": "Chain Tool", - "name": "chainTool", "version": 1, + "name": "chainTool", "type": "ChainTool", "baseClasses": ["ChainTool", "DynamicTool", "Tool", "StructuredTool", "BaseLangChain"], "category": "Tools", @@ -127,7 +127,7 @@ ], "inputs": { "name": "state-of-union-qa", - "description": "State of the Union QA - useful for when you need to ask questions about the most recent state of the union address.", + "description": "State of the Union QA - useful for when you need to ask questions about the president speech and most recent state of the union address.", "returnDirect": "", "baseChain": "{{retrievalQAChain_1.data.instance}}" }, @@ -145,66 +145,10 @@ "selected": false, "dragging": false, "positionAbsolute": { - "x": 1267.7142132085273, - "y": -85.7749282485849 + "x": 1255.0365190596667, + "y": -79.4360811741546 } }, - { - "width": 300, - "height": 280, - "id": "mrklAgentLLM_0", - "position": { - "x": 2061.891333395338, - "y": -140.0694021759809 - }, - "type": "customNode", - "data": { - "id": "mrklAgentLLM_0", - "label": "MRKL Agent for LLMs", - "name": "mrklAgentLLM", - "version": 1, - "type": "AgentExecutor", - "baseClasses": ["AgentExecutor", "BaseChain", "BaseLangChain"], - "category": "Agents", - "description": "Agent that uses the ReAct Framework to decide what action to take, optimized to be used with LLMs", - "inputParams": [], - "inputAnchors": [ - { - "label": "Allowed Tools", - "name": "tools", - "type": "Tool", - "list": true, - "id": "mrklAgentLLM_0-input-tools-Tool" - }, - { - "label": "Language Model", - "name": "model", - "type": "BaseLanguageModel", - "id": "mrklAgentLLM_0-input-model-BaseLanguageModel" - } - ], - "inputs": { - "tools": ["{{chainTool_2.data.instance}}", "{{chainTool_3.data.instance}}"], - "model": "{{openAI_4.data.instance}}" - }, - "outputAnchors": [ - { - "id": "mrklAgentLLM_0-output-mrklAgentLLM-AgentExecutor|BaseChain|BaseLangChain", - "name": "mrklAgentLLM", - "label": "AgentExecutor", - "type": "AgentExecutor | BaseChain | BaseLangChain" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 2061.891333395338, - "y": -140.0694021759809 - }, - "dragging": false - }, { "width": 300, "height": 280, @@ -217,8 +161,8 @@ "data": { "id": "retrievalQAChain_0", "label": "Retrieval QA Chain", - "name": "retrievalQAChain", "version": 1, + "name": "retrievalQAChain", "type": "RetrievalQAChain", "baseClasses": ["RetrievalQAChain", "BaseChain", "BaseLangChain"], "category": "Chains", @@ -239,8 +183,8 @@ } ], "inputs": { - "model": "{{openAI_2.data.instance}}", - "vectorStoreRetriever": "{{chromaExistingIndex_0.data.instance}}" + "model": "{{chatOpenAI_0.data.instance}}", + "vectorStoreRetriever": "{{redis_0.data.instance}}" }, "outputAnchors": [ { @@ -265,15 +209,15 @@ "height": 280, "id": "retrievalQAChain_1", "position": { - "x": 895.4349543765911, - "y": 166.60331503487222 + "x": 903.8867504758316, + "y": 380.0111665406929 }, "type": "customNode", "data": { "id": "retrievalQAChain_1", "label": "Retrieval QA Chain", - "name": "retrievalQAChain", "version": 1, + "name": "retrievalQAChain", "type": "RetrievalQAChain", "baseClasses": ["RetrievalQAChain", "BaseChain", "BaseLangChain"], "category": "Chains", @@ -294,8 +238,8 @@ } ], "inputs": { - "model": "{{openAI_3.data.instance}}", - "vectorStoreRetriever": "{{pineconeExistingIndex_0.data.instance}}" + "model": "{{chatOpenAI_1.data.instance}}", + "vectorStoreRetriever": "{{faiss_0.data.instance}}" }, "outputAnchors": [ { @@ -310,168 +254,8 @@ }, "selected": false, "positionAbsolute": { - "x": 895.4349543765911, - "y": 166.60331503487222 - }, - "dragging": false - }, - { - "width": 300, - "height": 523, - "id": "openAI_2", - "position": { - "x": 520.8471510168988, - "y": -1362.1183473852964 - }, - "type": "customNode", - "data": { - "id": "openAI_2", - "label": "OpenAI", - "name": "openAI", - "version": 3, - "type": "OpenAI", - "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], - "category": "LLMs", - "description": "Wrapper around OpenAI large language models", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "openAI_2-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-3.5-turbo-instruct", - "name": "gpt-3.5-turbo-instruct" - }, - { - "label": "babbage-002", - "name": "babbage-002" - }, - { - "label": "davinci-002", - "name": "davinci-002" - } - ], - "default": "gpt-3.5-turbo-instruct", - "optional": true, - "id": "openAI_2-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.7, - "optional": true, - "id": "openAI_2-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_2-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_2-input-topP-number" - }, - { - "label": "Best Of", - "name": "bestOf", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_2-input-bestOf-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_2-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_2-input-presencePenalty-number" - }, - { - "label": "Batch Size", - "name": "batchSize", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_2-input-batchSize-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_2-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "openAI_2-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "openAI_2-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo-instruct", - "temperature": 0.7, - "maxTokens": "", - "topP": "", - "bestOf": "", - "frequencyPenalty": "", - "presencePenalty": "", - "batchSize": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "openAI_2-output-openAI-OpenAI|BaseLLM|BaseLanguageModel", - "name": "openAI", - "label": "OpenAI", - "type": "OpenAI | BaseLLM | BaseLanguageModel" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 520.8471510168988, - "y": -1362.1183473852964 + "x": 903.8867504758316, + "y": 380.0111665406929 }, "dragging": false }, @@ -480,15 +264,15 @@ "height": 329, "id": "openAIEmbeddings_1", "position": { - "x": 148.65789308409916, - "y": -915.1982675859331 + "x": 100.06006551346672, + "y": -686.9997729064416 }, "type": "customNode", "data": { "id": "openAIEmbeddings_1", "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", "version": 1, + "name": "openAIEmbeddings", "type": "OpenAIEmbeddings", "baseClasses": ["OpenAIEmbeddings", "Embeddings"], "category": "Embeddings", @@ -554,99 +338,8 @@ }, "selected": false, "positionAbsolute": { - "x": 148.65789308409916, - "y": -915.1982675859331 - }, - "dragging": false - }, - { - "width": 300, - "height": 506, - "id": "chromaExistingIndex_0", - "position": { - "x": 509.55198017578016, - "y": -782.42003311752 - }, - "type": "customNode", - "data": { - "id": "chromaExistingIndex_0", - "label": "Chroma Load Existing Index", - "name": "chromaExistingIndex", - "version": 1, - "type": "Chroma", - "baseClasses": ["Chroma", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Load existing index from Chroma (i.e: Document has been upserted)", - "inputParams": [ - { - "label": "Collection Name", - "name": "collectionName", - "type": "string", - "id": "chromaExistingIndex_0-input-collectionName-string" - }, - { - "label": "Chroma URL", - "name": "chromaURL", - "type": "string", - "optional": true, - "id": "chromaExistingIndex_0-input-chromaURL-string" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "chromaExistingIndex_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "chromaExistingIndex_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "embeddings": "{{openAIEmbeddings_1.data.instance}}", - "collectionName": "", - "chromaURL": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "chromaExistingIndex_0-output-retriever-Chroma|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Chroma Retriever", - "type": "Chroma | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "chromaExistingIndex_0-output-vectorStore-Chroma|VectorStore", - "name": "vectorStore", - "label": "Chroma Vector Store", - "type": "Chroma | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "retriever" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 509.55198017578016, - "y": -782.42003311752 + "x": 100.06006551346672, + "y": -686.9997729064416 }, "dragging": false }, @@ -655,15 +348,15 @@ "height": 329, "id": "openAIEmbeddings_2", "position": { - "x": 128.85404348918783, - "y": 155.96043384682295 + "x": 126.74109446437771, + "y": 542.6301053870723 }, "type": "customNode", "data": { "id": "openAIEmbeddings_2", "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", "version": 1, + "name": "openAIEmbeddings", "type": "OpenAIEmbeddings", "baseClasses": ["OpenAIEmbeddings", "Embeddings"], "category": "Embeddings", @@ -729,36 +422,36 @@ }, "selected": false, "positionAbsolute": { - "x": 128.85404348918783, - "y": 155.96043384682295 + "x": 126.74109446437771, + "y": 542.6301053870723 }, "dragging": false }, { "width": 300, - "height": 523, - "id": "openAI_3", + "height": 574, + "id": "chatOpenAI_0", "position": { - "x": 504.808358369027, - "y": -257.78194663790197 + "x": 518.3288471761277, + "y": -1348.530642047776 }, "type": "customNode", "data": { - "id": "openAI_3", - "label": "OpenAI", - "name": "openAI", - "version": 3, - "type": "OpenAI", - "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], - "category": "LLMs", - "description": "Wrapper around OpenAI large language models", + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", "inputParams": [ { "label": "Connect Credential", "name": "credential", "type": "credential", "credentialNames": ["openAIApi"], - "id": "openAI_3-input-credential-credential" + "id": "chatOpenAI_0-input-credential-credential" }, { "label": "Model Name", @@ -766,85 +459,107 @@ "type": "options", "options": [ { - "label": "gpt-3.5-turbo-instruct", - "name": "gpt-3.5-turbo-instruct" + "label": "gpt-4", + "name": "gpt-4" }, { - "label": "babbage-002", - "name": "babbage-002" + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" }, { - "label": "davinci-002", - "name": "davinci-002" + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" } ], - "default": "gpt-3.5-turbo-instruct", + "default": "gpt-3.5-turbo", "optional": true, - "id": "openAI_3-input-modelName-options" + "id": "chatOpenAI_0-input-modelName-options" }, { "label": "Temperature", "name": "temperature", "type": "number", - "default": 0.7, + "step": 0.1, + "default": 0.9, "optional": true, - "id": "openAI_3-input-temperature-number" + "id": "chatOpenAI_0-input-temperature-number" }, { "label": "Max Tokens", "name": "maxTokens", "type": "number", + "step": 1, "optional": true, "additionalParams": true, - "id": "openAI_3-input-maxTokens-number" + "id": "chatOpenAI_0-input-maxTokens-number" }, { "label": "Top Probability", "name": "topP", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, - "id": "openAI_3-input-topP-number" - }, - { - "label": "Best Of", - "name": "bestOf", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_3-input-bestOf-number" + "id": "chatOpenAI_0-input-topP-number" }, { "label": "Frequency Penalty", "name": "frequencyPenalty", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, - "id": "openAI_3-input-frequencyPenalty-number" + "id": "chatOpenAI_0-input-frequencyPenalty-number" }, { "label": "Presence Penalty", "name": "presencePenalty", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, - "id": "openAI_3-input-presencePenalty-number" - }, - { - "label": "Batch Size", - "name": "batchSize", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_3-input-batchSize-number" + "id": "chatOpenAI_0-input-presencePenalty-number" }, { "label": "Timeout", "name": "timeout", "type": "number", + "step": 1, "optional": true, "additionalParams": true, - "id": "openAI_3-input-timeout-number" + "id": "chatOpenAI_0-input-timeout-number" }, { "label": "BasePath", @@ -852,7 +567,15 @@ "type": "string", "optional": true, "additionalParams": true, - "id": "openAI_3-input-basepath-string" + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -861,27 +584,27 @@ "name": "cache", "type": "BaseCache", "optional": true, - "id": "openAI_3-input-cache-BaseCache" + "id": "chatOpenAI_0-input-cache-BaseCache" } ], "inputs": { - "modelName": "gpt-3.5-turbo-instruct", - "temperature": 0.7, + "cache": "", + "modelName": "gpt-3.5-turbo-16k", + "temperature": 0.9, "maxTokens": "", "topP": "", - "bestOf": "", "frequencyPenalty": "", "presencePenalty": "", - "batchSize": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { - "id": "openAI_3-output-openAI-OpenAI|BaseLLM|BaseLanguageModel", - "name": "openAI", - "label": "OpenAI", - "type": "OpenAI | BaseLLM | BaseLanguageModel" + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" } ], "outputs": {}, @@ -889,59 +612,81 @@ }, "selected": false, "positionAbsolute": { - "x": 504.808358369027, - "y": -257.78194663790197 + "x": 518.3288471761277, + "y": -1348.530642047776 }, "dragging": false }, { "width": 300, - "height": 505, - "id": "pineconeExistingIndex_0", + "height": 652, + "id": "redis_0", "position": { - "x": 507.5206146177215, - "y": 343.07818128024616 + "x": 526.7806432753682, + "y": -759.0178641257562 }, "type": "customNode", "data": { - "id": "pineconeExistingIndex_0", - "label": "Pinecone Load Existing Index", - "name": "pineconeExistingIndex", + "id": "redis_0", + "label": "Redis", "version": 1, - "type": "Pinecone", - "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], + "name": "redis", + "type": "Redis", + "baseClasses": ["Redis", "VectorStoreRetriever", "BaseRetriever"], "category": "Vector Stores", - "description": "Load existing index from Pinecone (i.e: Document has been upserted)", + "description": "Upsert embedded data and perform similarity search upon query using Redis, an open source, in-memory data structure store", "inputParams": [ { "label": "Connect Credential", "name": "credential", "type": "credential", - "credentialNames": ["pineconeApi"], - "id": "pineconeExistingIndex_0-input-credential-credential" + "credentialNames": ["redisCacheUrlApi", "redisCacheApi"], + "id": "redis_0-input-credential-credential" }, { - "label": "Pinecone Index", - "name": "pineconeIndex", + "label": "Index Name", + "name": "indexName", + "placeholder": "", "type": "string", - "id": "pineconeExistingIndex_0-input-pineconeIndex-string" + "id": "redis_0-input-indexName-string" }, { - "label": "Pinecone Namespace", - "name": "pineconeNamespace", + "label": "Replace Index on Upsert", + "name": "replaceIndex", + "description": "Selecting this option will delete the existing index and recreate a new one when upserting", + "default": false, + "type": "boolean", + "id": "redis_0-input-replaceIndex-boolean" + }, + { + "label": "Content Field", + "name": "contentKey", + "description": "Name of the field (column) that contains the actual content", "type": "string", - "placeholder": "my-first-namespace", + "default": "content", "additionalParams": true, "optional": true, - "id": "pineconeExistingIndex_0-input-pineconeNamespace-string" + "id": "redis_0-input-contentKey-string" }, { - "label": "Pinecone Metadata Filter", - "name": "pineconeMetadataFilter", - "type": "json", - "optional": true, + "label": "Metadata Field", + "name": "metadataKey", + "description": "Name of the field (column) that contains the metadata of the document", + "type": "string", + "default": "metadata", "additionalParams": true, - "id": "pineconeExistingIndex_0-input-pineconeMetadataFilter-json" + "optional": true, + "id": "redis_0-input-metadataKey-string" + }, + { + "label": "Vector Field", + "name": "vectorKey", + "description": "Name of the field (column) that contains the vector", + "type": "string", + "default": "content_vector", + "additionalParams": true, + "optional": true, + "id": "redis_0-input-vectorKey-string" }, { "label": "Top K", @@ -951,22 +696,33 @@ "type": "number", "additionalParams": true, "optional": true, - "id": "pineconeExistingIndex_0-input-topK-number" + "id": "redis_0-input-topK-number" } ], "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "redis_0-input-document-Document" + }, { "label": "Embeddings", "name": "embeddings", "type": "Embeddings", - "id": "pineconeExistingIndex_0-input-embeddings-Embeddings" + "id": "redis_0-input-embeddings-Embeddings" } ], "inputs": { - "embeddings": "{{openAIEmbeddings_2.data.instance}}", - "pineconeIndex": "", - "pineconeNamespace": "", - "pineconeMetadataFilter": "", + "document": ["{{plainText_0.data.instance}}"], + "embeddings": "{{openAIEmbeddings_1.data.instance}}", + "indexName": "redis-1234", + "replaceIndex": true, + "contentKey": "content", + "metadataKey": "metadata", + "vectorKey": "content_vector", "topK": "" }, "outputAnchors": [ @@ -976,16 +732,16 @@ "type": "options", "options": [ { - "id": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "id": "redis_0-output-retriever-Redis|VectorStoreRetriever|BaseRetriever", "name": "retriever", - "label": "Pinecone Retriever", - "type": "Pinecone | VectorStoreRetriever | BaseRetriever" + "label": "Redis Retriever", + "type": "Redis | VectorStoreRetriever | BaseRetriever" }, { - "id": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", + "id": "redis_0-output-vectorStore-Redis|VectorStore", "name": "vectorStore", - "label": "Pinecone Vector Store", - "type": "Pinecone | VectorStore" + "label": "Redis Vector Store", + "type": "Redis | VectorStore" } ], "default": "retriever" @@ -998,36 +754,214 @@ }, "selected": false, "positionAbsolute": { - "x": 507.5206146177215, - "y": 343.07818128024616 + "x": 526.7806432753682, + "y": -759.0178641257562 }, "dragging": false }, { "width": 300, - "height": 523, - "id": "openAI_4", + "height": 458, + "id": "faiss_0", "position": { - "x": 1619.5346765785587, - "y": 352.29615581180684 + "x": 533.1194903497986, + "y": 508.751550760307 }, "type": "customNode", "data": { - "id": "openAI_4", - "label": "OpenAI", - "name": "openAI", - "version": 3, - "type": "OpenAI", - "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], - "category": "LLMs", - "description": "Wrapper around OpenAI large language models", + "id": "faiss_0", + "label": "Faiss", + "version": 1, + "name": "faiss", + "type": "Faiss", + "baseClasses": ["Faiss", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Faiss library from Meta", + "inputParams": [ + { + "label": "Base Path to load", + "name": "basePath", + "description": "Path to load faiss.index file", + "placeholder": "C:\\Users\\User\\Desktop", + "type": "string", + "id": "faiss_0-input-basePath-string" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Default to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "faiss_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "faiss_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "faiss_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": ["{{plainText_1.data.instance}}"], + "embeddings": "{{openAIEmbeddings_2.data.instance}}", + "basePath": "C:\\Users\\user\\yourpath", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "faiss_0-output-retriever-Faiss|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Faiss Retriever", + "type": "Faiss | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "faiss_0-output-vectorStore-Faiss|SaveableVectorStore|VectorStore", + "name": "vectorStore", + "label": "Faiss Vector Store", + "type": "Faiss | SaveableVectorStore | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "retriever" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 533.1194903497986, + "y": 508.751550760307 + }, + "dragging": false + }, + { + "width": 300, + "height": 485, + "id": "plainText_0", + "position": { + "x": 93.6260931892966, + "y": -1209.0760064103088 + }, + "type": "customNode", + "data": { + "id": "plainText_0", + "label": "Plain Text", + "version": 2, + "name": "plainText", + "type": "Document", + "baseClasses": ["Document"], + "category": "Document Loaders", + "description": "Load data from plain text", + "inputParams": [ + { + "label": "Text", + "name": "text", + "type": "string", + "rows": 4, + "placeholder": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...", + "id": "plainText_0-input-text-string" + }, + { + "label": "Metadata", + "name": "metadata", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "plainText_0-input-metadata-json" + } + ], + "inputAnchors": [ + { + "label": "Text Splitter", + "name": "textSplitter", + "type": "TextSplitter", + "optional": true, + "id": "plainText_0-input-textSplitter-TextSplitter" + } + ], + "inputs": { + "text": "AI-generated content refers to text, images, videos, or other media produced by artificial intelligence algorithms. It leverages deep learning and natural language processing to create human-like content autonomously. AI-generated content has diverse applications, from automated customer support chatbots and personalized marketing to creative writing and art generation. While it offers efficiency and scalability, it also raises concerns about ethics, authenticity, and potential misuse. Striking a balance between harnessing its potential for productivity and addressing its ethical implications is crucial as AI-generated content continues to evolve and reshape industries.", + "textSplitter": "", + "metadata": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "plainText_0-output-document-Document", + "name": "document", + "label": "Document", + "type": "Document" + }, + { + "id": "plainText_0-output-text-string|json", + "name": "text", + "label": "Text", + "type": "string | json" + } + ], + "default": "document" + } + ], + "outputs": { + "output": "document" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 93.6260931892966, + "y": -1209.0760064103088 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_1", + "position": { + "x": 531.5715383965282, + "y": -87.77517816462955 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_1", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", "inputParams": [ { "label": "Connect Credential", "name": "credential", "type": "credential", "credentialNames": ["openAIApi"], - "id": "openAI_4-input-credential-credential" + "id": "chatOpenAI_1-input-credential-credential" }, { "label": "Model Name", @@ -1035,85 +969,107 @@ "type": "options", "options": [ { - "label": "gpt-3.5-turbo-instruct", - "name": "gpt-3.5-turbo-instruct" + "label": "gpt-4", + "name": "gpt-4" }, { - "label": "babbage-002", - "name": "babbage-002" + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" }, { - "label": "davinci-002", - "name": "davinci-002" + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" } ], - "default": "gpt-3.5-turbo-instruct", + "default": "gpt-3.5-turbo", "optional": true, - "id": "openAI_4-input-modelName-options" + "id": "chatOpenAI_1-input-modelName-options" }, { "label": "Temperature", "name": "temperature", "type": "number", - "default": 0.7, + "step": 0.1, + "default": 0.9, "optional": true, - "id": "openAI_4-input-temperature-number" + "id": "chatOpenAI_1-input-temperature-number" }, { "label": "Max Tokens", "name": "maxTokens", "type": "number", + "step": 1, "optional": true, "additionalParams": true, - "id": "openAI_4-input-maxTokens-number" + "id": "chatOpenAI_1-input-maxTokens-number" }, { "label": "Top Probability", "name": "topP", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, - "id": "openAI_4-input-topP-number" - }, - { - "label": "Best Of", - "name": "bestOf", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_4-input-bestOf-number" + "id": "chatOpenAI_1-input-topP-number" }, { "label": "Frequency Penalty", "name": "frequencyPenalty", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, - "id": "openAI_4-input-frequencyPenalty-number" + "id": "chatOpenAI_1-input-frequencyPenalty-number" }, { "label": "Presence Penalty", "name": "presencePenalty", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, - "id": "openAI_4-input-presencePenalty-number" - }, - { - "label": "Batch Size", - "name": "batchSize", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_4-input-batchSize-number" + "id": "chatOpenAI_1-input-presencePenalty-number" }, { "label": "Timeout", "name": "timeout", "type": "number", + "step": 1, "optional": true, "additionalParams": true, - "id": "openAI_4-input-timeout-number" + "id": "chatOpenAI_1-input-timeout-number" }, { "label": "BasePath", @@ -1121,7 +1077,15 @@ "type": "string", "optional": true, "additionalParams": true, - "id": "openAI_4-input-basepath-string" + "id": "chatOpenAI_1-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-baseOptions-json" } ], "inputAnchors": [ @@ -1130,27 +1094,27 @@ "name": "cache", "type": "BaseCache", "optional": true, - "id": "openAI_4-input-cache-BaseCache" + "id": "chatOpenAI_1-input-cache-BaseCache" } ], "inputs": { - "modelName": "gpt-3.5-turbo-instruct", - "temperature": 0.7, + "cache": "", + "modelName": "gpt-3.5-turbo-16k", + "temperature": 0.9, "maxTokens": "", "topP": "", - "bestOf": "", "frequencyPenalty": "", "presencePenalty": "", - "batchSize": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { - "id": "openAI_4-output-openAI-OpenAI|BaseLLM|BaseLanguageModel", - "name": "openAI", - "label": "OpenAI", - "type": "OpenAI | BaseLLM | BaseLanguageModel" + "id": "chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" } ], "outputs": {}, @@ -1158,35 +1122,489 @@ }, "selected": false, "positionAbsolute": { - "x": 1619.5346765785587, - "y": 352.29615581180684 + "x": 531.5715383965282, + "y": -87.77517816462955 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_2", + "position": { + "x": 1628.7151156632485, + "y": 281.9500435520215 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_2", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_2-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_2-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_2-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_2-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_2-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_2-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_2-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_2-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_2-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_2-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_2-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo-16k", + "temperature": 0.9, + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1628.7151156632485, + "y": 281.9500435520215 + }, + "dragging": false + }, + { + "width": 300, + "height": 376, + "id": "bufferMemory_0", + "position": { + "x": 1996.4899941465392, + "y": 466.6000826492595 + }, + "type": "customNode", + "data": { + "id": "bufferMemory_0", + "label": "Buffer Memory", + "version": 1, + "name": "bufferMemory", + "type": "BufferMemory", + "baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"], + "category": "Memory", + "description": "Remembers previous conversational back and forths directly", + "inputParams": [ + { + "label": "Memory Key", + "name": "memoryKey", + "type": "string", + "default": "chat_history", + "id": "bufferMemory_0-input-memoryKey-string" + }, + { + "label": "Input Key", + "name": "inputKey", + "type": "string", + "default": "input", + "id": "bufferMemory_0-input-inputKey-string" + } + ], + "inputAnchors": [], + "inputs": { + "memoryKey": "chat_history", + "inputKey": "input" + }, + "outputAnchors": [ + { + "id": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", + "name": "bufferMemory", + "label": "BufferMemory", + "type": "BufferMemory | BaseChatMemory | BaseMemory" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1996.4899941465392, + "y": 466.6000826492595 + }, + "dragging": false + }, + { + "width": 300, + "height": 485, + "id": "plainText_1", + "position": { + "x": 117.23894449422778, + "y": 23.24339894687961 + }, + "type": "customNode", + "data": { + "id": "plainText_1", + "label": "Plain Text", + "version": 2, + "name": "plainText", + "type": "Document", + "baseClasses": ["Document"], + "category": "Document Loaders", + "description": "Load data from plain text", + "inputParams": [ + { + "label": "Text", + "name": "text", + "type": "string", + "rows": 4, + "placeholder": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...", + "id": "plainText_1-input-text-string" + }, + { + "label": "Metadata", + "name": "metadata", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "plainText_1-input-metadata-json" + } + ], + "inputAnchors": [ + { + "label": "Text Splitter", + "name": "textSplitter", + "type": "TextSplitter", + "optional": true, + "id": "plainText_1-input-textSplitter-TextSplitter" + } + ], + "inputs": { + "text": "Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \n\nLast year COVID-19 kept us apart. This year we are finally together again. \n\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \n\nWith a duty to one another to the American people to the Constitution. \n\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \n\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \n\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \n\nHe met the Ukrainian people. \n\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world. \n\nGroups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. \n\nIn this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight. \n\nLet each of us here tonight in this Chamber send an unmistakable signal to Ukraine and to the world. \n\nPlease rise if you are able and show that, Yes, we the United States of America stand with the Ukrainian people. \n\nThroughout our history we’ve learned this lesson when dictators do not pay a price for their aggression they cause more chaos. \n\nThey keep moving. \n\nAnd the costs and the threats to America and the world keep rising. \n\nThat’s why the NATO Alliance was created to secure peace and stability in Europe after World War 2. \n\nThe United States is a member along with 29 other nations. \n\nIt matters. American diplomacy matters. American resolve matters. \n\nPutin’s latest attack on Ukraine was premeditated and unprovoked. \n\nHe rejected repeated efforts at diplomacy. \n\nHe thought the West and NATO wouldn’t respond. And he thought he could divide us at home. Putin was wrong. We were ready. Here is what we did. \n\nWe prepared extensively and carefully. \n\nWe spent months building a coalition of other freedom-loving nations from Europe and the Americas to Asia and Africa to confront Putin. \n\nI spent countless hours unifying our European allies. We shared with the world in advance what we knew Putin was planning and precisely how he would try to falsely justify his aggression. \n\nWe countered Russia’s lies with truth. \n\nAnd now that he has acted the free world is holding him accountable. \n\nAlong with twenty-seven members of the European Union including France, Germany, Italy, as well as countries like the United Kingdom, Canada, Japan, Korea, Australia, New Zealand, and many others, even Switzerland. \n\nWe are inflicting pain on Russia and supporting the people of Ukraine. Putin is now isolated from the world more than ever. \n\nTogether with our allies –we are right now enforcing powerful economic sanctions. \n\nWe are cutting off Russia’s largest banks from the international financial system. \n\nPreventing Russia’s central bank from defending the Russian Ruble making Putin’s $630 Billion “war fund” worthless. \n\nWe are choking off Russia’s access to technology that will sap its economic strength and weaken its military for years to come. \n\nTonight I say to the Russian oligarchs and corrupt leaders who have bilked billions of dollars off this violent regime no more. \n\nThe U.S. Department of Justice is assembling a dedicated task force to go after the crimes of Russian oligarchs. \n\nWe are joining with our European allies to find and seize your yachts your luxury apartments your private jets. We are coming for your ill-begotten gains. \n\nAnd tonight I am announcing that we will join our allies in closing off American air space to all Russian flights – further isolating Russia – and adding an additional squeeze –on their economy. The Ruble has lost 30% of its value. \n\nThe Russian stock market has lost 40% of its value and trading remains suspended. Russia’s economy is reeling and Putin alone is to blame. \n\nTogether with our allies we are providing support to the Ukrainians in their fight for freedom. Military assistance. Economic assistance. Humanitarian assistance. \n\nWe are giving more than $1 Billion in direct assistance to Ukraine. \n\nAnd we will continue to aid the Ukrainian people as they defend their country and to help ease their suffering. \n\nLet me be clear, our forces are not engaged and will not engage in conflict with Russian forces in Ukraine. \n\nOur forces are not going to Europe to fight in Ukraine, but to defend our NATO Allies – in the event that Putin decides to keep moving west. \n\nFor that purpose we’ve mobilized American ground forces, air squadrons, and ship deployments to protect NATO countries including Poland, Romania, Latvia, Lithuania, and Estonia. \n\nAs I have made crystal clear the United States and our Allies will defend every inch of territory of NATO countries with the full force of our collective power. \n\nAnd we remain clear-eyed. The Ukrainians are fighting back with pure courage. But the next few days weeks, months, will be hard on them. \n\nPutin has unleashed violence and chaos. But while he may make gains on the battlefield – he will pay a continuing high price over the long run. \n\nAnd a proud Ukrainian people, who have known 30 years of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards. \n\nTo all Americans, I will be honest with you, as I’ve always promised. A Russian dictator, invading a foreign country, has costs around the world. \n\nAnd I’m taking robust action to make sure the pain of our sanctions is targeted at Russia’s economy. And I will use every tool at our disposal to protect American businesses and consumers. \n\nTonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of oil from reserves around the world. \n\nAmerica will lead that effort, releasing 30 Million barrels from our own Strategic Petroleum Reserve. And we stand ready to do more if necessary, unified with our allies. \n\nThese steps will help blunt gas prices here at home. And I know the news about what’s happening can seem alarming. \n\nBut I want you to know that we are going to be okay. \n\nWhen the history of this era is written Putin’s war on Ukraine will have left Russia weaker and the rest of the world stronger. \n\nWhile it shouldn’t have taken something so terrible for people around the world to see what’s at stake now everyone sees it clearly. \n\nWe see the unity among leaders of nations and a more unified Europe a more unified West. And we see unity among the people who are gathering in cities in large crowds around the world even in Russia to demonstrate their support for Ukraine. \n\nIn the battle between democracy and autocracy, democracies are rising to the moment, and the world is clearly choosing the side of peace and security. \n\nThis is a real test. It’s going to take time. So let us continue to draw inspiration from the iron will of the Ukrainian people. \n\nTo our fellow Ukrainian Americans who forge a deep bond that connects our two nations we stand with you. \n\nPutin may circle Kyiv with tanks, but he will never gain the hearts and souls of the Ukrainian people. \n\nHe will never extinguish their love of freedom. He will never weaken the resolve of the free world. \n\nWe meet tonight in an America that has lived through two of the hardest years this nation has ever faced. \n\nThe pandemic has been punishing. \n\nAnd so many families are living paycheck to paycheck, struggling to keep up with the rising cost of food, gas, housing, and so much more. \n\nI understand. \n\nI remember when my Dad had to leave our home in Scranton, Pennsylvania to find work. I grew up in a family where if the price of food went up, you felt it. \n\nThat’s why one of the first things I did as President was fight to pass the American Rescue Plan. \n\nBecause people were hurting. We needed to act, and we did. \n\nFew pieces of legislation have done more in a critical moment in our history to lift us out of crisis. \n\nIt fueled our efforts to vaccinate the nation and combat COVID-19. It delivered immediate economic relief for tens of millions of Americans. \n\nHelped put food on their table, keep a roof over their heads, and cut the cost of health insurance. \n\nAnd as my Dad used to say, it gave people a little breathing room. \n\nAnd unlike the $2 Trillion tax cut passed in the previous administration that benefitted the top 1% of Americans, the American Rescue Plan helped working people—and left no one behind. \n\nAnd it worked. It created jobs. Lots of jobs. \n\nIn fact—our economy created over 6.5 Million new jobs just last year, more jobs created in one year \nthan ever before in the history of America. \n\nOur economy grew at a rate of 5.7% last year, the strongest growth in nearly 40 years, the first step in bringing fundamental change to an economy that hasn’t worked for the working people of this nation for too long. \n\nFor the past 40 years we were told that if we gave tax breaks to those at the very top, the benefits would trickle down to everyone else. \n\nBut that trickle-down theory led to weaker economic growth, lower wages, bigger deficits, and the widest gap between those at the top and everyone else in nearly a century. \n\nVice President Harris and I ran for office with a new economic vision for America. \n\nInvest in America. Educate Americans. Grow the workforce. Build the economy from the bottom up \nand the middle out, not from the top down. \n\nBecause we know that when the middle class grows, the poor have a ladder up and the wealthy do very well. \n\nAmerica used to have the best roads, bridges, and airports on Earth. \n\nNow our infrastructure is ranked 13th in the world. \n\nWe won’t be able to compete for the jobs of the 21st Century if we don’t fix that. \n\nThat’s why it was so important to pass the Bipartisan Infrastructure Law—the most sweeping investment to rebuild America in history. \n\nThis was a bipartisan effort, and I want to thank the members of both parties who worked to make it happen. \n\nWe’re done talking about infrastructure weeks. \n\nWe’re going to have an infrastructure decade. \n\nIt is going to transform America and put us on a path to win the economic competition of the 21st Century that we face with the rest of the world—particularly with China. \n\nAs I’ve told Xi Jinping, it is never a good bet to bet against the American people. \n\nWe’ll create good jobs for millions of Americans, modernizing roads, airports, ports, and waterways all across America. \n\nAnd we’ll do it all to withstand the devastating effects of the climate crisis and promote environmental justice. \n\nWe’ll build a national network of 500,000 electric vehicle charging stations, begin to replace poisonous lead pipes—so every child—and every American—has clean water to drink at home and at school, provide affordable high-speed internet for every American—urban, suburban, rural, and tribal communities. \n\n4,000 projects have already been announced. \n\nAnd tonight, I’m announcing that this year we will start fixing over 65,000 miles of highway and 1,500 bridges in disrepair. \n\nWhen we use taxpayer dollars to rebuild America – we are going to Buy American: buy American products to support American jobs. \n\nThe federal government spends about $600 Billion a year to keep the country safe and secure. \n\nThere’s been a law on the books for almost a century \nto make sure taxpayers’ dollars support American jobs and businesses. \n\nEvery Administration says they’ll do it, but we are actually doing it. \n\nWe will buy American to make sure everything from the deck of an aircraft carrier to the steel on highway guardrails are made in America. \n\nBut to compete for the best jobs of the future, we also need to level the playing field with China and other competitors. \n\nThat’s why it is so important to pass the Bipartisan Innovation Act sitting in Congress that will make record investments in emerging technologies and American manufacturing. \n\nLet me give you one example of why it’s so important to pass it. \n\nIf you travel 20 miles east of Columbus, Ohio, you’ll find 1,000 empty acres of land. \n\nIt won’t look like much, but if you stop and look closely, you’ll see a “Field of dreams,” the ground on which America’s future will be built. \n\nThis is where Intel, the American company that helped build Silicon Valley, is going to build its $20 billion semiconductor “mega site”. \n\nUp to eight state-of-the-art factories in one place. 10,000 new good-paying jobs. \n\nSome of the most sophisticated manufacturing in the world to make computer chips the size of a fingertip that power the world and our everyday lives. \n\nSmartphones. The Internet. Technology we have yet to invent. \n\nBut that’s just the beginning. \n\nIntel’s CEO, Pat Gelsinger, who is here tonight, told me they are ready to increase their investment from \n$20 billion to $100 billion. \n\nThat would be one of the biggest investments in manufacturing in American history. \n\nAnd all they’re waiting for is for you to pass this bill. \n\nSo let’s not wait any longer. Send it to my desk. I’ll sign it. \n\nAnd we will really take off. \n\nAnd Intel is not alone. \n\nThere’s something happening in America. \n\nJust look around and you’ll see an amazing story. \n\nThe rebirth of the pride that comes from stamping products “Made In America.” The revitalization of American manufacturing. \n\nCompanies are choosing to build new factories here, when just a few years ago, they would have built them overseas. \n\nThat’s what is happening. Ford is investing $11 billion to build electric vehicles, creating 11,000 jobs across the country. \n\nGM is making the largest investment in its history—$7 billion to build electric vehicles, creating 4,000 jobs in Michigan. \n\nAll told, we created 369,000 new manufacturing jobs in America just last year. \n\nPowered by people I’ve met like JoJo Burgess, from generations of union steelworkers from Pittsburgh, who’s here with us tonight. \n\nAs Ohio Senator Sherrod Brown says, “It’s time to bury the label “Rust Belt.” \n\nIt’s time. \n\nBut with all the bright spots in our economy, record job growth and higher wages, too many families are struggling to keep up with the bills. \n\nInflation is robbing them of the gains they might otherwise feel. \n\nI get it. That’s why my top priority is getting prices under control. \n\nLook, our economy roared back faster than most predicted, but the pandemic meant that businesses had a hard time hiring enough workers to keep up production in their factories. \n\nThe pandemic also disrupted global supply chains. \n\nWhen factories close, it takes longer to make goods and get them from the warehouse to the store, and prices go up. \n\nLook at cars. \n\nLast year, there weren’t enough semiconductors to make all the cars that people wanted to buy. \n\nAnd guess what, prices of automobiles went up. \n\nSo—we have a choice. \n\nOne way to fight inflation is to drive down wages and make Americans poorer. \n\nI have a better plan to fight inflation. \n\nLower your costs, not your wages. \n\nMake more cars and semiconductors in America. \n\nMore infrastructure and innovation in America. \n\nMore goods moving faster and cheaper in America. \n\nMore jobs where you can earn a good living in America. \n\nAnd instead of relying on foreign supply chains, let’s make it in America. \n\nEconomists call it “increasing the productive capacity of our economy.” \n\nI call it building a better America. \n\nMy plan to fight inflation will lower your costs and lower the deficit. \n\n17 Nobel laureates in economics say my plan will ease long-term inflationary pressures. Top business leaders and most Americans support my plan. And here’s the plan: \n\nFirst – cut the cost of prescription drugs. Just look at insulin. One in ten Americans has diabetes. In Virginia, I met a 13-year-old boy named Joshua Davis. \n\nHe and his Dad both have Type 1 diabetes, which means they need insulin every day. Insulin costs about $10 a vial to make. \n\nBut drug companies charge families like Joshua and his Dad up to 30 times more. I spoke with Joshua’s mom. \n\nImagine what it’s like to look at your child who needs insulin and have no idea how you’re going to pay for it. \n\nWhat it does to your dignity, your ability to look your child in the eye, to be the parent you expect to be. \n\nJoshua is here with us tonight. Yesterday was his birthday. Happy birthday, buddy. \n\nFor Joshua, and for the 200,000 other young people with Type 1 diabetes, let’s cap the cost of insulin at $35 a month so everyone can afford it. \n\nDrug companies will still do very well. And while we’re at it let Medicare negotiate lower prices for prescription drugs, like the VA already does. \n\nLook, the American Rescue Plan is helping millions of families on Affordable Care Act plans save $2,400 a year on their health care premiums. Let’s close the coverage gap and make those savings permanent. \n\nSecond – cut energy costs for families an average of $500 a year by combatting climate change. \n\nLet’s provide investments and tax credits to weatherize your homes and businesses to be energy efficient and you get a tax credit; double America’s clean energy production in solar, wind, and so much more; lower the price of electric vehicles, saving you another $80 a month because you’ll never have to pay at the gas pump again. \n\nThird – cut the cost of child care. Many families pay up to $14,000 a year for child care per child. \n\nMiddle-class and working families shouldn’t have to pay more than 7% of their income for care of young children. \n\nMy plan will cut the cost in half for most families and help parents, including millions of women, who left the workforce during the pandemic because they couldn’t afford child care, to be able to get back to work. \n\nMy plan doesn’t stop there. It also includes home and long-term care. More affordable housing. And Pre-K for every 3- and 4-year-old. \n\nAll of these will lower costs. \n\nAnd under my plan, nobody earning less than $400,000 a year will pay an additional penny in new taxes. Nobody. \n\nThe one thing all Americans agree on is that the tax system is not fair. We have to fix it. \n\nI’m not looking to punish anyone. But let’s make sure corporations and the wealthiest Americans start paying their fair share. \n\nJust last year, 55 Fortune 500 corporations earned $40 billion in profits and paid zero dollars in federal income tax. \n\nThat’s simply not fair. That’s why I’ve proposed a 15% minimum tax rate for corporations. \n\nWe got more than 130 countries to agree on a global minimum tax rate so companies can’t get out of paying their taxes at home by shipping jobs and factories overseas. \n\nThat’s why I’ve proposed closing loopholes so the very wealthy don’t pay a lower tax rate than a teacher or a firefighter. \n\nSo that’s my plan. It will grow the economy and lower costs for families. \n\nSo what are we waiting for? Let’s get this done. And while you’re at it, confirm my nominees to the Federal Reserve, which plays a critical role in fighting inflation. \n\nMy plan will not only lower costs to give families a fair shot, it will lower the deficit. \n\nThe previous Administration not only ballooned the deficit with tax cuts for the very wealthy and corporations, it undermined the watchdogs whose job was to keep pandemic relief funds from being wasted. \n\nBut in my administration, the watchdogs have been welcomed back. \n\nWe’re going after the criminals who stole billions in relief money meant for small businesses and millions of Americans. \n\nAnd tonight, I’m announcing that the Justice Department will name a chief prosecutor for pandemic fraud. \n\nBy the end of this year, the deficit will be down to less than half what it was before I took office. \n\nThe only president ever to cut the deficit by more than one trillion dollars in a single year. \n\nLowering your costs also means demanding more competition. \n\nI’m a capitalist, but capitalism without competition isn’t capitalism. \n\nIt’s exploitation—and it drives up prices. \n\nWhen corporations don’t have to compete, their profits go up, your prices go up, and small businesses and family farmers and ranchers go under. \n\nWe see it happening with ocean carriers moving goods in and out of America. \n\nDuring the pandemic, these foreign-owned companies raised prices by as much as 1,000% and made record profits. \n\nTonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards for nursing homes and make sure your loved ones get the care they deserve and expect. \n\nWe’ll also cut costs and keep the economy going strong by giving workers a fair shot, provide more training and apprenticeships, hire them based on their skills not degrees. \n\nLet’s pass the Paycheck Fairness Act and paid leave. \n\nRaise the minimum wage to $15 an hour and extend the Child Tax Credit, so no one has to raise a family in poverty. \n\nLet’s increase Pell Grants and increase our historic support of HBCUs, and invest in what Jill—our First Lady who teaches full-time—calls America’s best-kept secret: community colleges. \n\nAnd let’s pass the PRO Act when a majority of workers want to form a union—they shouldn’t be stopped. \n\nWhen we invest in our workers, when we build the economy from the bottom up and the middle out together, we can do something we haven’t done in a long time: build a better America. \n\nFor more than two years, COVID-19 has impacted every decision in our lives and the life of the nation. \n\nAnd I know you’re tired, frustrated, and exhausted. \n\nBut I also know this. \n\nBecause of the progress we’ve made, because of your resilience and the tools we have, tonight I can say \nwe are moving forward safely, back to more normal routines. \n\nWe’ve reached a new moment in the fight against COVID-19, with severe cases down to a level not seen since last July. \n\nJust a few days ago, the Centers for Disease Control and Prevention—the CDC—issued new mask guidelines. \n\nUnder these new guidelines, most Americans in most of the country can now be mask free. \n\nAnd based on the projections, more of the country will reach that point across the next couple of weeks. \n\nThanks to the progress we have made this past year, COVID-19 need no longer control our lives. \n\nI know some are talking about “living with COVID-19”. Tonight – I say that we will never just accept living with COVID-19. \n\nWe will continue to combat the virus as we do other diseases. And because this is a virus that mutates and spreads, we will stay on guard. \n\nHere are four common sense steps as we move forward safely. \n\nFirst, stay protected with vaccines and treatments. We know how incredibly effective vaccines are. If you’re vaccinated and boosted you have the highest degree of protection. \n\nWe will never give up on vaccinating more Americans. Now, I know parents with kids under 5 are eager to see a vaccine authorized for their children. \n\nThe scientists are working hard to get that done and we’ll be ready with plenty of vaccines when they do. \n\nWe’re also ready with anti-viral treatments. If you get COVID-19, the Pfizer pill reduces your chances of ending up in the hospital by 90%. \n\nWe’ve ordered more of these pills than anyone in the world. And Pfizer is working overtime to get us 1 Million pills this month and more than double that next month. \n\nAnd we’re launching the “Test to Treat” initiative so people can get tested at a pharmacy, and if they’re positive, receive antiviral pills on the spot at no cost. \n\nIf you’re immunocompromised or have some other vulnerability, we have treatments and free high-quality masks. \n\nWe’re leaving no one behind or ignoring anyone’s needs as we move forward. \n\nAnd on testing, we have made hundreds of millions of tests available for you to order for free. \n\nEven if you already ordered free tests tonight, I am announcing that you can order more from covidtests.gov starting next week. \n\nSecond – we must prepare for new variants. Over the past year, we’ve gotten much better at detecting new variants. \n\nIf necessary, we’ll be able to deploy new vaccines within 100 days instead of many more months or years. \n\nAnd, if Congress provides the funds we need, we’ll have new stockpiles of tests, masks, and pills ready if needed. \n\nI cannot promise a new variant won’t come. But I can promise you we’ll do everything within our power to be ready if it does. \n\nThird – we can end the shutdown of schools and businesses. We have the tools we need. \n\nIt’s time for Americans to get back to work and fill our great downtowns again. People working from home can feel safe to begin to return to the office. \n\nWe’re doing that here in the federal government. The vast majority of federal workers will once again work in person. \n\nOur schools are open. Let’s keep it that way. Our kids need to be in school. \n\nAnd with 75% of adult Americans fully vaccinated and hospitalizations down by 77%, most Americans can remove their masks, return to work, stay in the classroom, and move forward safely. \n\nWe achieved this because we provided free vaccines, treatments, tests, and masks. \n\nOf course, continuing this costs money. \n\nI will soon send Congress a request. \n\nThe vast majority of Americans have used these tools and may want to again, so I expect Congress to pass it quickly. \n\nFourth, we will continue vaccinating the world. \n\nWe’ve sent 475 Million vaccine doses to 112 countries, more than any other nation. \n\nAnd we won’t stop. \n\nWe have lost so much to COVID-19. Time with one another. And worst of all, so much loss of life. \n\nLet’s use this moment to reset. Let’s stop looking at COVID-19 as a partisan dividing line and see it for what it is: A God-awful disease. \n\nLet’s stop seeing each other as enemies, and start seeing each other for who we really are: Fellow Americans. \n\nWe can’t change how divided we’ve been. But we can change how we move forward—on COVID-19 and other issues we must face together. \n\nI recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera. \n\nThey were responding to a 9-1-1 call when a man shot and killed them with a stolen gun. \n\nOfficer Mora was 27 years old. \n\nOfficer Rivera was 22. \n\nBoth Dominican Americans who’d grown up on the same streets they later chose to patrol as police officers. \n\nI spoke with their families and told them that we are forever in debt for their sacrifice, and we will carry on their mission to restore the trust and safety every community deserves. \n\nI’ve worked on these issues a long time. \n\nI know what works: Investing in crime preventionand community police officers who’ll walk the beat, who’ll know the neighborhood, and who can restore trust and safety. \n\nSo let’s not abandon our streets. Or choose between safety and equal justice. \n\nLet’s come together to protect our communities, restore trust, and hold law enforcement accountable. \n\nThat’s why the Justice Department required body cameras, banned chokeholds, and restricted no-knock warrants for its officers. \n\nThat’s why the American Rescue Plan provided $350 Billion that cities, states, and counties can use to hire more police and invest in proven strategies like community violence interruption—trusted messengers breaking the cycle of violence and trauma and giving young people hope. \n\nWe should all agree: The answer is not to Defund the police. The answer is to FUND the police with the resources and training they need to protect our communities. \n\nI ask Democrats and Republicans alike: Pass my budget and keep our neighborhoods safe. \n\nAnd I will keep doing everything in my power to crack down on gun trafficking and ghost guns you can buy online and make at home—they have no serial numbers and can’t be traced. \n\nAnd I ask Congress to pass proven measures to reduce gun violence. Pass universal background checks. Why should anyone on a terrorist list be able to purchase a weapon? \n\nBan assault weapons and high-capacity magazines. \n\nRepeal the liability shield that makes gun manufacturers the only industry in America that can’t be sued. \n\nThese laws don’t infringe on the Second Amendment. They save lives. \n\nThe most fundamental right in America is the right to vote – and to have it counted. And it’s under assault. \n\nIn state after state, new laws have been passed, not only to suppress the vote, but to subvert entire elections. \n\nWe cannot let this happen. \n\nTonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. \n\nOne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \n\nAnd I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence. \n\nA former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by Democrats and Republicans. \n\nAnd if we are to advance liberty and justice, we need to secure the Border and fix the immigration system. \n\nWe can do both. At our border, we’ve installed new technology like cutting-edge scanners to better detect drug smuggling. \n\nWe’ve set up joint patrols with Mexico and Guatemala to catch more human traffickers. \n\nWe’re putting in place dedicated immigration judges so families fleeing persecution and violence can have their cases heard faster. \n\nWe’re securing commitments and supporting partners in South and Central America to host more refugees and secure their own borders. \n\nWe can do all this while keeping lit the torch of liberty that has led generations of immigrants to this land—my forefathers and so many of yours. \n\nProvide a pathway to citizenship for Dreamers, those on temporary status, farm workers, and essential workers. \n\nRevise our laws so businesses have the workers they need and families don’t wait decades to reunite. \n\nIt’s not only the right thing to do—it’s the economically smart thing to do. \n\nThat’s why immigration reform is supported by everyone from labor unions to religious leaders to the U.S. Chamber of Commerce. \n\nLet’s get it done once and for all. \n\nAdvancing liberty and justice also requires protecting the rights of women. \n\nThe constitutional right affirmed in Roe v. Wade—standing precedent for half a century—is under attack as never before. \n\nIf we want to go forward—not backward—we must protect access to health care. Preserve a woman’s right to choose. And let’s continue to advance maternal health care in America. \n\nAnd for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President, so you can be yourself and reach your God-given potential. \n\nWhile it often appears that we never agree, that isn’t true. I signed 80 bipartisan bills into law last year. From preventing government shutdowns to protecting Asian-Americans from still-too-common hate crimes to reforming military justice. \n\nAnd soon, we’ll strengthen the Violence Against Women Act that I first wrote three decades ago. It is important for us to show the nation that we can come together and do big things. \n\nSo tonight I’m offering a Unity Agenda for the Nation. Four big things we can do together. \n\nFirst, beat the opioid epidemic. \n\nThere is so much we can do. Increase funding for prevention, treatment, harm reduction, and recovery. \n\nGet rid of outdated rules that stop doctors from prescribing treatments. And stop the flow of illicit drugs by working with state and local law enforcement to go after traffickers. \n\nIf you’re suffering from addiction, know you are not alone. I believe in recovery, and I celebrate the 23 million Americans in recovery. \n\nSecond, let’s take on mental health. Especially among our children, whose lives and education have been turned upside down. \n\nThe American Rescue Plan gave schools money to hire teachers and help students make up for lost learning. \n\nI urge every parent to make sure your school does just that. And we can all play a part—sign up to be a tutor or a mentor. \n\nChildren were also struggling before the pandemic. Bullying, violence, trauma, and the harms of social media. \n\nAs Frances Haugen, who is here with us tonight, has shown, we must hold social media platforms accountable for the national experiment they’re conducting on our children for profit. \n\nIt’s time to strengthen privacy protections, ban targeted advertising to children, demand tech companies stop collecting personal data on our children. \n\nAnd let’s get all Americans the mental health services they need. More people they can turn to for help, and full parity between physical and mental health care. \n\nThird, support our veterans. \n\nVeterans are the best of us. \n\nI’ve always believed that we have a sacred obligation to equip all those we send to war and care for them and their families when they come home. \n\nMy administration is providing assistance with job training and housing, and now helping lower-income veterans get VA care debt-free. \n\nOur troops in Iraq and Afghanistan faced many dangers. \n\nOne was stationed at bases and breathing in toxic smoke from “burn pits” that incinerated wastes of war—medical and hazard material, jet fuel, and more. \n\nWhen they came home, many of the world’s fittest and best trained warriors were never the same. \n\nHeadaches. Numbness. Dizziness. \n\nA cancer that would put them in a flag-draped coffin. \n\nI know. \n\nOne of those soldiers was my son Major Beau Biden. \n\nWe don’t know for sure if a burn pit was the cause of his brain cancer, or the diseases of so many of our troops. \n\nBut I’m committed to finding out everything we can. \n\nCommitted to military families like Danielle Robinson from Ohio. \n\nThe widow of Sergeant First Class Heath Robinson. \n\nHe was born a soldier. Army National Guard. Combat medic in Kosovo and Iraq. \n\nStationed near Baghdad, just yards from burn pits the size of football fields. \n\nHeath’s widow Danielle is here with us tonight. They loved going to Ohio State football games. He loved building Legos with their daughter. \n\nBut cancer from prolonged exposure to burn pits ravaged Heath’s lungs and body. \n\nDanielle says Heath was a fighter to the very end. \n\nHe didn’t know how to stop fighting, and neither did she. \n\nThrough her pain she found purpose to demand we do better. \n\nTonight, Danielle—we are. \n\nThe VA is pioneering new ways of linking toxic exposures to diseases, already helping more veterans get benefits. \n\nAnd tonight, I’m announcing we’re expanding eligibility to veterans suffering from nine respiratory cancers. \n\nI’m also calling on Congress: pass a law to make sure veterans devastated by toxic exposures in Iraq and Afghanistan finally get the benefits and comprehensive health care they deserve. \n\nAnd fourth, let’s end cancer as we know it. \n\nThis is personal to me and Jill, to Kamala, and to so many of you. \n\nCancer is the #2 cause of death in America–second only to heart disease. \n\nLast month, I announced our plan to supercharge \nthe Cancer Moonshot that President Obama asked me to lead six years ago. \n\nOur goal is to cut the cancer death rate by at least 50% over the next 25 years, turn more cancers from death sentences into treatable diseases. \n\nMore support for patients and families. \n\nTo get there, I call on Congress to fund ARPA-H, the Advanced Research Projects Agency for Health. \n\nIt’s based on DARPA—the Defense Department project that led to the Internet, GPS, and so much more. \n\nARPA-H will have a singular purpose—to drive breakthroughs in cancer, Alzheimer’s, diabetes, and more. \n\nA unity agenda for the nation. \n\nWe can do this. \n\nMy fellow Americans—tonight , we have gathered in a sacred space—the citadel of our democracy. \n\nIn this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. \n\nWe have fought for freedom, expanded liberty, defeated totalitarianism and terror. \n\nAnd built the strongest, freest, and most prosperous nation the world has ever known. \n\nNow is the hour. \n\nOur moment of responsibility. \n\nOur test of resolve and conscience, of history itself. \n\nIt is in this moment that our character is formed. Our purpose is found. Our future is forged. \n\nWell I know this nation. \n\nWe will meet the test. \n\nTo protect freedom and liberty, to expand fairness and opportunity. \n\nWe will save democracy. \n\nAs hard as these times have been, I am more optimistic about America today than I have been my whole life. \n\nBecause I see the future that is within our grasp. \n\nBecause I know there is simply nothing beyond our capacity. \n\nWe are the only nation on Earth that has always turned every crisis we have faced into an opportunity. \n\nThe only nation that can be defined by a single word: possibilities. \n\nSo on this night, in our 245th year as a nation, I have come to report on the State of the Union. \n\nAnd my report is this: the State of the Union is strong—because you, the American people, are strong. \n\nWe are stronger today than we were a year ago. \n\nAnd we will be stronger a year from now than we are today. \n\nNow is our moment to meet and overcome the challenges of our time. \n\nAnd we will, as one people. \n\nOne America. \n\nThe United States of America. \n\nMay God bless you all. May God protect our troops.", + "textSplitter": "{{recursiveCharacterTextSplitter_0.data.instance}}", + "metadata": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "plainText_1-output-document-Document", + "name": "document", + "label": "Document", + "type": "Document" + }, + { + "id": "plainText_1-output-text-string|json", + "name": "text", + "label": "Text", + "type": "string | json" + } + ], + "default": "document" + } + ], + "outputs": { + "output": "document" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 117.23894449422778, + "y": 23.24339894687961 + }, + "dragging": false + }, + { + "width": 300, + "height": 429, + "id": "recursiveCharacterTextSplitter_0", + "position": { + "x": -259.38954307457425, + "y": 75.96855802341503 + }, + "type": "customNode", + "data": { + "id": "recursiveCharacterTextSplitter_0", + "label": "Recursive Character Text Splitter", + "version": 2, + "name": "recursiveCharacterTextSplitter", + "type": "RecursiveCharacterTextSplitter", + "baseClasses": ["RecursiveCharacterTextSplitter", "TextSplitter", "BaseDocumentTransformer", "Runnable"], + "category": "Text Splitters", + "description": "Split documents recursively by different characters - starting with \"\\n\\n\", then \"\\n\", then \" \"", + "inputParams": [ + { + "label": "Chunk Size", + "name": "chunkSize", + "type": "number", + "default": 1000, + "optional": true, + "id": "recursiveCharacterTextSplitter_0-input-chunkSize-number" + }, + { + "label": "Chunk Overlap", + "name": "chunkOverlap", + "type": "number", + "optional": true, + "id": "recursiveCharacterTextSplitter_0-input-chunkOverlap-number" + }, + { + "label": "Custom Separators", + "name": "separators", + "type": "string", + "rows": 4, + "description": "Array of custom separators to determine when to split the text, will override the default separators", + "placeholder": "[\"|\", \"##\", \">\", \"-\"]", + "additionalParams": true, + "optional": true, + "id": "recursiveCharacterTextSplitter_0-input-separators-string" + } + ], + "inputAnchors": [], + "inputs": { + "chunkSize": 1000, + "chunkOverlap": "", + "separators": "" + }, + "outputAnchors": [ + { + "id": "recursiveCharacterTextSplitter_0-output-recursiveCharacterTextSplitter-RecursiveCharacterTextSplitter|TextSplitter|BaseDocumentTransformer|Runnable", + "name": "recursiveCharacterTextSplitter", + "label": "RecursiveCharacterTextSplitter", + "type": "RecursiveCharacterTextSplitter | TextSplitter | BaseDocumentTransformer | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": -259.38954307457425, + "y": 75.96855802341503 + }, + "dragging": false + }, + { + "width": 300, + "height": 383, + "id": "conversationalAgent_0", + "position": { + "x": 2432.125364763489, + "y": -105.27942167533908 + }, + "type": "customNode", + "data": { + "id": "conversationalAgent_0", + "label": "Conversational Agent", + "version": 2, + "name": "conversationalAgent", + "type": "AgentExecutor", + "baseClasses": ["AgentExecutor", "BaseChain", "Runnable"], + "category": "Agents", + "description": "Conversational agent for a chat model. It will utilize chat specific prompts", + "inputParams": [ + { + "label": "System Message", + "name": "systemMessage", + "type": "string", + "rows": 4, + "default": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.", + "optional": true, + "additionalParams": true, + "id": "conversationalAgent_0-input-systemMessage-string" + } + ], + "inputAnchors": [ + { + "label": "Allowed Tools", + "name": "tools", + "type": "Tool", + "list": true, + "id": "conversationalAgent_0-input-tools-Tool" + }, + { + "label": "Language Model", + "name": "model", + "type": "BaseChatModel", + "id": "conversationalAgent_0-input-model-BaseChatModel" + }, + { + "label": "Memory", + "name": "memory", + "type": "BaseChatMemory", + "id": "conversationalAgent_0-input-memory-BaseChatMemory" + } + ], + "inputs": { + "tools": ["{{chainTool_2.data.instance}}", "{{chainTool_3.data.instance}}"], + "model": "{{chatOpenAI_2.data.instance}}", + "memory": "{{bufferMemory_0.data.instance}}", + "systemMessage": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist." + }, + "outputAnchors": [ + { + "id": "conversationalAgent_0-output-conversationalAgent-AgentExecutor|BaseChain|Runnable", + "name": "conversationalAgent", + "label": "AgentExecutor", + "type": "AgentExecutor | BaseChain | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 2432.125364763489, + "y": -105.27942167533908 }, "dragging": false } ], "edges": [ - { - "source": "chainTool_2", - "sourceHandle": "chainTool_2-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool|BaseLangChain", - "target": "mrklAgentLLM_0", - "targetHandle": "mrklAgentLLM_0-input-tools-Tool", - "type": "buttonedge", - "id": "chainTool_2-chainTool_2-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool|BaseLangChain-mrklAgentLLM_0-mrklAgentLLM_0-input-tools-Tool", - "data": { - "label": "" - } - }, - { - "source": "chainTool_3", - "sourceHandle": "chainTool_3-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool|BaseLangChain", - "target": "mrklAgentLLM_0", - "targetHandle": "mrklAgentLLM_0-input-tools-Tool", - "type": "buttonedge", - "id": "chainTool_3-chainTool_3-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool|BaseLangChain-mrklAgentLLM_0-mrklAgentLLM_0-input-tools-Tool", - "data": { - "label": "" - } - }, { "source": "retrievalQAChain_0", "sourceHandle": "retrievalQAChain_0-output-retrievalQAChain-RetrievalQAChain|BaseChain|BaseLangChain", @@ -1209,35 +1627,68 @@ "label": "" } }, - { - "source": "openAI_2", - "sourceHandle": "openAI_2-output-openAI-OpenAI|BaseLLM|BaseLanguageModel", - "target": "retrievalQAChain_0", - "targetHandle": "retrievalQAChain_0-input-model-BaseLanguageModel", - "type": "buttonedge", - "id": "openAI_2-openAI_2-output-openAI-OpenAI|BaseLLM|BaseLanguageModel-retrievalQAChain_0-retrievalQAChain_0-input-model-BaseLanguageModel", - "data": { - "label": "" - } - }, { "source": "openAIEmbeddings_1", "sourceHandle": "openAIEmbeddings_1-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "chromaExistingIndex_0", - "targetHandle": "chromaExistingIndex_0-input-embeddings-Embeddings", + "target": "redis_0", + "targetHandle": "redis_0-input-embeddings-Embeddings", "type": "buttonedge", - "id": "openAIEmbeddings_1-openAIEmbeddings_1-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-chromaExistingIndex_0-chromaExistingIndex_0-input-embeddings-Embeddings", + "id": "openAIEmbeddings_1-openAIEmbeddings_1-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-redis_0-redis_0-input-embeddings-Embeddings", "data": { "label": "" } }, { - "source": "chromaExistingIndex_0", - "sourceHandle": "chromaExistingIndex_0-output-retriever-Chroma|VectorStoreRetriever|BaseRetriever", + "source": "redis_0", + "sourceHandle": "redis_0-output-retriever-Redis|VectorStoreRetriever|BaseRetriever", "target": "retrievalQAChain_0", "targetHandle": "retrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", "type": "buttonedge", - "id": "chromaExistingIndex_0-chromaExistingIndex_0-output-retriever-Chroma|VectorStoreRetriever|BaseRetriever-retrievalQAChain_0-retrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "id": "redis_0-redis_0-output-retriever-Redis|VectorStoreRetriever|BaseRetriever-retrievalQAChain_0-retrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "data": { + "label": "" + } + }, + { + "source": "plainText_0", + "sourceHandle": "plainText_0-output-document-Document", + "target": "redis_0", + "targetHandle": "redis_0-input-document-Document", + "type": "buttonedge", + "id": "plainText_0-plainText_0-output-document-Document-redis_0-redis_0-input-document-Document", + "data": { + "label": "" + } + }, + { + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "retrievalQAChain_0", + "targetHandle": "retrievalQAChain_0-input-model-BaseLanguageModel", + "type": "buttonedge", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-retrievalQAChain_0-retrievalQAChain_0-input-model-BaseLanguageModel", + "data": { + "label": "" + } + }, + { + "source": "chatOpenAI_1", + "sourceHandle": "chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "retrievalQAChain_1", + "targetHandle": "retrievalQAChain_1-input-model-BaseLanguageModel", + "type": "buttonedge", + "id": "chatOpenAI_1-chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-retrievalQAChain_1-retrievalQAChain_1-input-model-BaseLanguageModel", + "data": { + "label": "" + } + }, + { + "source": "faiss_0", + "sourceHandle": "faiss_0-output-retriever-Faiss|VectorStoreRetriever|BaseRetriever", + "target": "retrievalQAChain_1", + "targetHandle": "retrievalQAChain_1-input-vectorStoreRetriever-BaseRetriever", + "type": "buttonedge", + "id": "faiss_0-faiss_0-output-retriever-Faiss|VectorStoreRetriever|BaseRetriever-retrievalQAChain_1-retrievalQAChain_1-input-vectorStoreRetriever-BaseRetriever", "data": { "label": "" } @@ -1245,43 +1696,76 @@ { "source": "openAIEmbeddings_2", "sourceHandle": "openAIEmbeddings_2-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeExistingIndex_0", - "targetHandle": "pineconeExistingIndex_0-input-embeddings-Embeddings", + "target": "faiss_0", + "targetHandle": "faiss_0-input-embeddings-Embeddings", "type": "buttonedge", - "id": "openAIEmbeddings_2-openAIEmbeddings_2-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeExistingIndex_0-pineconeExistingIndex_0-input-embeddings-Embeddings", + "id": "openAIEmbeddings_2-openAIEmbeddings_2-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-faiss_0-faiss_0-input-embeddings-Embeddings", "data": { "label": "" } }, { - "source": "openAI_3", - "sourceHandle": "openAI_3-output-openAI-OpenAI|BaseLLM|BaseLanguageModel", - "target": "retrievalQAChain_1", - "targetHandle": "retrievalQAChain_1-input-model-BaseLanguageModel", + "source": "plainText_1", + "sourceHandle": "plainText_1-output-document-Document", + "target": "faiss_0", + "targetHandle": "faiss_0-input-document-Document", "type": "buttonedge", - "id": "openAI_3-openAI_3-output-openAI-OpenAI|BaseLLM|BaseLanguageModel-retrievalQAChain_1-retrievalQAChain_1-input-model-BaseLanguageModel", + "id": "plainText_1-plainText_1-output-document-Document-faiss_0-faiss_0-input-document-Document", "data": { "label": "" } }, { - "source": "pineconeExistingIndex_0", - "sourceHandle": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "target": "retrievalQAChain_1", - "targetHandle": "retrievalQAChain_1-input-vectorStoreRetriever-BaseRetriever", + "source": "recursiveCharacterTextSplitter_0", + "sourceHandle": "recursiveCharacterTextSplitter_0-output-recursiveCharacterTextSplitter-RecursiveCharacterTextSplitter|TextSplitter|BaseDocumentTransformer|Runnable", + "target": "plainText_1", + "targetHandle": "plainText_1-input-textSplitter-TextSplitter", "type": "buttonedge", - "id": "pineconeExistingIndex_0-pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-retrievalQAChain_1-retrievalQAChain_1-input-vectorStoreRetriever-BaseRetriever", + "id": "recursiveCharacterTextSplitter_0-recursiveCharacterTextSplitter_0-output-recursiveCharacterTextSplitter-RecursiveCharacterTextSplitter|TextSplitter|BaseDocumentTransformer|Runnable-plainText_1-plainText_1-input-textSplitter-TextSplitter", "data": { "label": "" } }, { - "source": "openAI_4", - "sourceHandle": "openAI_4-output-openAI-OpenAI|BaseLLM|BaseLanguageModel", - "target": "mrklAgentLLM_0", - "targetHandle": "mrklAgentLLM_0-input-model-BaseLanguageModel", + "source": "chainTool_2", + "sourceHandle": "chainTool_2-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool|BaseLangChain", + "target": "conversationalAgent_0", + "targetHandle": "conversationalAgent_0-input-tools-Tool", "type": "buttonedge", - "id": "openAI_4-openAI_4-output-openAI-OpenAI|BaseLLM|BaseLanguageModel-mrklAgentLLM_0-mrklAgentLLM_0-input-model-BaseLanguageModel", + "id": "chainTool_2-chainTool_2-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool|BaseLangChain-conversationalAgent_0-conversationalAgent_0-input-tools-Tool", + "data": { + "label": "" + } + }, + { + "source": "chainTool_3", + "sourceHandle": "chainTool_3-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool|BaseLangChain", + "target": "conversationalAgent_0", + "targetHandle": "conversationalAgent_0-input-tools-Tool", + "type": "buttonedge", + "id": "chainTool_3-chainTool_3-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool|BaseLangChain-conversationalAgent_0-conversationalAgent_0-input-tools-Tool", + "data": { + "label": "" + } + }, + { + "source": "chatOpenAI_2", + "sourceHandle": "chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "conversationalAgent_0", + "targetHandle": "conversationalAgent_0-input-model-BaseChatModel", + "type": "buttonedge", + "id": "chatOpenAI_2-chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationalAgent_0-conversationalAgent_0-input-model-BaseChatModel", + "data": { + "label": "" + } + }, + { + "source": "bufferMemory_0", + "sourceHandle": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", + "target": "conversationalAgent_0", + "targetHandle": "conversationalAgent_0-input-memory-BaseChatMemory", + "type": "buttonedge", + "id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-conversationalAgent_0-conversationalAgent_0-input-memory-BaseChatMemory", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/OpenAI Agent.json b/packages/server/marketplaces/chatflows/OpenAI Agent.json index 9a98d29d..d2c842c6 100644 --- a/packages/server/marketplaces/chatflows/OpenAI Agent.json +++ b/packages/server/marketplaces/chatflows/OpenAI Agent.json @@ -13,8 +13,8 @@ "data": { "id": "calculator_0", "label": "Calculator", - "name": "calculator", "version": 1, + "name": "calculator", "type": "Calculator", "baseClasses": ["Calculator", "Tool", "StructuredTool", "BaseLangChain", "Serializable"], "category": "Tools", @@ -52,8 +52,8 @@ "data": { "id": "bufferMemory_0", "label": "Buffer Memory", - "name": "bufferMemory", "version": 1, + "name": "bufferMemory", "type": "BufferMemory", "baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"], "category": "Memory", @@ -109,8 +109,8 @@ "data": { "id": "customTool_0", "label": "Custom Tool", - "name": "customTool", "version": 1, + "name": "customTool", "type": "CustomTool", "baseClasses": ["CustomTool", "Tool", "StructuredTool"], "category": "Tools", @@ -158,8 +158,8 @@ "data": { "id": "serper_0", "label": "Serper", - "name": "serper", "version": 1, + "name": "serper", "type": "Serper", "baseClasses": ["Serper", "Tool", "StructuredTool"], "category": "Tools", @@ -205,8 +205,8 @@ "data": { "id": "openAIFunctionAgent_0", "label": "OpenAI Function Agent", + "version": 2, "name": "openAIFunctionAgent", - "version": 1, "type": "AgentExecutor", "baseClasses": ["AgentExecutor", "BaseChain"], "category": "Agents", @@ -237,11 +237,10 @@ "id": "openAIFunctionAgent_0-input-memory-BaseChatMemory" }, { - "label": "OpenAI Chat Model", + "label": "OpenAI/Azure Chat Model", "name": "model", - "description": "Only works with gpt-3.5-turbo-0613 and gpt-4-0613. Refer docs for more info", - "type": "BaseChatModel", - "id": "openAIFunctionAgent_0-input-model-BaseChatModel" + "type": "ChatOpenAI | AzureChatOpenAI", + "id": "openAIFunctionAgent_0-input-model-ChatOpenAI | AzureChatOpenAI" } ], "inputs": { @@ -270,7 +269,7 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_0", "position": { "x": 817.8210275868742, @@ -280,8 +279,8 @@ "data": { "id": "chatOpenAI_0", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -391,6 +390,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -410,7 +417,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -465,17 +473,6 @@ "label": "" } }, - { - "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-model-BaseChatModel", - "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-openAIFunctionAgent_0-openAIFunctionAgent_0-input-model-BaseChatModel", - "data": { - "label": "" - } - }, { "source": "bufferMemory_0", "sourceHandle": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", @@ -486,6 +483,17 @@ "data": { "label": "" } + }, + { + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", + "target": "openAIFunctionAgent_0", + "targetHandle": "openAIFunctionAgent_0-input-model-ChatOpenAI | AzureChatOpenAI", + "type": "buttonedge", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-openAIFunctionAgent_0-openAIFunctionAgent_0-input-model-ChatOpenAI | AzureChatOpenAI", + "data": { + "label": "" + } } ] } diff --git a/packages/server/marketplaces/chatflows/Prompt Chaining with VectorStore.json b/packages/server/marketplaces/chatflows/Prompt Chaining with VectorStore.json index 29f7e7aa..0ddec74f 100644 --- a/packages/server/marketplaces/chatflows/Prompt Chaining with VectorStore.json +++ b/packages/server/marketplaces/chatflows/Prompt Chaining with VectorStore.json @@ -2,96 +2,12 @@ "description": "Use chat history to rephrase user question, and answer the rephrased question using retrieved docs from vector store", "badge": "POPULAR", "nodes": [ - { - "width": 300, - "height": 329, - "id": "openAIEmbeddings_0", - "position": { - "x": 1198.6643452533754, - "y": -584.4233173804803 - }, - "type": "customNode", - "data": { - "id": "openAIEmbeddings_0", - "label": "OpenAI Embeddings", - "version": 1, - "name": "openAIEmbeddings", - "type": "OpenAIEmbeddings", - "baseClasses": ["OpenAIEmbeddings", "Embeddings"], - "category": "Embeddings", - "description": "OpenAI API to generate embeddings for a given text", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "openAIEmbeddings_0-input-credential-credential" - }, - { - "label": "Strip New Lines", - "name": "stripNewLines", - "type": "boolean", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-stripNewLines-boolean" - }, - { - "label": "Batch Size", - "name": "batchSize", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-batchSize-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-basepath-string" - } - ], - "inputAnchors": [], - "inputs": { - "stripNewLines": "", - "batchSize": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "name": "openAIEmbeddings", - "label": "OpenAIEmbeddings", - "type": "OpenAIEmbeddings | Embeddings" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1198.6643452533754, - "y": -584.4233173804803 - }, - "dragging": false - }, { "width": 300, "height": 475, "id": "promptTemplate_0", "position": { - "x": 354.2706973608643, + "x": 344.73370692733414, "y": -122.34815000085804 }, "type": "customNode", @@ -141,456 +57,11 @@ }, "selected": false, "positionAbsolute": { - "x": 354.2706973608643, + "x": 344.73370692733414, "y": -122.34815000085804 }, "dragging": false }, - { - "width": 300, - "height": 574, - "id": "chatOpenAI_0", - "position": { - "x": 353.5672832154869, - "y": -730.6436764835541 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_0", - "label": "ChatOpenAI", - "version": 2, - "name": "chatOpenAI", - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "step": 0.1, - "default": 0.9, - "optional": true, - "id": "chatOpenAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "step": 1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "step": 0.1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "step": 0.1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "step": 0.1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "step": 1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo-16k", - "temperature": "0", - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "dragging": false, - "positionAbsolute": { - "x": 353.5672832154869, - "y": -730.6436764835541 - } - }, - { - "width": 300, - "height": 574, - "id": "chatOpenAI_1", - "position": { - "x": 2281.9246645710673, - "y": -778.8379360672121 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_1", - "label": "ChatOpenAI", - "version": 2, - "name": "chatOpenAI", - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_1-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_1-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "step": 0.1, - "default": 0.9, - "optional": true, - "id": "chatOpenAI_1-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "step": 1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_1-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "step": 0.1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_1-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "step": 0.1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_1-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "step": 0.1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_1-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "step": 1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_1-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_1-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_1-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo-16k", - "temperature": "0", - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "dragging": false, - "positionAbsolute": { - "x": 2281.9246645710673, - "y": -778.8379360672121 - } - }, - { - "width": 300, - "height": 505, - "id": "pineconeExistingIndex_0", - "position": { - "x": 1544.4998097474581, - "y": -628.8477510577202 - }, - "type": "customNode", - "data": { - "id": "pineconeExistingIndex_0", - "label": "Pinecone Load Existing Index", - "version": 1, - "name": "pineconeExistingIndex", - "type": "Pinecone", - "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Load existing index from Pinecone (i.e: Document has been upserted)", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["pineconeApi"], - "id": "pineconeExistingIndex_0-input-credential-credential" - }, - { - "label": "Pinecone Index", - "name": "pineconeIndex", - "type": "string", - "id": "pineconeExistingIndex_0-input-pineconeIndex-string" - }, - { - "label": "Pinecone Namespace", - "name": "pineconeNamespace", - "type": "string", - "placeholder": "my-first-namespace", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-pineconeNamespace-string" - }, - { - "label": "Pinecone Metadata Filter", - "name": "pineconeMetadataFilter", - "type": "json", - "optional": true, - "additionalParams": true, - "id": "pineconeExistingIndex_0-input-pineconeMetadataFilter-json" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pineconeExistingIndex_0-input-topK-number" - } - ], - "inputAnchors": [ - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "pineconeExistingIndex_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "pineconeIndex": "", - "pineconeNamespace": "", - "pineconeMetadataFilter": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "pineconeExistingIndex_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Pinecone Retriever", - "type": "Pinecone | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", - "name": "vectorStore", - "label": "Pinecone Vector Store", - "type": "Pinecone | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "vectorStore" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1544.4998097474581, - "y": -628.8477510577202 - }, - "dragging": false - }, { "width": 300, "height": 652, @@ -708,7 +179,7 @@ } ], "inputs": { - "vectorStore": "{{pineconeExistingIndex_0.data.instance}}", + "vectorStore": "{{singlestore_0.data.instance}}", "query": "{{llmChain_2.data.instance}}", "minScore": "" }, @@ -923,31 +394,620 @@ "y": -301.4742415779482 }, "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_0", + "position": { + "x": 339.96857057520754, + "y": -732.8078068632885 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_0-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_0-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo-16k", + "temperature": "0", + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 339.96857057520754, + "y": -732.8078068632885 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_1", + "position": { + "x": 2291.510577325338, + "y": -785.9138727666948 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_1", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_1-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_1-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_1-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_1-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo-16k", + "temperature": "0", + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 2291.510577325338, + "y": -785.9138727666948 + }, + "dragging": false + }, + { + "width": 300, + "height": 654, + "id": "singlestore_0", + "position": { + "x": 1530.532503048084, + "y": -657.3586990397077 + }, + "type": "customNode", + "data": { + "id": "singlestore_0", + "label": "SingleStore", + "version": 1, + "name": "singlestore", + "type": "SingleStore", + "baseClasses": ["SingleStore", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using SingleStore, a fast and distributed cloud relational database", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "description": "Needed when using SingleStore cloud hosted", + "optional": true, + "credentialNames": ["singleStoreApi"], + "id": "singlestore_0-input-credential-credential" + }, + { + "label": "Host", + "name": "host", + "type": "string", + "id": "singlestore_0-input-host-string" + }, + { + "label": "Database", + "name": "database", + "type": "string", + "id": "singlestore_0-input-database-string" + }, + { + "label": "Table Name", + "name": "tableName", + "type": "string", + "placeholder": "embeddings", + "additionalParams": true, + "optional": true, + "id": "singlestore_0-input-tableName-string" + }, + { + "label": "Content Column Name", + "name": "contentColumnName", + "type": "string", + "placeholder": "content", + "additionalParams": true, + "optional": true, + "id": "singlestore_0-input-contentColumnName-string" + }, + { + "label": "Vector Column Name", + "name": "vectorColumnName", + "type": "string", + "placeholder": "vector", + "additionalParams": true, + "optional": true, + "id": "singlestore_0-input-vectorColumnName-string" + }, + { + "label": "Metadata Column Name", + "name": "metadataColumnName", + "type": "string", + "placeholder": "metadata", + "additionalParams": true, + "optional": true, + "id": "singlestore_0-input-metadataColumnName-string" + }, + { + "label": "Top K", + "name": "topK", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "singlestore_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "singlestore_0-input-document-Document" + }, + { + "label": "Embeddings", + "name": "embeddings", + "type": "Embeddings", + "id": "singlestore_0-input-embeddings-Embeddings" + } + ], + "inputs": { + "document": "", + "embeddings": "{{openAIEmbeddings_0.data.instance}}", + "host": "", + "database": "", + "tableName": "", + "contentColumnName": "", + "vectorColumnName": "", + "metadataColumnName": "", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "singlestore_0-output-retriever-SingleStore|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "SingleStore Retriever", + "type": "SingleStore | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "singlestore_0-output-vectorStore-SingleStore|VectorStore", + "name": "vectorStore", + "label": "SingleStore Vector Store", + "type": "SingleStore | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "vectorStore" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1530.532503048084, + "y": -657.3586990397077 + }, + "dragging": false + }, + { + "width": 300, + "height": 329, + "id": "openAIEmbeddings_0", + "position": { + "x": 1154.293946350955, + "y": -589.6072684085893 + }, + "type": "customNode", + "data": { + "id": "openAIEmbeddings_0", + "label": "OpenAI Embeddings", + "version": 1, + "name": "openAIEmbeddings", + "type": "OpenAIEmbeddings", + "baseClasses": ["OpenAIEmbeddings", "Embeddings"], + "category": "Embeddings", + "description": "OpenAI API to generate embeddings for a given text", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "openAIEmbeddings_0-input-credential-credential" + }, + { + "label": "Strip New Lines", + "name": "stripNewLines", + "type": "boolean", + "optional": true, + "additionalParams": true, + "id": "openAIEmbeddings_0-input-stripNewLines-boolean" + }, + { + "label": "Batch Size", + "name": "batchSize", + "type": "number", + "optional": true, + "additionalParams": true, + "id": "openAIEmbeddings_0-input-batchSize-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "optional": true, + "additionalParams": true, + "id": "openAIEmbeddings_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "openAIEmbeddings_0-input-basepath-string" + } + ], + "inputAnchors": [], + "inputs": { + "stripNewLines": "", + "batchSize": "", + "timeout": "", + "basepath": "" + }, + "outputAnchors": [ + { + "id": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "name": "openAIEmbeddings", + "label": "OpenAIEmbeddings", + "type": "OpenAIEmbeddings | Embeddings" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1154.293946350955, + "y": -589.6072684085893 + }, + "dragging": false } ], "edges": [ - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeExistingIndex_0", - "targetHandle": "pineconeExistingIndex_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeExistingIndex_0-pineconeExistingIndex_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, - { - "source": "pineconeExistingIndex_0", - "sourceHandle": "pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore", - "target": "vectorStoreToDocument_0", - "targetHandle": "vectorStoreToDocument_0-input-vectorStore-VectorStore", - "type": "buttonedge", - "id": "pineconeExistingIndex_0-pineconeExistingIndex_0-output-vectorStore-Pinecone|VectorStore-vectorStoreToDocument_0-vectorStoreToDocument_0-input-vectorStore-VectorStore", - "data": { - "label": "" - } - }, { "source": "vectorStoreToDocument_0", "sourceHandle": "vectorStoreToDocument_0-output-text-string|json", @@ -959,17 +1019,6 @@ "label": "" } }, - { - "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", - "target": "llmChain_2", - "targetHandle": "llmChain_2-input-model-BaseLanguageModel", - "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-llmChain_2-llmChain_2-input-model-BaseLanguageModel", - "data": { - "label": "" - } - }, { "source": "promptTemplate_0", "sourceHandle": "promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate|Runnable", @@ -992,6 +1041,28 @@ "label": "" } }, + { + "source": "chatPromptTemplate_0", + "sourceHandle": "chatPromptTemplate_0-output-chatPromptTemplate-ChatPromptTemplate|BaseChatPromptTemplate|BasePromptTemplate|Runnable", + "target": "llmChain_1", + "targetHandle": "llmChain_1-input-prompt-BasePromptTemplate", + "type": "buttonedge", + "id": "chatPromptTemplate_0-chatPromptTemplate_0-output-chatPromptTemplate-ChatPromptTemplate|BaseChatPromptTemplate|BasePromptTemplate|Runnable-llmChain_1-llmChain_1-input-prompt-BasePromptTemplate", + "data": { + "label": "" + } + }, + { + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "llmChain_2", + "targetHandle": "llmChain_2-input-model-BaseLanguageModel", + "type": "buttonedge", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-llmChain_2-llmChain_2-input-model-BaseLanguageModel", + "data": { + "label": "" + } + }, { "source": "chatOpenAI_1", "sourceHandle": "chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", @@ -1004,12 +1075,23 @@ } }, { - "source": "chatPromptTemplate_0", - "sourceHandle": "chatPromptTemplate_0-output-chatPromptTemplate-ChatPromptTemplate|BaseChatPromptTemplate|BasePromptTemplate|Runnable", - "target": "llmChain_1", - "targetHandle": "llmChain_1-input-prompt-BasePromptTemplate", + "source": "singlestore_0", + "sourceHandle": "singlestore_0-output-vectorStore-SingleStore|VectorStore", + "target": "vectorStoreToDocument_0", + "targetHandle": "vectorStoreToDocument_0-input-vectorStore-VectorStore", "type": "buttonedge", - "id": "chatPromptTemplate_0-chatPromptTemplate_0-output-chatPromptTemplate-ChatPromptTemplate|BaseChatPromptTemplate|BasePromptTemplate|Runnable-llmChain_1-llmChain_1-input-prompt-BasePromptTemplate", + "id": "singlestore_0-singlestore_0-output-vectorStore-SingleStore|VectorStore-vectorStoreToDocument_0-vectorStoreToDocument_0-input-vectorStore-VectorStore", + "data": { + "label": "" + } + }, + { + "source": "openAIEmbeddings_0", + "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", + "target": "singlestore_0", + "targetHandle": "singlestore_0-input-embeddings-Embeddings", + "type": "buttonedge", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-singlestore_0-singlestore_0-input-embeddings-Embeddings", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/MRKLAgent.json b/packages/server/marketplaces/chatflows/ReAct Agent.json similarity index 78% rename from packages/server/marketplaces/chatflows/MRKLAgent.json rename to packages/server/marketplaces/chatflows/ReAct Agent.json index 697e4919..b776dd37 100644 --- a/packages/server/marketplaces/chatflows/MRKLAgent.json +++ b/packages/server/marketplaces/chatflows/ReAct Agent.json @@ -1,5 +1,5 @@ { - "description": "An agent that uses the React Framework to decide what action to take", + "description": "An agent that uses ReAct logic to decide what action to take", "nodes": [ { "width": 300, @@ -13,8 +13,8 @@ "data": { "id": "calculator_1", "label": "Calculator", - "name": "calculator", "version": 1, + "name": "calculator", "type": "Calculator", "baseClasses": ["Calculator", "Tool", "StructuredTool", "BaseLangChain"], "category": "Tools", @@ -40,62 +40,6 @@ "selected": false, "dragging": false }, - { - "width": 300, - "height": 280, - "id": "mrklAgentLLM_0", - "position": { - "x": 1055.3271135179489, - "y": 245.36098016819074 - }, - "type": "customNode", - "data": { - "id": "mrklAgentLLM_0", - "label": "MRKL Agent for LLMs", - "name": "mrklAgentLLM", - "version": 1, - "type": "AgentExecutor", - "baseClasses": ["AgentExecutor", "BaseChain", "BaseLangChain"], - "category": "Agents", - "description": "Agent that uses the ReAct Framework to decide what action to take, optimized to be used with LLMs", - "inputParams": [], - "inputAnchors": [ - { - "label": "Allowed Tools", - "name": "tools", - "type": "Tool", - "list": true, - "id": "mrklAgentLLM_0-input-tools-Tool" - }, - { - "label": "Language Model", - "name": "model", - "type": "BaseLanguageModel", - "id": "mrklAgentLLM_0-input-model-BaseLanguageModel" - } - ], - "inputs": { - "tools": ["{{calculator_1.data.instance}}", "{{serper_0.data.instance}}"], - "model": "{{chatOpenAI_0.data.instance}}" - }, - "outputAnchors": [ - { - "id": "mrklAgentLLM_0-output-mrklAgentLLM-AgentExecutor|BaseChain|BaseLangChain", - "name": "mrklAgentLLM", - "label": "AgentExecutor", - "type": "AgentExecutor | BaseChain | BaseLangChain" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1055.3271135179489, - "y": 245.36098016819074 - }, - "dragging": false - }, { "width": 300, "height": 277, @@ -108,8 +52,8 @@ "data": { "id": "serper_0", "label": "Serper", - "name": "serper", "version": 1, + "name": "serper", "type": "Serper", "baseClasses": ["Serper", "Tool", "StructuredTool"], "category": "Tools", @@ -145,20 +89,20 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_0", "position": { - "x": 333.58931284721206, - "y": 416.98420974875927 + "x": -27.71074046118335, + "y": 243.62715178281059 }, "type": "customNode", "data": { "id": "chatOpenAI_0", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], "category": "Chat Models", "description": "Wrapper around OpenAI large language models that use the Chat endpoint", "inputParams": [ @@ -178,6 +122,14 @@ "label": "gpt-4", "name": "gpt-4" }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, { "label": "gpt-4-0613", "name": "gpt-4-0613" @@ -194,6 +146,10 @@ "label": "gpt-3.5-turbo", "name": "gpt-3.5-turbo" }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, { "label": "gpt-3.5-turbo-0613", "name": "gpt-3.5-turbo-0613" @@ -215,6 +171,7 @@ "label": "Temperature", "name": "temperature", "type": "number", + "step": 0.1, "default": 0.9, "optional": true, "id": "chatOpenAI_0-input-temperature-number" @@ -223,6 +180,7 @@ "label": "Max Tokens", "name": "maxTokens", "type": "number", + "step": 1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-maxTokens-number" @@ -231,6 +189,7 @@ "label": "Top Probability", "name": "topP", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-topP-number" @@ -239,6 +198,7 @@ "label": "Frequency Penalty", "name": "frequencyPenalty", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-frequencyPenalty-number" @@ -247,6 +207,7 @@ "label": "Presence Penalty", "name": "presencePenalty", "type": "number", + "step": 0.1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-presencePenalty-number" @@ -255,6 +216,7 @@ "label": "Timeout", "name": "timeout", "type": "number", + "step": 1, "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-timeout-number" @@ -266,6 +228,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -278,6 +248,7 @@ } ], "inputs": { + "cache": "", "modelName": "gpt-3.5-turbo", "temperature": 0.9, "maxTokens": "", @@ -285,14 +256,15 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", "name": "chatOpenAI", "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel" + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" } ], "outputs": {}, @@ -300,20 +272,75 @@ }, "selected": false, "positionAbsolute": { - "x": 333.58931284721206, - "y": 416.98420974875927 + "x": -27.71074046118335, + "y": 243.62715178281059 }, "dragging": false + }, + { + "width": 300, + "height": 280, + "id": "mrklAgentChat_0", + "position": { + "x": 1090.2058867451212, + "y": 423.2174695788541 + }, + "type": "customNode", + "data": { + "id": "mrklAgentChat_0", + "label": "ReAct Agent for Chat Models", + "version": 1, + "name": "mrklAgentChat", + "type": "AgentExecutor", + "baseClasses": ["AgentExecutor", "BaseChain", "Runnable"], + "category": "Agents", + "description": "Agent that uses the ReAct logic to decide what action to take, optimized to be used with Chat Models", + "inputParams": [], + "inputAnchors": [ + { + "label": "Allowed Tools", + "name": "tools", + "type": "Tool", + "list": true, + "id": "mrklAgentChat_0-input-tools-Tool" + }, + { + "label": "Language Model", + "name": "model", + "type": "BaseLanguageModel", + "id": "mrklAgentChat_0-input-model-BaseLanguageModel" + } + ], + "inputs": { + "tools": ["{{calculator_1.data.instance}}", "{{serper_0.data.instance}}"], + "model": "{{chatOpenAI_0.data.instance}}" + }, + "outputAnchors": [ + { + "id": "mrklAgentChat_0-output-mrklAgentChat-AgentExecutor|BaseChain|Runnable", + "name": "mrklAgentChat", + "label": "AgentExecutor", + "type": "AgentExecutor | BaseChain | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "positionAbsolute": { + "x": 1090.2058867451212, + "y": 423.2174695788541 + }, + "selected": false } ], "edges": [ { "source": "calculator_1", "sourceHandle": "calculator_1-output-calculator-Calculator|Tool|StructuredTool|BaseLangChain", - "target": "mrklAgentLLM_0", - "targetHandle": "mrklAgentLLM_0-input-tools-Tool", + "target": "mrklAgentChat_0", + "targetHandle": "mrklAgentChat_0-input-tools-Tool", "type": "buttonedge", - "id": "calculator_1-calculator_1-output-calculator-Calculator|Tool|StructuredTool|BaseLangChain-mrklAgentLLM_0-mrklAgentLLM_0-input-tools-Tool", + "id": "calculator_1-calculator_1-output-calculator-Calculator|Tool|StructuredTool|BaseLangChain-mrklAgentChat_0-mrklAgentChat_0-input-tools-Tool", "data": { "label": "" } @@ -321,21 +348,21 @@ { "source": "serper_0", "sourceHandle": "serper_0-output-serper-Serper|Tool|StructuredTool", - "target": "mrklAgentLLM_0", - "targetHandle": "mrklAgentLLM_0-input-tools-Tool", + "target": "mrklAgentChat_0", + "targetHandle": "mrklAgentChat_0-input-tools-Tool", "type": "buttonedge", - "id": "serper_0-serper_0-output-serper-Serper|Tool|StructuredTool-mrklAgentLLM_0-mrklAgentLLM_0-input-tools-Tool", + "id": "serper_0-serper_0-output-serper-Serper|Tool|StructuredTool-mrklAgentChat_0-mrklAgentChat_0-input-tools-Tool", "data": { "label": "" } }, { "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "mrklAgentLLM_0", - "targetHandle": "mrklAgentLLM_0-input-model-BaseLanguageModel", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "mrklAgentChat_0", + "targetHandle": "mrklAgentChat_0-input-model-BaseLanguageModel", "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-mrklAgentLLM_0-mrklAgentLLM_0-input-model-BaseLanguageModel", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-mrklAgentChat_0-mrklAgentChat_0-input-model-BaseLanguageModel", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/SQL DB Chain.json b/packages/server/marketplaces/chatflows/SQL DB Chain.json index 3b32efe0..026a03d8 100644 --- a/packages/server/marketplaces/chatflows/SQL DB Chain.json +++ b/packages/server/marketplaces/chatflows/SQL DB Chain.json @@ -124,6 +124,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -143,7 +151,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { diff --git a/packages/server/marketplaces/chatflows/Simple Conversation Chain.json b/packages/server/marketplaces/chatflows/Simple Conversation Chain.json index f5fac38e..2dac3823 100644 --- a/packages/server/marketplaces/chatflows/Simple Conversation Chain.json +++ b/packages/server/marketplaces/chatflows/Simple Conversation Chain.json @@ -182,6 +182,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -201,7 +209,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { diff --git a/packages/server/marketplaces/chatflows/Translator.json b/packages/server/marketplaces/chatflows/Translator.json index 7cbe5ac7..f1fa0764 100644 --- a/packages/server/marketplaces/chatflows/Translator.json +++ b/packages/server/marketplaces/chatflows/Translator.json @@ -193,6 +193,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -212,7 +220,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { diff --git a/packages/server/marketplaces/chatflows/Vectara LLM Chain Upload.json b/packages/server/marketplaces/chatflows/Vectara LLM Chain Upload.json index 5fc540b0..d9f9fb49 100644 --- a/packages/server/marketplaces/chatflows/Vectara LLM Chain Upload.json +++ b/packages/server/marketplaces/chatflows/Vectara LLM Chain Upload.json @@ -3,123 +3,12 @@ "nodes": [ { "width": 300, - "height": 524, - "id": "vectaraUpload_0", - "position": { "x": 219.0098475967174, "y": 189.74396248534583 }, - "type": "customNode", - "data": { - "id": "vectaraUpload_0", - "label": "Vectara Upload File", - "version": 1, - "name": "vectaraUpload", - "type": "Vectara", - "baseClasses": ["Vectara", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Upload files to Vectara", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["vectaraApi"], - "id": "vectaraUpload_0-input-credential-credential" - }, - { - "label": "File", - "name": "file", - "description": "File to upload to Vectara. Supported file types: https://docs.vectara.com/docs/api-reference/indexing-apis/file-upload/file-upload-filetypes", - "type": "file", - "id": "vectaraUpload_0-input-file-file" - }, - { - "label": "Metadata Filter", - "name": "filter", - "description": "Filter to apply to Vectara metadata. Refer to the documentation on how to use Vectara filters with Flowise.", - "type": "string", - "additionalParams": true, - "optional": true, - "id": "vectaraUpload_0-input-filter-string" - }, - { - "label": "Sentences Before", - "name": "sentencesBefore", - "description": "Number of sentences to fetch before the matched sentence. Defaults to 2.", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "vectaraUpload_0-input-sentencesBefore-number" - }, - { - "label": "Sentences After", - "name": "sentencesAfter", - "description": "Number of sentences to fetch after the matched sentence. Defaults to 2.", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "vectaraUpload_0-input-sentencesAfter-number" - }, - { - "label": "Lambda", - "name": "lambda", - "description": "Improves retrieval accuracy by adjusting the balance (from 0 to 1) between neural search and keyword-based search factors.", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "vectaraUpload_0-input-lambda-number" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Defaults to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "vectaraUpload_0-input-topK-number" - } - ], - "inputAnchors": [], - "inputs": { - "filter": "", - "sentencesBefore": "", - "sentencesAfter": "", - "lambda": "", - "topK": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "vectaraUpload_0-output-retriever-Vectara|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Vectara Retriever", - "type": "Vectara | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "vectaraUpload_0-output-vectorStore-Vectara|VectorStore", - "name": "vectorStore", - "label": "Vectara Vector Store", - "type": "Vectara | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { "output": "retriever" }, - "selected": false - }, - "selected": false, - "positionAbsolute": { "x": 219.0098475967174, "y": 189.74396248534583 }, - "dragging": false - }, - { - "width": 300, - "height": 525, + "height": 574, "id": "chatOpenAI_0", - "position": { "x": 669.6533996522251, "y": 177.86181519287192 }, + "position": { + "x": 581.1784360612766, + "y": -229.3906666911439 + }, "type": "customNode", "data": { "id": "chatOpenAI_0", @@ -143,13 +32,34 @@ "name": "modelName", "type": "options", "options": [ - { "label": "gpt-4", "name": "gpt-4" }, - { "label": "gpt-4-0613", "name": "gpt-4-0613" }, - { "label": "gpt-4-32k", "name": "gpt-4-32k" }, - { "label": "gpt-4-32k-0613", "name": "gpt-4-32k-0613" }, - { "label": "gpt-3.5-turbo", "name": "gpt-3.5-turbo" }, - { "label": "gpt-3.5-turbo-0613", "name": "gpt-3.5-turbo-0613" }, - { "label": "gpt-3.5-turbo-16k", "name": "gpt-3.5-turbo-16k" }, + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, { "label": "gpt-3.5-turbo-16k-0613", "name": "gpt-3.5-turbo-16k-0613" @@ -241,7 +151,7 @@ ], "inputs": { "modelName": "gpt-3.5-turbo", - "temperature": "0.5", + "temperature": "0.6", "maxTokens": "", "topP": "", "frequencyPenalty": "", @@ -262,14 +172,20 @@ "selected": false }, "selected": false, - "positionAbsolute": { "x": 669.6533996522251, "y": 177.86181519287192 }, + "positionAbsolute": { + "x": 581.1784360612766, + "y": -229.3906666911439 + }, "dragging": false }, { "width": 300, - "height": 481, + "height": 480, "id": "conversationalRetrievalQAChain_0", - "position": { "x": 1135.5490908971935, "y": 201.62146241822506 }, + "position": { + "x": 979.9713511176517, + "y": 200.09513217589273 + }, "type": "customNode", "data": { "id": "conversationalRetrievalQAChain_0", @@ -348,7 +264,7 @@ ], "inputs": { "model": "{{chatOpenAI_0.data.instance}}", - "vectorStoreRetriever": "{{vectaraUpload_0.data.instance}}", + "vectorStoreRetriever": "{{vectara_0.data.instance}}", "memory": "", "returnSourceDocuments": true, "systemMessagePrompt": "", @@ -367,19 +283,146 @@ }, "selected": false, "dragging": false, - "positionAbsolute": { "x": 1135.5490908971935, "y": 201.62146241822506 } + "positionAbsolute": { + "x": 979.9713511176517, + "y": 200.09513217589273 + } + }, + { + "width": 300, + "height": 535, + "id": "vectara_0", + "position": { + "x": 199.28476672510158, + "y": 177.63260741741112 + }, + "type": "customNode", + "data": { + "id": "vectara_0", + "label": "Vectara", + "version": 1, + "name": "vectara", + "type": "Vectara", + "baseClasses": ["Vectara", "VectorStoreRetriever", "BaseRetriever"], + "category": "Vector Stores", + "description": "Upsert embedded data and perform similarity search upon query using Vectara, a LLM-powered search-as-a-service", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["vectaraApi"], + "id": "vectara_0-input-credential-credential" + }, + { + "label": "File", + "name": "file", + "description": "File to upload to Vectara. Supported file types: https://docs.vectara.com/docs/api-reference/indexing-apis/file-upload/file-upload-filetypes", + "type": "file", + "optional": true, + "id": "vectara_0-input-file-file" + }, + { + "label": "Metadata Filter", + "name": "filter", + "description": "Filter to apply to Vectara metadata. Refer to the documentation on how to use Vectara filters with Flowise.", + "type": "string", + "additionalParams": true, + "optional": true, + "id": "vectara_0-input-filter-string" + }, + { + "label": "Sentences Before", + "name": "sentencesBefore", + "description": "Number of sentences to fetch before the matched sentence. Defaults to 2.", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "vectara_0-input-sentencesBefore-number" + }, + { + "label": "Sentences After", + "name": "sentencesAfter", + "description": "Number of sentences to fetch after the matched sentence. Defaults to 2.", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "vectara_0-input-sentencesAfter-number" + }, + { + "label": "Lambda", + "name": "lambda", + "description": "Improves retrieval accuracy by adjusting the balance (from 0 to 1) between neural search and keyword-based search factors.", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "vectara_0-input-lambda-number" + }, + { + "label": "Top K", + "name": "topK", + "description": "Number of top results to fetch. Defaults to 4", + "placeholder": "4", + "type": "number", + "additionalParams": true, + "optional": true, + "id": "vectara_0-input-topK-number" + } + ], + "inputAnchors": [ + { + "label": "Document", + "name": "document", + "type": "Document", + "list": true, + "optional": true, + "id": "vectara_0-input-document-Document" + } + ], + "inputs": { + "document": "", + "filter": "", + "sentencesBefore": "", + "sentencesAfter": "", + "lambda": "", + "topK": "" + }, + "outputAnchors": [ + { + "name": "output", + "label": "Output", + "type": "options", + "options": [ + { + "id": "vectara_0-output-retriever-Vectara|VectorStoreRetriever|BaseRetriever", + "name": "retriever", + "label": "Vectara Retriever", + "type": "Vectara | VectorStoreRetriever | BaseRetriever" + }, + { + "id": "vectara_0-output-vectorStore-Vectara|VectorStore", + "name": "vectorStore", + "label": "Vectara Vector Store", + "type": "Vectara | VectorStore" + } + ], + "default": "retriever" + } + ], + "outputs": { + "output": "retriever" + }, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 199.28476672510158, + "y": 177.63260741741112 + }, + "dragging": false } ], "edges": [ - { - "source": "vectaraUpload_0", - "sourceHandle": "vectaraUpload_0-output-retriever-Vectara|VectorStoreRetriever|BaseRetriever", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "type": "buttonedge", - "id": "vectaraUpload_0-vectaraUpload_0-output-retriever-Vectara|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "data": { "label": "" } - }, { "source": "chatOpenAI_0", "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", @@ -387,7 +430,20 @@ "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", "type": "buttonedge", "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "data": { "label": "" } + "data": { + "label": "" + } + }, + { + "source": "vectara_0", + "sourceHandle": "vectara_0-output-retriever-Vectara|VectorStoreRetriever|BaseRetriever", + "target": "conversationalRetrievalQAChain_0", + "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "type": "buttonedge", + "id": "vectara_0-vectara_0-output-retriever-Vectara|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", + "data": { + "label": "" + } } ] } diff --git a/packages/server/marketplaces/chatflows/WebBrowser.json b/packages/server/marketplaces/chatflows/WebBrowser.json index b784f9ab..0547366a 100644 --- a/packages/server/marketplaces/chatflows/WebBrowser.json +++ b/packages/server/marketplaces/chatflows/WebBrowser.json @@ -13,8 +13,8 @@ "data": { "id": "bufferMemory_0", "label": "Buffer Memory", - "name": "bufferMemory", "version": 1, + "name": "bufferMemory", "type": "BufferMemory", "baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"], "category": "Memory", @@ -70,8 +70,8 @@ "data": { "id": "webBrowser_0", "label": "Web Browser", - "name": "webBrowser", "version": 1, + "name": "webBrowser", "type": "WebBrowser", "baseClasses": ["WebBrowser", "Tool", "StructuredTool", "BaseLangChain"], "category": "Tools", @@ -115,82 +115,7 @@ }, { "width": 300, - "height": 383, - "id": "conversationalAgent_0", - "position": { - "x": 1464.513303631911, - "y": 155.73036805253955 - }, - "type": "customNode", - "data": { - "id": "conversationalAgent_0", - "label": "Conversational Agent", - "name": "conversationalAgent", - "version": 1, - "type": "AgentExecutor", - "baseClasses": ["AgentExecutor", "BaseChain"], - "category": "Agents", - "description": "Conversational agent for a chat model. It will utilize chat specific prompts", - "inputParams": [ - { - "label": "System Message", - "name": "systemMessage", - "type": "string", - "rows": 4, - "default": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.", - "optional": true, - "additionalParams": true, - "id": "conversationalAgent_0-input-systemMessage-string" - } - ], - "inputAnchors": [ - { - "label": "Allowed Tools", - "name": "tools", - "type": "Tool", - "list": true, - "id": "conversationalAgent_0-input-tools-Tool" - }, - { - "label": "Language Model", - "name": "model", - "type": "BaseLanguageModel", - "id": "conversationalAgent_0-input-model-BaseLanguageModel" - }, - { - "label": "Memory", - "name": "memory", - "type": "BaseChatMemory", - "id": "conversationalAgent_0-input-memory-BaseChatMemory" - } - ], - "inputs": { - "tools": ["{{webBrowser_0.data.instance}}"], - "model": "{{chatOpenAI_1.data.instance}}", - "memory": "{{bufferMemory_0.data.instance}}", - "systemMessage": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist." - }, - "outputAnchors": [ - { - "id": "conversationalAgent_0-output-conversationalAgent-AgentExecutor|BaseChain", - "name": "conversationalAgent", - "label": "AgentExecutor", - "type": "AgentExecutor | BaseChain" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1464.513303631911, - "y": 155.73036805253955 - }, - "dragging": false - }, - { - "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_0", "position": { "x": 734.7477982032904, @@ -200,8 +125,8 @@ "data": { "id": "chatOpenAI_0", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -311,6 +236,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" } ], "inputAnchors": [ @@ -330,7 +263,8 @@ "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -362,8 +296,8 @@ "data": { "id": "openAIEmbeddings_0", "label": "OpenAI Embeddings", - "name": "openAIEmbeddings", "version": 1, + "name": "openAIEmbeddings", "type": "OpenAIEmbeddings", "baseClasses": ["OpenAIEmbeddings", "Embeddings"], "category": "Embeddings", @@ -436,7 +370,7 @@ }, { "width": 300, - "height": 523, + "height": 574, "id": "chatOpenAI_1", "position": { "x": 68.312124033115, @@ -446,8 +380,8 @@ "data": { "id": "chatOpenAI_1", "label": "ChatOpenAI", - "name": "chatOpenAI", "version": 2, + "name": "chatOpenAI", "type": "ChatOpenAI", "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], "category": "Chat Models", @@ -557,6 +491,14 @@ "optional": true, "additionalParams": true, "id": "chatOpenAI_1-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_1-input-baseOptions-json" } ], "inputAnchors": [ @@ -569,14 +511,15 @@ } ], "inputs": { - "modelName": "gpt-3.5-turbo", + "modelName": "gpt-3.5-turbo-16k", "temperature": 0.9, "maxTokens": "", "topP": "", "frequencyPenalty": "", "presencePenalty": "", "timeout": "", - "basepath": "" + "basepath": "", + "baseOptions": "" }, "outputAnchors": [ { @@ -595,6 +538,81 @@ "y": -239.65476709991256 }, "dragging": false + }, + { + "width": 300, + "height": 383, + "id": "conversationalAgent_0", + "position": { + "x": 1518.944765840293, + "y": 212.2513364217197 + }, + "type": "customNode", + "data": { + "id": "conversationalAgent_0", + "label": "Conversational Agent", + "version": 2, + "name": "conversationalAgent", + "type": "AgentExecutor", + "baseClasses": ["AgentExecutor", "BaseChain", "Runnable"], + "category": "Agents", + "description": "Conversational agent for a chat model. It will utilize chat specific prompts", + "inputParams": [ + { + "label": "System Message", + "name": "systemMessage", + "type": "string", + "rows": 4, + "default": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.", + "optional": true, + "additionalParams": true, + "id": "conversationalAgent_0-input-systemMessage-string" + } + ], + "inputAnchors": [ + { + "label": "Allowed Tools", + "name": "tools", + "type": "Tool", + "list": true, + "id": "conversationalAgent_0-input-tools-Tool" + }, + { + "label": "Language Model", + "name": "model", + "type": "BaseChatModel", + "id": "conversationalAgent_0-input-model-BaseChatModel" + }, + { + "label": "Memory", + "name": "memory", + "type": "BaseChatMemory", + "id": "conversationalAgent_0-input-memory-BaseChatMemory" + } + ], + "inputs": { + "tools": ["{{webBrowser_0.data.instance}}"], + "model": "{{chatOpenAI_1.data.instance}}", + "memory": "{{bufferMemory_0.data.instance}}", + "systemMessage": "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist." + }, + "outputAnchors": [ + { + "id": "conversationalAgent_0-output-conversationalAgent-AgentExecutor|BaseChain|Runnable", + "name": "conversationalAgent", + "label": "AgentExecutor", + "type": "AgentExecutor | BaseChain | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1518.944765840293, + "y": 212.2513364217197 + }, + "dragging": false } ], "edges": [ @@ -620,17 +638,6 @@ "label": "" } }, - { - "source": "chatOpenAI_1", - "sourceHandle": "chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "conversationalAgent_0", - "targetHandle": "conversationalAgent_0-input-model-BaseLanguageModel", - "type": "buttonedge", - "id": "chatOpenAI_1-chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalAgent_0-conversationalAgent_0-input-model-BaseLanguageModel", - "data": { - "label": "" - } - }, { "source": "webBrowser_0", "sourceHandle": "webBrowser_0-output-webBrowser-WebBrowser|Tool|StructuredTool|BaseLangChain", @@ -642,6 +649,17 @@ "label": "" } }, + { + "source": "chatOpenAI_1", + "sourceHandle": "chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", + "target": "conversationalAgent_0", + "targetHandle": "conversationalAgent_0-input-model-BaseChatModel", + "type": "buttonedge", + "id": "chatOpenAI_1-chatOpenAI_1-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalAgent_0-conversationalAgent_0-input-model-BaseChatModel", + "data": { + "label": "" + } + }, { "source": "bufferMemory_0", "sourceHandle": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", diff --git a/packages/server/marketplaces/chatflows/WebPage QnA.json b/packages/server/marketplaces/chatflows/WebPage QnA.json index c4bbc22d..9b1119b9 100644 --- a/packages/server/marketplaces/chatflows/WebPage QnA.json +++ b/packages/server/marketplaces/chatflows/WebPage QnA.json @@ -4,173 +4,11 @@ "nodes": [ { "width": 300, - "height": 523, - "id": "chatOpenAI_0", - "position": { - "x": 1542.965468159417, - "y": -200.10756989974368 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_0", - "label": "ChatOpenAI", - "version": 2, - "name": "chatOpenAI", - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.9, - "optional": true, - "id": "chatOpenAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo-16k", - "temperature": "0.9", - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel" - } - ], - "outputs": {}, - "selected": false - }, - "positionAbsolute": { - "x": 1542.965468159417, - "y": -200.10756989974368 - }, - "selected": false, - "dragging": false - }, - { - "width": 300, - "height": 328, + "height": 329, "id": "openAIEmbeddings_0", "position": { - "x": 827.6835380475393, - "y": 253.8955254525015 + "x": 825.9524798523752, + "y": 243.50917628151723 }, "type": "customNode", "data": { @@ -243,8 +81,8 @@ }, "selected": false, "positionAbsolute": { - "x": 827.6835380475393, - "y": 253.8955254525015 + "x": 825.9524798523752, + "y": 243.50917628151723 }, "dragging": false }, @@ -314,7 +152,7 @@ }, { "width": 300, - "height": 479, + "height": 480, "id": "conversationalRetrievalQAChain_0", "position": { "x": 1882.5543981868987, @@ -398,8 +236,8 @@ ], "inputs": { "model": "{{chatOpenAI_0.data.instance}}", - "vectorStoreRetriever": "{{pineconeUpsert_0.data.instance}}", - "memory": "{{motorheadMemory_0.data.instance}}", + "vectorStoreRetriever": "{{pinecone_0.data.instance}}", + "memory": "{{RedisBackedChatMemory_0.data.instance}}", "returnSourceDocuments": true, "systemMessagePrompt": "I want you to act as a document that I am having a conversation with. Your name is \"AI Assistant\". You will provide me with answers from the given context. If the answer is not included, say exactly \"Hmm, I am not sure.\" and stop after that. Do not make up any information that is not in the context. Refuse to answer any question not about the info. Never break character.", "chainOption": "" @@ -427,8 +265,8 @@ "height": 380, "id": "cheerioWebScraper_0", "position": { - "x": 831.9867292136466, - "y": -181.92350323746112 + "x": 825.0624964329904, + "y": -183.65456143262517 }, "type": "customNode", "data": { @@ -525,42 +363,311 @@ }, "selected": false, "positionAbsolute": { - "x": 831.9867292136466, - "y": -181.92350323746112 + "x": 825.0624964329904, + "y": -183.65456143262517 + }, + "dragging": false + }, + { + "width": 300, + "height": 574, + "id": "chatOpenAI_0", + "position": { + "x": 1530.2074695018944, + "y": -247.5543013399219 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 2, + "name": "chatOpenAI", + "type": "ChatOpenAI", + "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], + "category": "Chat Models", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "credentialNames": ["openAIApi"], + "id": "chatOpenAI_0-input-credential-credential" + }, + { + "label": "Model Name", + "name": "modelName", + "type": "options", + "options": [ + { + "label": "gpt-4", + "name": "gpt-4" + }, + { + "label": "gpt-4-1106-preview", + "name": "gpt-4-1106-preview" + }, + { + "label": "gpt-4-vision-preview", + "name": "gpt-4-vision-preview" + }, + { + "label": "gpt-4-0613", + "name": "gpt-4-0613" + }, + { + "label": "gpt-4-32k", + "name": "gpt-4-32k" + }, + { + "label": "gpt-4-32k-0613", + "name": "gpt-4-32k-0613" + }, + { + "label": "gpt-3.5-turbo", + "name": "gpt-3.5-turbo" + }, + { + "label": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106" + }, + { + "label": "gpt-3.5-turbo-0613", + "name": "gpt-3.5-turbo-0613" + }, + { + "label": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k" + }, + { + "label": "gpt-3.5-turbo-16k-0613", + "name": "gpt-3.5-turbo-16k-0613" + } + ], + "default": "gpt-3.5-turbo", + "optional": true, + "id": "chatOpenAI_0-input-modelName-options" + }, + { + "label": "Temperature", + "name": "temperature", + "type": "number", + "step": 0.1, + "default": 0.9, + "optional": true, + "id": "chatOpenAI_0-input-temperature-number" + }, + { + "label": "Max Tokens", + "name": "maxTokens", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-maxTokens-number" + }, + { + "label": "Top Probability", + "name": "topP", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-topP-number" + }, + { + "label": "Frequency Penalty", + "name": "frequencyPenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-frequencyPenalty-number" + }, + { + "label": "Presence Penalty", + "name": "presencePenalty", + "type": "number", + "step": 0.1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-presencePenalty-number" + }, + { + "label": "Timeout", + "name": "timeout", + "type": "number", + "step": 1, + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-timeout-number" + }, + { + "label": "BasePath", + "name": "basepath", + "type": "string", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-basepath-string" + }, + { + "label": "BaseOptions", + "name": "baseOptions", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "chatOpenAI_0-input-baseOptions-json" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-3.5-turbo", + "temperature": 0.9, + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1530.2074695018944, + "y": -247.5543013399219 + }, + "dragging": false + }, + { + "width": 300, + "height": 329, + "id": "RedisBackedChatMemory_0", + "position": { + "x": 1203.0374706158896, + "y": 420.6341619933999 + }, + "type": "customNode", + "data": { + "id": "RedisBackedChatMemory_0", + "label": "Redis-Backed Chat Memory", + "version": 2, + "name": "RedisBackedChatMemory", + "type": "RedisBackedChatMemory", + "baseClasses": ["RedisBackedChatMemory", "BaseChatMemory", "BaseMemory"], + "category": "Memory", + "description": "Summarizes the conversation and stores the memory in Redis server", + "inputParams": [ + { + "label": "Connect Credential", + "name": "credential", + "type": "credential", + "optional": true, + "credentialNames": ["redisCacheApi", "redisCacheUrlApi"], + "id": "RedisBackedChatMemory_0-input-credential-credential" + }, + { + "label": "Session Id", + "name": "sessionId", + "type": "string", + "description": "If not specified, the first CHAT_MESSAGE_ID will be used as sessionId", + "default": "", + "additionalParams": true, + "optional": true, + "id": "RedisBackedChatMemory_0-input-sessionId-string" + }, + { + "label": "Session Timeouts", + "name": "sessionTTL", + "type": "number", + "description": "Omit this parameter to make sessions never expire", + "additionalParams": true, + "optional": true, + "id": "RedisBackedChatMemory_0-input-sessionTTL-number" + }, + { + "label": "Memory Key", + "name": "memoryKey", + "type": "string", + "default": "chat_history", + "additionalParams": true, + "id": "RedisBackedChatMemory_0-input-memoryKey-string" + } + ], + "inputAnchors": [], + "inputs": { + "sessionId": "", + "sessionTTL": "", + "memoryKey": "chat_history" + }, + "outputAnchors": [ + { + "id": "RedisBackedChatMemory_0-output-RedisBackedChatMemory-RedisBackedChatMemory|BaseChatMemory|BaseMemory", + "name": "RedisBackedChatMemory", + "label": "RedisBackedChatMemory", + "type": "RedisBackedChatMemory | BaseChatMemory | BaseMemory" + } + ], + "outputs": {}, + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 1203.0374706158896, + "y": 420.6341619933999 }, "dragging": false }, { "width": 300, "height": 555, - "id": "pineconeUpsert_0", + "id": "pinecone_0", "position": { - "x": 1179.6228496246993, - "y": -167.023255532671 + "x": 1194.3821796400694, + "y": -162.7324497768837 }, "type": "customNode", "data": { - "id": "pineconeUpsert_0", - "label": "Pinecone Upsert Document", + "id": "pinecone_0", + "label": "Pinecone", "version": 1, - "name": "pineconeUpsert", + "name": "pinecone", "type": "Pinecone", "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], "category": "Vector Stores", - "description": "Upsert documents to Pinecone", + "description": "Upsert embedded data and perform similarity search upon query using Pinecone, a leading fully managed hosted vector database", "inputParams": [ { "label": "Connect Credential", "name": "credential", "type": "credential", "credentialNames": ["pineconeApi"], - "id": "pineconeUpsert_0-input-credential-credential" + "id": "pinecone_0-input-credential-credential" }, { "label": "Pinecone Index", "name": "pineconeIndex", "type": "string", - "id": "pineconeUpsert_0-input-pineconeIndex-string" + "id": "pinecone_0-input-pineconeIndex-string" }, { "label": "Pinecone Namespace", @@ -569,7 +676,15 @@ "placeholder": "my-first-namespace", "additionalParams": true, "optional": true, - "id": "pineconeUpsert_0-input-pineconeNamespace-string" + "id": "pinecone_0-input-pineconeNamespace-string" + }, + { + "label": "Pinecone Metadata Filter", + "name": "pineconeMetadataFilter", + "type": "json", + "optional": true, + "additionalParams": true, + "id": "pinecone_0-input-pineconeMetadataFilter-json" }, { "label": "Top K", @@ -579,7 +694,7 @@ "type": "number", "additionalParams": true, "optional": true, - "id": "pineconeUpsert_0-input-topK-number" + "id": "pinecone_0-input-topK-number" } ], "inputAnchors": [ @@ -588,13 +703,14 @@ "name": "document", "type": "Document", "list": true, - "id": "pineconeUpsert_0-input-document-Document" + "optional": true, + "id": "pinecone_0-input-document-Document" }, { "label": "Embeddings", "name": "embeddings", "type": "Embeddings", - "id": "pineconeUpsert_0-input-embeddings-Embeddings" + "id": "pinecone_0-input-embeddings-Embeddings" } ], "inputs": { @@ -602,6 +718,7 @@ "embeddings": "{{openAIEmbeddings_0.data.instance}}", "pineconeIndex": "", "pineconeNamespace": "", + "pineconeMetadataFilter": "", "topK": "" }, "outputAnchors": [ @@ -611,13 +728,13 @@ "type": "options", "options": [ { - "id": "pineconeUpsert_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "id": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", "name": "retriever", "label": "Pinecone Retriever", "type": "Pinecone | VectorStoreRetriever | BaseRetriever" }, { - "id": "pineconeUpsert_0-output-vectorStore-Pinecone|VectorStore", + "id": "pinecone_0-output-vectorStore-Pinecone|VectorStore", "name": "vectorStore", "label": "Pinecone Vector Store", "type": "Pinecone | VectorStore" @@ -633,103 +750,13 @@ }, "selected": false, "positionAbsolute": { - "x": 1179.6228496246993, - "y": -167.023255532671 - }, - "dragging": false - }, - { - "width": 300, - "height": 427, - "id": "motorheadMemory_0", - "position": { - "x": 1202.1545938923578, - "y": 425.69055061366237 - }, - "type": "customNode", - "data": { - "id": "motorheadMemory_0", - "label": "Motorhead Memory", - "version": 1, - "name": "motorheadMemory", - "type": "MotorheadMemory", - "baseClasses": ["MotorheadMemory", "BaseChatMemory", "BaseMemory"], - "category": "Memory", - "description": "Use Motorhead Memory to store chat conversations", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "optional": true, - "description": "Only needed when using hosted solution - https://getmetal.io", - "credentialNames": ["motorheadMemoryApi"], - "id": "motorheadMemory_0-input-credential-credential" - }, - { - "label": "Base URL", - "name": "baseURL", - "type": "string", - "optional": true, - "description": "To use the online version, leave the URL blank. More details at https://getmetal.io.", - "id": "motorheadMemory_0-input-baseURL-string" - }, - { - "label": "Session Id", - "name": "sessionId", - "type": "string", - "description": "If not specified, the first CHAT_MESSAGE_ID will be used as sessionId", - "default": "", - "additionalParams": true, - "optional": true, - "id": "motorheadMemory_0-input-sessionId-string" - }, - { - "label": "Memory Key", - "name": "memoryKey", - "type": "string", - "default": "chat_history", - "additionalParams": true, - "id": "motorheadMemory_0-input-memoryKey-string" - } - ], - "inputAnchors": [], - "inputs": { - "baseURL": "", - "sessionId": "", - "memoryKey": "chat_history" - }, - "outputAnchors": [ - { - "id": "motorheadMemory_0-output-motorheadMemory-MotorheadMemory|BaseChatMemory|BaseMemory", - "name": "motorheadMemory", - "label": "MotorheadMemory", - "type": "MotorheadMemory | BaseChatMemory | BaseMemory" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1202.1545938923578, - "y": 425.69055061366237 + "x": 1194.3821796400694, + "y": -162.7324497768837 }, "dragging": false } ], "edges": [ - { - "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", - "data": { - "label": "" - } - }, { "source": "htmlToMarkdownTextSplitter_0", "sourceHandle": "htmlToMarkdownTextSplitter_0-output-htmlToMarkdownTextSplitter-HtmlToMarkdownTextSplitter|MarkdownTextSplitter|RecursiveCharacterTextSplitter|TextSplitter|BaseDocumentTransformer", @@ -741,13 +768,35 @@ "label": "" } }, + { + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "conversationalRetrievalQAChain_0", + "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", + "type": "buttonedge", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseLanguageModel", + "data": { + "label": "" + } + }, + { + "source": "RedisBackedChatMemory_0", + "sourceHandle": "RedisBackedChatMemory_0-output-RedisBackedChatMemory-RedisBackedChatMemory|BaseChatMemory|BaseMemory", + "target": "conversationalRetrievalQAChain_0", + "targetHandle": "conversationalRetrievalQAChain_0-input-memory-BaseMemory", + "type": "buttonedge", + "id": "RedisBackedChatMemory_0-RedisBackedChatMemory_0-output-RedisBackedChatMemory-RedisBackedChatMemory|BaseChatMemory|BaseMemory-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-memory-BaseMemory", + "data": { + "label": "" + } + }, { "source": "cheerioWebScraper_0", "sourceHandle": "cheerioWebScraper_0-output-cheerioWebScraper-Document", - "target": "pineconeUpsert_0", - "targetHandle": "pineconeUpsert_0-input-document-Document", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-document-Document", "type": "buttonedge", - "id": "cheerioWebScraper_0-cheerioWebScraper_0-output-cheerioWebScraper-Document-pineconeUpsert_0-pineconeUpsert_0-input-document-Document", + "id": "cheerioWebScraper_0-cheerioWebScraper_0-output-cheerioWebScraper-Document-pinecone_0-pinecone_0-input-document-Document", "data": { "label": "" } @@ -755,32 +804,21 @@ { "source": "openAIEmbeddings_0", "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pineconeUpsert_0", - "targetHandle": "pineconeUpsert_0-input-embeddings-Embeddings", + "target": "pinecone_0", + "targetHandle": "pinecone_0-input-embeddings-Embeddings", "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pineconeUpsert_0-pineconeUpsert_0-input-embeddings-Embeddings", + "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pinecone_0-pinecone_0-input-embeddings-Embeddings", "data": { "label": "" } }, { - "source": "pineconeUpsert_0", - "sourceHandle": "pineconeUpsert_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", + "source": "pinecone_0", + "sourceHandle": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", "target": "conversationalRetrievalQAChain_0", "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", "type": "buttonedge", - "id": "pineconeUpsert_0-pineconeUpsert_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", - "data": { - "label": "" - } - }, - { - "source": "motorheadMemory_0", - "sourceHandle": "motorheadMemory_0-output-motorheadMemory-MotorheadMemory|BaseChatMemory|BaseMemory", - "target": "conversationalRetrievalQAChain_0", - "targetHandle": "conversationalRetrievalQAChain_0-input-memory-BaseMemory", - "type": "buttonedge", - "id": "motorheadMemory_0-motorheadMemory_0-output-motorheadMemory-MotorheadMemory|BaseChatMemory|BaseMemory-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-memory-BaseMemory", + "id": "pinecone_0-pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever", "data": { "label": "" } diff --git a/packages/server/marketplaces/chatflows/Zapier NLA.json b/packages/server/marketplaces/chatflows/Zapier NLA.json deleted file mode 100644 index 49527da2..00000000 --- a/packages/server/marketplaces/chatflows/Zapier NLA.json +++ /dev/null @@ -1,290 +0,0 @@ -{ - "description": "An agent that uses Zapier NLA to accesss apps and actions on Zapier's platform", - "nodes": [ - { - "width": 300, - "height": 278, - "id": "zapierNLA_0", - "position": { - "x": 546.0561178227484, - "y": 83.03303671691799 - }, - "type": "customNode", - "data": { - "id": "zapierNLA_0", - "label": "Zapier NLA", - "name": "zapierNLA", - "version": 1, - "type": "ZapierNLA", - "baseClasses": ["ZapierNLA", "Tool"], - "category": "Tools", - "description": "Access to apps and actions on Zapier's platform through a natural language API interface", - "inputParams": [ - { - "label": "Zapier NLA Api Key", - "name": "apiKey", - "type": "password", - "id": "zapierNLA_0-input-apiKey-password" - } - ], - "inputAnchors": [], - "inputs": {}, - "outputAnchors": [ - { - "id": "zapierNLA_0-output-zapierNLA-ZapierNLA|Tool", - "name": "zapierNLA", - "label": "ZapierNLA", - "type": "ZapierNLA | Tool" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 546.0561178227484, - "y": 83.03303671691799 - }, - "dragging": false - }, - { - "width": 300, - "height": 280, - "id": "mrklAgentLLM_0", - "position": { - "x": 1002.5779315680477, - "y": 329.9701389591812 - }, - "type": "customNode", - "data": { - "id": "mrklAgentLLM_0", - "label": "MRKL Agent for LLMs", - "name": "mrklAgentLLM", - "version": 1, - "type": "AgentExecutor", - "baseClasses": ["AgentExecutor", "BaseChain", "BaseLangChain"], - "category": "Agents", - "description": "Agent that uses the ReAct Framework to decide what action to take, optimized to be used with LLMs", - "inputParams": [], - "inputAnchors": [ - { - "label": "Allowed Tools", - "name": "tools", - "type": "Tool", - "list": true, - "id": "mrklAgentLLM_0-input-tools-Tool" - }, - { - "label": "Language Model", - "name": "model", - "type": "BaseLanguageModel", - "id": "mrklAgentLLM_0-input-model-BaseLanguageModel" - } - ], - "inputs": { - "tools": ["{{zapierNLA_0.data.instance}}"], - "model": "{{openAI_0.data.instance}}" - }, - "outputAnchors": [ - { - "id": "mrklAgentLLM_0-output-mrklAgentLLM-AgentExecutor|BaseChain|BaseLangChain", - "name": "mrklAgentLLM", - "label": "AgentExecutor", - "type": "AgentExecutor | BaseChain | BaseLangChain" - } - ], - "outputs": {}, - "selected": false - }, - "positionAbsolute": { - "x": 1002.5779315680477, - "y": 329.9701389591812 - }, - "selected": false - }, - { - "width": 300, - "height": 523, - "id": "openAI_0", - "position": { - "x": 550.5957793208096, - "y": 378.30370661617934 - }, - "type": "customNode", - "data": { - "id": "openAI_0", - "label": "OpenAI", - "name": "openAI", - "version": 3, - "type": "OpenAI", - "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], - "category": "LLMs", - "description": "Wrapper around OpenAI large language models", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "openAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-3.5-turbo-instruct", - "name": "gpt-3.5-turbo-instruct" - }, - { - "label": "babbage-002", - "name": "babbage-002" - }, - { - "label": "davinci-002", - "name": "davinci-002" - } - ], - "default": "gpt-3.5-turbo-instruct", - "optional": true, - "id": "openAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "default": 0.7, - "optional": true, - "id": "openAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_0-input-topP-number" - }, - { - "label": "Best Of", - "name": "bestOf", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_0-input-bestOf-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_0-input-presencePenalty-number" - }, - { - "label": "Batch Size", - "name": "batchSize", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_0-input-batchSize-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "openAI_0-input-basepath-string" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "openAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "modelName": "gpt-3.5-turbo-instruct", - "temperature": 0.7, - "maxTokens": "", - "topP": "", - "bestOf": "", - "frequencyPenalty": "", - "presencePenalty": "", - "batchSize": "", - "timeout": "", - "basepath": "" - }, - "outputAnchors": [ - { - "id": "openAI_0-output-openAI-OpenAI|BaseLLM|BaseLanguageModel", - "name": "openAI", - "label": "OpenAI", - "type": "OpenAI | BaseLLM | BaseLanguageModel" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 550.5957793208096, - "y": 378.30370661617934 - }, - "dragging": false - } - ], - "edges": [ - { - "source": "zapierNLA_0", - "sourceHandle": "zapierNLA_0-output-zapierNLA-ZapierNLA|Tool", - "target": "mrklAgentLLM_0", - "targetHandle": "mrklAgentLLM_0-input-tools-Tool", - "type": "buttonedge", - "id": "zapierNLA_0-zapierNLA_0-output-zapierNLA-ZapierNLA|Tool-mrklAgentLLM_0-mrklAgentLLM_0-input-tools-Tool", - "data": { - "label": "" - } - }, - { - "source": "openAI_0", - "sourceHandle": "openAI_0-output-openAI-OpenAI|BaseLLM|BaseLanguageModel", - "target": "mrklAgentLLM_0", - "targetHandle": "mrklAgentLLM_0-input-model-BaseLanguageModel", - "type": "buttonedge", - "id": "openAI_0-openAI_0-output-openAI-OpenAI|BaseLLM|BaseLanguageModel-mrklAgentLLM_0-mrklAgentLLM_0-input-model-BaseLanguageModel", - "data": { - "label": "" - } - } - ] -} diff --git a/packages/server/package.json b/packages/server/package.json index ab48decd..6f4ccaf4 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "flowise", - "version": "1.4.0-rc.1", + "version": "1.4.3", "description": "Flowiseai Server", "main": "dist/index", "types": "dist/index.d.ts", @@ -54,8 +54,8 @@ "express": "^4.17.3", "express-basic-auth": "^1.2.1", "express-rate-limit": "^6.9.0", - "flowise-components": "1.4.0-rc.1", - "flowise-ui": "1.4.0-rc.1", + "flowise-components": "*", + "flowise-ui": "*", "moment-timezone": "^0.5.34", "multer": "^1.4.5-lts.1", "mysql": "^2.18.1", diff --git a/packages/server/src/Interface.ts b/packages/server/src/Interface.ts index 1d272464..c562b4ee 100644 --- a/packages/server/src/Interface.ts +++ b/packages/server/src/Interface.ts @@ -166,6 +166,7 @@ export interface IncomingInput { overrideConfig?: ICommonObject socketIOClientId?: string chatId?: string + stopNodeId?: string } export interface IActiveChatflows { diff --git a/packages/server/src/database/entities/ChatFlow.ts b/packages/server/src/database/entities/ChatFlow.ts index 376a100b..b3131c2e 100644 --- a/packages/server/src/database/entities/ChatFlow.ts +++ b/packages/server/src/database/entities/ChatFlow.ts @@ -36,4 +36,7 @@ export class ChatFlow implements IChatFlow { @UpdateDateColumn() updatedDate: Date + + @Column({ nullable: true, type: 'text' }) + category?: string } diff --git a/packages/server/src/database/migrations/mysql/1699900910291-AddCategoryToChatFlow.ts b/packages/server/src/database/migrations/mysql/1699900910291-AddCategoryToChatFlow.ts new file mode 100644 index 00000000..424f3b0e --- /dev/null +++ b/packages/server/src/database/migrations/mysql/1699900910291-AddCategoryToChatFlow.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddCategoryToChatFlow1699900910291 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_flow', 'category') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`category\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`category\`;`) + } +} diff --git a/packages/server/src/database/migrations/mysql/index.ts b/packages/server/src/database/migrations/mysql/index.ts index eff089cd..8f9824a8 100644 --- a/packages/server/src/database/migrations/mysql/index.ts +++ b/packages/server/src/database/migrations/mysql/index.ts @@ -8,6 +8,7 @@ import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic' import { AddChatHistory1694658767766 } from './1694658767766-AddChatHistory' import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity' import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage' +import { AddCategoryToChatFlow1699900910291 } from './1699900910291-AddCategoryToChatFlow' import { AddFileAnnotationsToChatMessage1700271021237 } from './1700271021237-AddFileAnnotationsToChatMessage' export const mysqlMigrations = [ @@ -21,5 +22,6 @@ export const mysqlMigrations = [ AddChatHistory1694658767766, AddAssistantEntity1699325775451, AddUsedToolsToChatMessage1699481607341, + AddCategoryToChatFlow1699900910291, AddFileAnnotationsToChatMessage1700271021237 ] diff --git a/packages/server/src/database/migrations/postgres/1699900910291-AddCategoryToChatFlow.ts b/packages/server/src/database/migrations/postgres/1699900910291-AddCategoryToChatFlow.ts new file mode 100644 index 00000000..f5d96439 --- /dev/null +++ b/packages/server/src/database/migrations/postgres/1699900910291-AddCategoryToChatFlow.ts @@ -0,0 +1,11 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddCategoryToChatFlow1699900910291 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "chat_flow" ADD COLUMN IF NOT EXISTS "category" TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "chat_flow" DROP COLUMN "category";`) + } +} diff --git a/packages/server/src/database/migrations/postgres/index.ts b/packages/server/src/database/migrations/postgres/index.ts index 93d02f3e..d196fbc1 100644 --- a/packages/server/src/database/migrations/postgres/index.ts +++ b/packages/server/src/database/migrations/postgres/index.ts @@ -8,6 +8,7 @@ import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic' import { AddChatHistory1694658756136 } from './1694658756136-AddChatHistory' import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity' import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage' +import { AddCategoryToChatFlow1699900910291 } from './1699900910291-AddCategoryToChatFlow' import { AddFileAnnotationsToChatMessage1700271021237 } from './1700271021237-AddFileAnnotationsToChatMessage' export const postgresMigrations = [ @@ -21,5 +22,6 @@ export const postgresMigrations = [ AddChatHistory1694658756136, AddAssistantEntity1699325775451, AddUsedToolsToChatMessage1699481607341, + AddCategoryToChatFlow1699900910291, AddFileAnnotationsToChatMessage1700271021237 ] diff --git a/packages/server/src/database/migrations/sqlite/1699900910291-AddCategoryToChatFlow.ts b/packages/server/src/database/migrations/sqlite/1699900910291-AddCategoryToChatFlow.ts new file mode 100644 index 00000000..270b2998 --- /dev/null +++ b/packages/server/src/database/migrations/sqlite/1699900910291-AddCategoryToChatFlow.ts @@ -0,0 +1,11 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddCategoryToChatFlow1699900910291 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "chat_flow" ADD COLUMN "category" TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "chat_flow" DROP COLUMN "category";`) + } +} diff --git a/packages/server/src/database/migrations/sqlite/index.ts b/packages/server/src/database/migrations/sqlite/index.ts index edba5930..fdd83064 100644 --- a/packages/server/src/database/migrations/sqlite/index.ts +++ b/packages/server/src/database/migrations/sqlite/index.ts @@ -8,6 +8,7 @@ import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic' import { AddChatHistory1694657778173 } from './1694657778173-AddChatHistory' import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity' import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage' +import { AddCategoryToChatFlow1699900910291 } from './1699900910291-AddCategoryToChatFlow' import { AddFileAnnotationsToChatMessage1700271021237 } from './1700271021237-AddFileAnnotationsToChatMessage' export const sqliteMigrations = [ @@ -21,5 +22,6 @@ export const sqliteMigrations = [ AddChatHistory1694657778173, AddAssistantEntity1699325775451, AddUsedToolsToChatMessage1699481607341, + AddCategoryToChatFlow1699900910291, AddFileAnnotationsToChatMessage1700271021237 ] diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 57245f2c..91de4f4c 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -135,6 +135,7 @@ export class App { '/api/v1/chatflows/apikey/', '/api/v1/public-chatflows', '/api/v1/prediction/', + '/api/v1/vector/upsert/', '/api/v1/node-icon/', '/api/v1/components-credentials-icon/', '/api/v1/chatflows-streaming', @@ -356,8 +357,12 @@ export class App { this.AppDataSource.getRepository(ChatFlow).merge(chatflow, updateChatFlow) const result = await this.AppDataSource.getRepository(ChatFlow).save(chatflow) - // Update chatflowpool inSync to false, to build Langchain again because data has been changed - this.chatflowPool.updateInSync(chatflow.id, false) + // chatFlowPool is initialized only when a flow is opened + // if the user attempts to rename/update category without opening any flow, chatFlowPool will be undefined + if (this.chatflowPool) { + // Update chatflowpool inSync to false, to build Langchain again because data has been changed + this.chatflowPool.updateInSync(chatflow.id, false) + } return res.json(result) }) @@ -1071,6 +1076,23 @@ export class App { return res.status(201).send('OK') }) + // ---------------------------------------- + // Upsert + // ---------------------------------------- + + this.app.post( + '/api/v1/vector/upsert/:id', + upload.array('files'), + (req: Request, res: Response, next: NextFunction) => getRateLimiter(req, res, next), + async (req: Request, res: Response) => { + await this.buildChatflow(req, res, undefined, false, true) + } + ) + + this.app.post('/api/v1/vector/internal-upsert/:id', async (req: Request, res: Response) => { + await this.buildChatflow(req, res, undefined, true, true) + }) + // ---------------------------------------- // Prediction // ---------------------------------------- @@ -1081,13 +1103,13 @@ export class App { upload.array('files'), (req: Request, res: Response, next: NextFunction) => getRateLimiter(req, res, next), async (req: Request, res: Response) => { - await this.processPrediction(req, res, socketIO) + await this.buildChatflow(req, res, socketIO) } ) // Send input message and get prediction result (Internal) this.app.post('/api/v1/internal-prediction/:id', async (req: Request, res: Response) => { - await this.processPrediction(req, res, socketIO, true) + await this.buildChatflow(req, res, socketIO, true) }) // ---------------------------------------- @@ -1144,28 +1166,52 @@ export class App { // API Keys // ---------------------------------------- + const addChatflowsCount = async (keys: any, res: Response) => { + if (keys) { + const updatedKeys: any[] = [] + //iterate through keys and get chatflows + for (const key of keys) { + const chatflows = await this.AppDataSource.getRepository(ChatFlow) + .createQueryBuilder('cf') + .where('cf.apikeyid = :apikeyid', { apikeyid: key.id }) + .getMany() + const linkedChatFlows: any[] = [] + chatflows.map((cf) => { + linkedChatFlows.push({ + flowName: cf.name, + category: cf.category, + updatedDate: cf.updatedDate + }) + }) + key.chatFlows = linkedChatFlows + updatedKeys.push(key) + } + return res.json(updatedKeys) + } + return res.json(keys) + } // Get api keys this.app.get('/api/v1/apikey', async (req: Request, res: Response) => { const keys = await getAPIKeys() - return res.json(keys) + return addChatflowsCount(keys, res) }) // Add new api key this.app.post('/api/v1/apikey', async (req: Request, res: Response) => { const keys = await addAPIKey(req.body.keyName) - return res.json(keys) + return addChatflowsCount(keys, res) }) // Update api key this.app.put('/api/v1/apikey/:id', async (req: Request, res: Response) => { const keys = await updateAPIKey(req.params.id, req.body.keyName) - return res.json(keys) + return addChatflowsCount(keys, res) }) // Delete new api key this.app.delete('/api/v1/apikey/:id', async (req: Request, res: Response) => { const keys = await deleteAPIKey(req.params.id) - return res.json(keys) + return addChatflowsCount(keys, res) }) // Verify api key @@ -1293,13 +1339,14 @@ export class App { } /** - * Process Prediction + * Build Chatflow * @param {Request} req * @param {Response} res * @param {Server} socketIO * @param {boolean} isInternal + * @param {boolean} isUpsert */ - async processPrediction(req: Request, res: Response, socketIO?: Server, isInternal: boolean = false) { + async buildChatflow(req: Request, res: Response, socketIO?: Server, isInternal: boolean = false, isUpsert: boolean = false) { try { const chatflowid = req.params.id let incomingInput: IncomingInput = req.body @@ -1340,7 +1387,8 @@ export class App { question: req.body.question ?? 'hello', overrideConfig, history: [], - socketIOClientId: req.body.socketIOClientId + socketIOClientId: req.body.socketIOClientId, + stopNodeId: req.body.stopNodeId } } @@ -1365,7 +1413,8 @@ export class App { this.chatflowPool.activeChatflows[chatflowid].overrideConfig, incomingInput.overrideConfig ) && - !isStartNodeDependOnInput(this.chatflowPool.activeChatflows[chatflowid].startingNodes, nodes) + !isStartNodeDependOnInput(this.chatflowPool.activeChatflows[chatflowid].startingNodes, nodes) && + !isUpsert ) } @@ -1385,14 +1434,15 @@ export class App { const endingNodeData = nodes.find((nd) => nd.id === endingNodeId)?.data if (!endingNodeData) return res.status(500).send(`Ending node ${endingNodeId} data not found`) - if (endingNodeData && endingNodeData.category !== 'Chains' && endingNodeData.category !== 'Agents') { + if (endingNodeData && endingNodeData.category !== 'Chains' && endingNodeData.category !== 'Agents' && !isUpsert) { return res.status(500).send(`Ending node must be either a Chain or Agent`) } if ( endingNodeData.outputs && Object.keys(endingNodeData.outputs).length && - !Object.values(endingNodeData.outputs).includes(endingNodeData.name) + !Object.values(endingNodeData.outputs).includes(endingNodeData.name) && + !isUpsert ) { return res .status(500) @@ -1422,8 +1472,11 @@ export class App { chatflowid, this.AppDataSource, incomingInput?.overrideConfig, - this.cachePool + this.cachePool, + isUpsert, + incomingInput.stopNodeId ) + if (isUpsert) return res.status(201).send('Successfully Upserted') const nodeToExecute = reactFlowNodes.find((node: IReactFlowNode) => node.id === endingNodeId) if (!nodeToExecute) return res.status(404).send(`Node ${endingNodeId} not found`) diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts index 239773a9..9dbb695e 100644 --- a/packages/server/src/utils/index.ts +++ b/packages/server/src/utils/index.ts @@ -222,7 +222,9 @@ export const buildLangchain = async ( chatflowid: string, appDataSource: DataSource, overrideConfig?: ICommonObject, - cachePool?: CachePool + cachePool?: CachePool, + isUpsert?: boolean, + stopNodeId?: string ) => { const flowNodes = cloneDeep(reactFlowNodes) @@ -254,16 +256,33 @@ export const buildLangchain = async ( if (overrideConfig) flowNodeData = replaceInputsWithConfig(flowNodeData, overrideConfig) const reactFlowNodeData: INodeData = resolveVariables(flowNodeData, flowNodes, question, chatHistory) - logger.debug(`[server]: Initializing ${reactFlowNode.data.label} (${reactFlowNode.data.id})`) - flowNodes[nodeIndex].data.instance = await newNodeInstance.init(reactFlowNodeData, question, { - chatId, - chatflowid, - appDataSource, - databaseEntities, - logger, - cachePool - }) - logger.debug(`[server]: Finished initializing ${reactFlowNode.data.label} (${reactFlowNode.data.id})`) + if ( + isUpsert && + ((stopNodeId && reactFlowNodeData.id === stopNodeId) || (!stopNodeId && reactFlowNodeData.category === 'Vector Stores')) + ) { + logger.debug(`[server]: Upserting ${reactFlowNode.data.label} (${reactFlowNode.data.id})`) + await newNodeInstance.vectorStoreMethods!['upsert']!.call(newNodeInstance, reactFlowNodeData, { + chatId, + chatflowid, + appDataSource, + databaseEntities, + logger, + cachePool + }) + logger.debug(`[server]: Finished upserting ${reactFlowNode.data.label} (${reactFlowNode.data.id})`) + break + } else { + logger.debug(`[server]: Initializing ${reactFlowNode.data.label} (${reactFlowNode.data.id})`) + flowNodes[nodeIndex].data.instance = await newNodeInstance.init(reactFlowNodeData, question, { + chatId, + chatflowid, + appDataSource, + databaseEntities, + logger, + cachePool + }) + logger.debug(`[server]: Finished initializing ${reactFlowNode.data.label} (${reactFlowNode.data.id})`) + } } catch (e: any) { logger.error(e) throw new Error(e) @@ -825,7 +844,7 @@ export const findAvailableConfigs = (reactFlowNodes: IReactFlowNode[], component */ export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNodeData: INodeData) => { const streamAvailableLLMs = { - 'Chat Models': ['azureChatOpenAI', 'chatOpenAI', 'chatAnthropic', 'chatOllama'], + 'Chat Models': ['azureChatOpenAI', 'chatOpenAI', 'chatAnthropic', 'chatOllama', 'awsChatBedrock'], LLMs: ['azureOpenAI', 'openAI', 'ollama'] } @@ -842,7 +861,7 @@ export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNod let isValidChainOrAgent = false if (endingNodeData.category === 'Chains') { // Chains that are not available to stream - const blacklistChains = ['openApiChain'] + const blacklistChains = ['openApiChain', 'vectaraQAChain'] isValidChainOrAgent = !blacklistChains.includes(endingNodeData.name) } else if (endingNodeData.category === 'Agents') { // Agent that are available to stream @@ -985,10 +1004,14 @@ export const redactCredentialWithPasswordType = ( * @param {any} instance * @param {string} chatId */ -export const checkMemorySessionId = (instance: any, chatId: string): string => { +export const checkMemorySessionId = (instance: any, chatId: string): string | undefined => { if (instance.memory && instance.memory.isSessionIdUsingChatMessageId && chatId) { instance.memory.sessionId = chatId instance.memory.chatHistory.sessionId = chatId } - return instance.memory ? instance.memory.sessionId ?? instance.memory.chatHistory.sessionId : undefined + + if (instance.memory && instance.memory.sessionId) return instance.memory.sessionId + else if (instance.memory && instance.memory.chatHistory && instance.memory.chatHistory.sessionId) + return instance.memory.chatHistory.sessionId + return undefined } diff --git a/packages/ui/package.json b/packages/ui/package.json index ab0b2740..76369ab2 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "flowise-ui", - "version": "1.4.0-rc.1", + "version": "1.4.1", "license": "SEE LICENSE IN LICENSE.md", "homepage": "https://flowiseai.com", "author": { diff --git a/packages/ui/src/api/vectorstore.js b/packages/ui/src/api/vectorstore.js new file mode 100644 index 00000000..053f5112 --- /dev/null +++ b/packages/ui/src/api/vectorstore.js @@ -0,0 +1,7 @@ +import client from './client' + +const upsertVectorStore = (id, input) => client.post(`/vector/internal-upsert/${id}`, input) + +export default { + upsertVectorStore +} diff --git a/packages/ui/src/assets/scss/_themes-vars.module.scss b/packages/ui/src/assets/scss/_themes-vars.module.scss index 374c36c9..6304b707 100644 --- a/packages/ui/src/assets/scss/_themes-vars.module.scss +++ b/packages/ui/src/assets/scss/_themes-vars.module.scss @@ -31,6 +31,11 @@ $orangeLight: #fbe9e7; $orangeMain: #ffab91; $orangeDark: #d84315; +// brown +$tealLight: #76c893; +$tealMain: #52b69a; +$tealDark: #34a0a4; + // warning $warningLight: #fff8e1; $warningMain: #ffe57f; @@ -46,6 +51,9 @@ $grey600: #757575; $grey700: #616161; $grey900: #212121; +// transparent +$transparent: #ffffff00; + // ==============================|| DARK THEME VARIANTS ||============================== // // paper & background @@ -111,6 +119,11 @@ $darkTextSecondary: #8492c4; orangeMain: $orangeMain; orangeDark: $orangeDark; + // orange + tealLight: $tealLight; + tealMain: $tealMain; + tealDark: $tealDark; + // warning warningLight: $warningLight; warningMain: $warningMain; @@ -154,4 +167,7 @@ $darkTextSecondary: #8492c4; darkSecondaryDark: $darkSecondaryDark; darkSecondary200: $darkSecondary200; darkSecondary800: $darkSecondary800; + + // transparent + transparent: $transparent; } diff --git a/packages/ui/src/store/context/ReactFlowContext.js b/packages/ui/src/store/context/ReactFlowContext.js index 055cb8bc..36190626 100644 --- a/packages/ui/src/store/context/ReactFlowContext.js +++ b/packages/ui/src/store/context/ReactFlowContext.js @@ -97,9 +97,8 @@ export const ReactFlowContext = ({ children }) => { selected: false } - const dataKeys = ['inputParams', 'inputAnchors', 'outputAnchors'] - - for (const key of dataKeys) { + const inputKeys = ['inputParams', 'inputAnchors'] + for (const key of inputKeys) { for (const item of duplicatedNode.data[key]) { if (item.id) { item.id = item.id.replace(id, newNodeId) @@ -107,6 +106,35 @@ export const ReactFlowContext = ({ children }) => { } } + const outputKeys = ['outputAnchors'] + for (const key of outputKeys) { + for (const item of duplicatedNode.data[key]) { + if (item.id) { + item.id = item.id.replace(id, newNodeId) + } + if (item.options) { + for (const output of item.options) { + output.id = output.id.replace(id, newNodeId) + } + } + } + } + + // Clear connected inputs + for (const inputName in duplicatedNode.data.inputs) { + if ( + typeof duplicatedNode.data.inputs[inputName] === 'string' && + duplicatedNode.data.inputs[inputName].startsWith('{{') && + duplicatedNode.data.inputs[inputName].endsWith('}}') + ) { + duplicatedNode.data.inputs[inputName] = '' + } else if (Array.isArray(duplicatedNode.data.inputs[inputName])) { + duplicatedNode.data.inputs[inputName] = duplicatedNode.data.inputs[inputName].filter( + (item) => !(typeof item === 'string' && item.startsWith('{{') && item.endsWith('}}')) + ) + } + } + reactFlowInstance.setNodes([...nodes, duplicatedNode]) dispatch({ type: SET_DIRTY }) } diff --git a/packages/ui/src/themes/palette.js b/packages/ui/src/themes/palette.js index 66ec3d01..750fe1be 100644 --- a/packages/ui/src/themes/palette.js +++ b/packages/ui/src/themes/palette.js @@ -6,6 +6,7 @@ export default function themePalette(theme) { return { mode: theme?.customization?.navType, + transparent: theme.colors?.transparent, common: { black: theme.colors?.darkPaper, dark: theme.colors?.darkPrimaryMain @@ -34,6 +35,11 @@ export default function themePalette(theme) { main: theme.colors?.orangeMain, dark: theme.colors?.orangeDark }, + teal: { + light: theme.colors?.tealLight, + main: theme.colors?.tealMain, + dark: theme.colors?.tealDark + }, warning: { light: theme.colors?.warningLight, main: theme.colors?.warningMain, diff --git a/packages/ui/src/ui-component/button/FlowListMenu.js b/packages/ui/src/ui-component/button/FlowListMenu.js new file mode 100644 index 00000000..b242d2cb --- /dev/null +++ b/packages/ui/src/ui-component/button/FlowListMenu.js @@ -0,0 +1,291 @@ +import { useState } from 'react' +import { useDispatch } from 'react-redux' +import PropTypes from 'prop-types' + +import { styled, alpha } from '@mui/material/styles' +import Menu from '@mui/material/Menu' +import MenuItem from '@mui/material/MenuItem' +import EditIcon from '@mui/icons-material/Edit' +import Divider from '@mui/material/Divider' +import FileCopyIcon from '@mui/icons-material/FileCopy' +import FileDownloadIcon from '@mui/icons-material/Downloading' +import FileDeleteIcon from '@mui/icons-material/Delete' +import FileCategoryIcon from '@mui/icons-material/Category' +import Button from '@mui/material/Button' +import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' +import { IconX } from '@tabler/icons' + +import chatflowsApi from 'api/chatflows' + +import useApi from '../../hooks/useApi' +import useConfirm from 'hooks/useConfirm' +import { uiBaseURL } from '../../store/constant' +import { closeSnackbar as closeSnackbarAction, enqueueSnackbar as enqueueSnackbarAction } from '../../store/actions' + +import ConfirmDialog from '../dialog/ConfirmDialog' +import SaveChatflowDialog from '../dialog/SaveChatflowDialog' +import TagDialog from '../dialog/TagDialog' + +import { generateExportFlowData } from '../../utils/genericHelper' +import useNotifier from '../../utils/useNotifier' + +const StyledMenu = styled((props) => ( + +))(({ theme }) => ({ + '& .MuiPaper-root': { + borderRadius: 6, + marginTop: theme.spacing(1), + minWidth: 180, + boxShadow: + 'rgb(255, 255, 255) 0px 0px 0px 0px, rgba(0, 0, 0, 0.05) 0px 0px 0px 1px, rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px', + '& .MuiMenu-list': { + padding: '4px 0' + }, + '& .MuiMenuItem-root': { + '& .MuiSvgIcon-root': { + fontSize: 18, + color: theme.palette.text.secondary, + marginRight: theme.spacing(1.5) + }, + '&:active': { + backgroundColor: alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity) + } + } + } +})) + +export default function FlowListMenu({ chatflow, updateFlowsApi }) { + const { confirm } = useConfirm() + const dispatch = useDispatch() + const updateChatflowApi = useApi(chatflowsApi.updateChatflow) + + useNotifier() + const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args)) + const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args)) + + const [flowDialogOpen, setFlowDialogOpen] = useState(false) + const [categoryDialogOpen, setCategoryDialogOpen] = useState(false) + const [categoryDialogProps, setCategoryDialogProps] = useState({}) + const [anchorEl, setAnchorEl] = useState(null) + const open = Boolean(anchorEl) + + const handleClick = (event) => { + setAnchorEl(event.currentTarget) + } + + const handleClose = () => { + setAnchorEl(null) + } + + const handleFlowRename = () => { + setAnchorEl(null) + setFlowDialogOpen(true) + } + + const saveFlowRename = async (chatflowName) => { + const updateBody = { + name: chatflowName, + chatflow + } + try { + await updateChatflowApi.request(chatflow.id, updateBody) + await updateFlowsApi.request() + } catch (error) { + const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}` + enqueueSnackbar({ + message: errorData, + options: { + key: new Date().getTime() + Math.random(), + variant: 'error', + persist: true, + action: (key) => ( + + ) + } + }) + } + } + + const handleFlowCategory = () => { + setAnchorEl(null) + if (chatflow.category) { + setCategoryDialogProps({ + category: chatflow.category.split(';') + }) + } + setCategoryDialogOpen(true) + } + + const saveFlowCategory = async (categories) => { + setCategoryDialogOpen(false) + // save categories as string + const categoryTags = categories.join(';') + const updateBody = { + category: categoryTags, + chatflow + } + try { + await updateChatflowApi.request(chatflow.id, updateBody) + await updateFlowsApi.request() + } catch (error) { + const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}` + enqueueSnackbar({ + message: errorData, + options: { + key: new Date().getTime() + Math.random(), + variant: 'error', + persist: true, + action: (key) => ( + + ) + } + }) + } + } + + const handleDelete = async () => { + setAnchorEl(null) + const confirmPayload = { + title: `Delete`, + description: `Delete chatflow ${chatflow.name}?`, + confirmButtonName: 'Delete', + cancelButtonName: 'Cancel' + } + const isConfirmed = await confirm(confirmPayload) + + if (isConfirmed) { + try { + await chatflowsApi.deleteChatflow(chatflow.id) + await updateFlowsApi.request() + } catch (error) { + const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}` + enqueueSnackbar({ + message: errorData, + options: { + key: new Date().getTime() + Math.random(), + variant: 'error', + persist: true, + action: (key) => ( + + ) + } + }) + } + } + } + + const handleDuplicate = () => { + setAnchorEl(null) + try { + localStorage.setItem('duplicatedFlowData', chatflow.flowData) + window.open(`${uiBaseURL}/canvas`, '_blank') + } catch (e) { + console.error(e) + } + } + + const handleExport = () => { + setAnchorEl(null) + try { + const flowData = JSON.parse(chatflow.flowData) + let dataStr = JSON.stringify(generateExportFlowData(flowData), null, 2) + let dataUri = 'data:application/json;charset=utf-8,' + encodeURIComponent(dataStr) + + let exportFileDefaultName = `${chatflow.name} Chatflow.json` + + let linkElement = document.createElement('a') + linkElement.setAttribute('href', dataUri) + linkElement.setAttribute('download', exportFileDefaultName) + linkElement.click() + } catch (e) { + console.error(e) + } + } + + return ( +
+ + + + + Rename + + + + Duplicate + + + + Export + + + + + Update Category + + + + + Delete + + + + setFlowDialogOpen(false)} + onConfirm={saveFlowRename} + /> + setCategoryDialogOpen(false)} + onSubmit={saveFlowCategory} + /> +
+ ) +} + +FlowListMenu.propTypes = { + chatflow: PropTypes.object, + updateFlowsApi: PropTypes.object +} diff --git a/packages/ui/src/ui-component/button/StyledButton.js b/packages/ui/src/ui-component/button/StyledButton.js index 6e0c7078..29e17f80 100644 --- a/packages/ui/src/ui-component/button/StyledButton.js +++ b/packages/ui/src/ui-component/button/StyledButton.js @@ -1,5 +1,6 @@ import { styled } from '@mui/material/styles' import { Button } from '@mui/material' +import MuiToggleButton from '@mui/material/ToggleButton' export const StyledButton = styled(Button)(({ theme, color = 'primary' }) => ({ color: 'white', @@ -9,3 +10,10 @@ export const StyledButton = styled(Button)(({ theme, color = 'primary' }) => ({ backgroundImage: `linear-gradient(rgb(0 0 0/10%) 0 0)` } })) + +export const StyledToggleButton = styled(MuiToggleButton)(({ theme, color = 'primary' }) => ({ + '&.Mui-selected, &.Mui-selected:hover': { + color: 'white', + backgroundColor: theme.palette[color].main + } +})) diff --git a/packages/ui/src/ui-component/dialog/NodeInfoDialog.js b/packages/ui/src/ui-component/dialog/NodeInfoDialog.js index 74c45a1a..6f3bec5d 100644 --- a/packages/ui/src/ui-component/dialog/NodeInfoDialog.js +++ b/packages/ui/src/ui-component/dialog/NodeInfoDialog.js @@ -106,6 +106,32 @@ const NodeInfoDialog = ({ show, dialogProps, onCancel }) => { version {dialogProps.data.version} )} + {dialogProps.data.badge && ( +
+ + {dialogProps.data.badge} + +
+ )} @@ -123,7 +149,14 @@ const NodeInfoDialog = ({ show, dialogProps, onCancel }) => { )} {getNodeConfigApi.data && getNodeConfigApi.data.length > 0 && ( - + { + // eslint-disable-next-line + const { node, nodeId, ...rest } = obj + return rest + })} + columns={Object.keys(getNodeConfigApi.data[0]).slice(-3)} + /> )} diff --git a/packages/ui/src/ui-component/dialog/TagDialog.js b/packages/ui/src/ui-component/dialog/TagDialog.js new file mode 100644 index 00000000..82c35dde --- /dev/null +++ b/packages/ui/src/ui-component/dialog/TagDialog.js @@ -0,0 +1,110 @@ +import { useState, useEffect } from 'react' +import Dialog from '@mui/material/Dialog' +import Box from '@mui/material/Box' +import Button from '@mui/material/Button' +import TextField from '@mui/material/TextField' +import Chip from '@mui/material/Chip' +import PropTypes from 'prop-types' +import { DialogActions, DialogContent, DialogTitle, Typography } from '@mui/material' + +const TagDialog = ({ isOpen, dialogProps, onClose, onSubmit }) => { + const [inputValue, setInputValue] = useState('') + const [categoryValues, setCategoryValues] = useState([]) + + const handleInputChange = (event) => { + setInputValue(event.target.value) + } + + const handleInputKeyDown = (event) => { + if (event.key === 'Enter' && inputValue.trim()) { + event.preventDefault() + if (!categoryValues.includes(inputValue)) { + setCategoryValues([...categoryValues, inputValue]) + setInputValue('') + } + } + } + + const handleDeleteTag = (categoryToDelete) => { + setCategoryValues(categoryValues.filter((category) => category !== categoryToDelete)) + } + + const handleSubmit = (event) => { + event.preventDefault() + let newCategories = [...categoryValues] + if (inputValue.trim() && !categoryValues.includes(inputValue)) { + newCategories = [...newCategories, inputValue] + setCategoryValues(newCategories) + } + onSubmit(newCategories) + } + + useEffect(() => { + if (dialogProps.category) setCategoryValues(dialogProps.category) + + return () => { + setInputValue('') + setCategoryValues([]) + } + }, [dialogProps]) + + return ( + + + Set Chatflow Category Tags + + + +
+ {categoryValues.length > 0 && ( +
+ {categoryValues.map((category, index) => ( + handleDeleteTag(category)} + style={{ marginRight: 5, marginBottom: 5 }} + /> + ))} +
+ )} + + + Enter a tag and press enter to add it to the list. You can add as many tags as you want. + + +
+
+ + + + +
+ ) +} + +TagDialog.propTypes = { + isOpen: PropTypes.bool, + dialogProps: PropTypes.object, + onClose: PropTypes.func, + onSubmit: PropTypes.func +} + +export default TagDialog diff --git a/packages/ui/src/ui-component/dialog/ViewMessagesDialog.js b/packages/ui/src/ui-component/dialog/ViewMessagesDialog.js index 29a64155..cadd4abd 100644 --- a/packages/ui/src/ui-component/dialog/ViewMessagesDialog.js +++ b/packages/ui/src/ui-component/dialog/ViewMessagesDialog.js @@ -699,7 +699,10 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => { {message.sourceDocuments && (
{removeDuplicateURL(message).map((source, index) => { - const URL = isValidURL(source.metadata.source) + const URL = + source.metadata && source.metadata.source + ? isValidURL(source.metadata.source) + : undefined return ( ({ + [`&.${tableCellClasses.head}`]: { + backgroundColor: theme.palette.common.black, + color: theme.palette.common.white + }, + [`&.${tableCellClasses.body}`]: { + fontSize: 14 + } +})) + +const StyledTableRow = styled(TableRow)(({ theme }) => ({ + '&:nth-of-type(odd)': { + backgroundColor: theme.palette.action.hover + }, + // hide last border + '&:last-child td, &:last-child th': { + border: 0 + } +})) + +export const FlowListTable = ({ data, images, filterFunction, updateFlowsApi }) => { + const navigate = useNavigate() + const goToCanvas = (selectedChatflow) => { + navigate(`/canvas/${selectedChatflow.id}`) + } + + return ( + <> + + + + + + Name + + + Category + + + Nodes + + + Last Modified Date + + + Actions + + + + + {data.filter(filterFunction).map((row, index) => ( + + + + + + + +
+   + {row.category && + row.category + .split(';') + .map((tag, index) => ( + + ))} +
+
+ + {images[row.id] && ( +
+ {images[row.id].slice(0, images[row.id].length > 5 ? 5 : images[row.id].length).map((img) => ( +
+ +
+ ))} + {images[row.id].length > 5 && ( + + + {images[row.id].length - 5} More + + )} +
+ )} +
+ {moment(row.updatedDate).format('MMMM Do, YYYY')} + + + + + +
+ ))} +
+
+
+ + ) +} + +FlowListTable.propTypes = { + data: PropTypes.object, + images: PropTypes.array, + filterFunction: PropTypes.func, + updateFlowsApi: PropTypes.object +} diff --git a/packages/ui/src/ui-component/table/Table.js b/packages/ui/src/ui-component/table/Table.js index 2cf39182..1f0892bb 100644 --- a/packages/ui/src/ui-component/table/Table.js +++ b/packages/ui/src/ui-component/table/Table.js @@ -1,11 +1,11 @@ import PropTypes from 'prop-types' import { TableContainer, Table, TableHead, TableCell, TableRow, TableBody, Paper } from '@mui/material' -export const TableViewOnly = ({ columns, rows }) => { +export const TableViewOnly = ({ columns, rows, sx }) => { return ( <> - +
{columns.map((col, index) => ( @@ -16,11 +16,9 @@ export const TableViewOnly = ({ columns, rows }) => { {rows.map((row, index) => ( - {Object.keys(row) - .slice(-3) - .map((key, index) => ( - {row[key]} - ))} + {Object.keys(row).map((key, index) => ( + {row[key]} + ))} ))} @@ -32,5 +30,6 @@ export const TableViewOnly = ({ columns, rows }) => { TableViewOnly.propTypes = { rows: PropTypes.array, - columns: PropTypes.array + columns: PropTypes.array, + sx: PropTypes.object } diff --git a/packages/ui/src/ui-component/toolbar/Toolbar.js b/packages/ui/src/ui-component/toolbar/Toolbar.js new file mode 100644 index 00000000..f72ba339 --- /dev/null +++ b/packages/ui/src/ui-component/toolbar/Toolbar.js @@ -0,0 +1,24 @@ +import * as React from 'react' +import ViewListIcon from '@mui/icons-material/ViewList' +import ViewModuleIcon from '@mui/icons-material/ViewModule' +import ToggleButtonGroup from '@mui/material/ToggleButtonGroup' +import { StyledToggleButton } from '../button/StyledButton' + +export default function Toolbar() { + const [view, setView] = React.useState('list') + + const handleChange = (event, nextView) => { + setView(nextView) + } + + return ( + + + + + + + + + ) +} diff --git a/packages/ui/src/utils/genericHelper.js b/packages/ui/src/utils/genericHelper.js index 32331b14..b34d6c72 100644 --- a/packages/ui/src/utils/genericHelper.js +++ b/packages/ui/src/utils/genericHelper.js @@ -332,6 +332,57 @@ export const getAvailableNodesForVariable = (nodes, edges, target, targetHandle) return parentNodes } +export const getUpsertDetails = (nodes, edges) => { + const vsNodes = nodes.filter( + (node) => + node.data.category === 'Vector Stores' && !node.data.label.includes('Upsert') && !node.data.label.includes('Load Existing') + ) + const vsNodeIds = vsNodes.map((vs) => vs.data.id) + + const upsertNodes = [] + const seenVsNodeIds = [] + for (const edge of edges) { + if (vsNodeIds.includes(edge.source) || vsNodeIds.includes(edge.target)) { + const vsNode = vsNodes.find((node) => node.data.id === edge.source || node.data.id === edge.target) + if (!vsNode || seenVsNodeIds.includes(vsNode.data.id)) continue + seenVsNodeIds.push(vsNode.data.id) + + // Found Vector Store Node, proceed to find connected Document Loader node + let connectedDocs = [] + + if (vsNode.data.inputs.document) connectedDocs = [...new Set(vsNode.data.inputs.document)] + + if (connectedDocs.length) { + const innerNodes = [vsNode] + + if (vsNode.data.inputs.embeddings) { + const embeddingsId = vsNode.data.inputs.embeddings.replace(/{{|}}/g, '').split('.')[0] + innerNodes.push(nodes.find((node) => node.data.id === embeddingsId)) + } + + for (const doc of connectedDocs) { + const docId = doc.replace(/{{|}}/g, '').split('.')[0] + const docNode = nodes.find((node) => node.data.id === docId) + if (docNode) innerNodes.push(docNode) + + // Found Document Loader Node, proceed to find connected Text Splitter node + if (docNode && docNode.data.inputs.textSplitter) { + const textSplitterId = docNode.data.inputs.textSplitter.replace(/{{|}}/g, '').split('.')[0] + const textSplitterNode = nodes.find((node) => node.data.id === textSplitterId) + if (textSplitterNode) innerNodes.push(textSplitterNode) + } + } + + upsertNodes.push({ + vectorNode: vsNode, + nodes: innerNodes.reverse() + }) + } + } + } + return upsertNodes +} + export const rearrangeToolsOrdering = (newValues, sourceNodeId) => { // RequestsGet and RequestsPost have to be in order before other tools newValues.push(`{{${sourceNodeId}.data.instance}}`) @@ -423,10 +474,14 @@ export const removeDuplicateURL = (message) => { if (!message.sourceDocuments) return newSourceDocuments message.sourceDocuments.forEach((source) => { - if (isValidURL(source.metadata.source) && !visitedURLs.includes(source.metadata.source)) { - visitedURLs.push(source.metadata.source) - newSourceDocuments.push(source) - } else if (!isValidURL(source.metadata.source)) { + if (source.metadata && source.metadata.source) { + if (isValidURL(source.metadata.source) && !visitedURLs.includes(source.metadata.source)) { + visitedURLs.push(source.metadata.source) + newSourceDocuments.push(source) + } else if (!isValidURL(source.metadata.source)) { + newSourceDocuments.push(source) + } + } else { newSourceDocuments.push(source) } }) @@ -454,3 +509,106 @@ export const formatDataGridRows = (rows) => { return [] } } + +export const setLocalStorageChatflow = (chatflowid, chatId, chatHistory) => { + const chatDetails = localStorage.getItem(`${chatflowid}_INTERNAL`) + const obj = {} + if (chatId) obj.chatId = chatId + if (chatHistory) obj.chatHistory = chatHistory + + if (!chatDetails) { + localStorage.setItem(`${chatflowid}_INTERNAL`, JSON.stringify(obj)) + } else { + try { + const parsedChatDetails = JSON.parse(chatDetails) + localStorage.setItem(`${chatflowid}_INTERNAL`, JSON.stringify({ ...parsedChatDetails, ...obj })) + } catch (e) { + const chatId = chatDetails + obj.chatId = chatId + localStorage.setItem(`${chatflowid}_INTERNAL`, JSON.stringify(obj)) + } + } +} + +export const unshiftFiles = (configData) => { + const filesConfig = configData.find((config) => config.name === 'files') + if (filesConfig) { + configData = configData.filter((config) => config.name !== 'files') + configData.unshift(filesConfig) + } + return configData +} + +export const getConfigExamplesForJS = (configData, bodyType, isMultiple, stopNodeId) => { + let finalStr = '' + configData = unshiftFiles(configData) + const loop = Math.min(configData.length, 4) + for (let i = 0; i < loop; i += 1) { + const config = configData[i] + let exampleVal = `"example"` + if (config.type === 'string') exampleVal = `"example"` + else if (config.type === 'boolean') exampleVal = `true` + else if (config.type === 'number') exampleVal = `1` + else if (config.type === 'json') exampleVal = `{ "key": "val" }` + else if (config.name === 'files') exampleVal = `input.files[0]` + finalStr += bodyType === 'json' ? `\n "${config.name}": ${exampleVal},` : `formData.append("${config.name}", ${exampleVal})\n` + if (i === loop - 1 && bodyType !== 'json') + finalStr += !isMultiple + ? `` + : stopNodeId + ? `formData.append("stopNodeId", "${stopNodeId}")\n` + : `formData.append("question", "Hey, how are you?")\n` + } + return finalStr +} + +export const getConfigExamplesForPython = (configData, bodyType, isMultiple, stopNodeId) => { + let finalStr = '' + configData = unshiftFiles(configData) + const loop = Math.min(configData.length, 4) + for (let i = 0; i < loop; i += 1) { + const config = configData[i] + let exampleVal = `"example"` + if (config.type === 'string') exampleVal = `"example"` + else if (config.type === 'boolean') exampleVal = `true` + else if (config.type === 'number') exampleVal = `1` + else if (config.type === 'json') exampleVal = `{ "key": "val" }` + else if (config.name === 'files') continue + finalStr += bodyType === 'json' ? `\n "${config.name}": ${exampleVal},` : `\n "${config.name}": ${exampleVal},` + if (i === loop - 1 && bodyType !== 'json') + finalStr += !isMultiple + ? `\n` + : stopNodeId + ? `\n "stopNodeId": "${stopNodeId}"\n` + : `\n "question": "Hey, how are you?"\n` + } + return finalStr +} + +export const getConfigExamplesForCurl = (configData, bodyType, isMultiple, stopNodeId) => { + let finalStr = '' + configData = unshiftFiles(configData) + const loop = Math.min(configData.length, 4) + for (let i = 0; i < loop; i += 1) { + const config = configData[i] + let exampleVal = `example` + if (config.type === 'string') exampleVal = bodyType === 'json' ? `"example"` : `example` + else if (config.type === 'boolean') exampleVal = `true` + else if (config.type === 'number') exampleVal = `1` + else if (config.type === 'json') exampleVal = `{key:val}` + else if (config.name === 'files') + exampleVal = `@/home/user1/Desktop/example${config.type.includes(',') ? config.type.split(',')[0] : config.type}` + finalStr += bodyType === 'json' ? `"${config.name}": ${exampleVal}` : `\n -F "${config.name}=${exampleVal}"` + if (i === loop - 1) + finalStr += + bodyType === 'json' + ? ` }` + : !isMultiple + ? `` + : stopNodeId + ? ` \\\n -F "stopNodeId=${stopNodeId}"` + : ` \\\n -F "question=Hey, how are you?"` + else finalStr += bodyType === 'json' ? `, ` : ` \\` + } + return finalStr +} diff --git a/packages/ui/src/views/apikey/index.js b/packages/ui/src/views/apikey/index.js index a2b2e639..68113af5 100644 --- a/packages/ui/src/views/apikey/index.js +++ b/packages/ui/src/views/apikey/index.js @@ -6,19 +6,25 @@ import { enqueueSnackbar as enqueueSnackbarAction, closeSnackbar as closeSnackba import { Button, Box, + Chip, Stack, Table, TableBody, - TableCell, TableContainer, TableHead, TableRow, Paper, IconButton, Popover, - Typography + Collapse, + Typography, + Toolbar, + TextField, + InputAdornment, + ButtonGroup } from '@mui/material' -import { useTheme } from '@mui/material/styles' +import TableCell, { tableCellClasses } from '@mui/material/TableCell' +import { useTheme, styled } from '@mui/material/styles' // project imports import MainCard from 'ui-component/cards/MainCard' @@ -37,11 +43,146 @@ import useConfirm from 'hooks/useConfirm' import useNotifier from 'utils/useNotifier' // Icons -import { IconTrash, IconEdit, IconCopy, IconX, IconPlus, IconEye, IconEyeOff } from '@tabler/icons' +import { + IconTrash, + IconEdit, + IconCopy, + IconChevronsUp, + IconChevronsDown, + IconX, + IconSearch, + IconPlus, + IconEye, + IconEyeOff +} from '@tabler/icons' import APIEmptySVG from 'assets/images/api_empty.svg' +import * as PropTypes from 'prop-types' +import moment from 'moment/moment' // ==============================|| APIKey ||============================== // +const StyledTableCell = styled(TableCell)(({ theme }) => ({ + [`&.${tableCellClasses.head}`]: { + backgroundColor: theme.palette.action.hover + } +})) +const StyledTableRow = styled(TableRow)(() => ({ + // hide last border + '&:last-child td, &:last-child th': { + border: 0 + } +})) + +function APIKeyRow(props) { + const [open, setOpen] = useState(false) + return ( + <> + + {props.apiKey.keyName} + + {props.showApiKeys.includes(props.apiKey.apiKey) + ? props.apiKey.apiKey + : `${props.apiKey.apiKey.substring(0, 2)}${'•'.repeat(18)}${props.apiKey.apiKey.substring( + props.apiKey.apiKey.length - 5 + )}`} + + + + + {props.showApiKeys.includes(props.apiKey.apiKey) ? : } + + + + Copied! + + + + + {props.apiKey.chatFlows.length}{' '} + {props.apiKey.chatFlows.length > 0 && ( + setOpen(!open)}> + {props.apiKey.chatFlows.length > 0 && open ? : } + + )} + + {props.apiKey.createdAt} + + + + + + + + + + + + {open && ( + + + + +
+ + + + Chatflow Name + + Modified On + Category + + + + {props.apiKey.chatFlows.map((flow, index) => ( + + {flow.flowName} + {moment(flow.updatedDate).format('DD-MMM-YY')} + +   + {flow.category && + flow.category + .split(';') + .map((tag, index) => ( + + ))} + + + ))} + +
+ + + + + )} + + ) +} + +APIKeyRow.propTypes = { + apiKey: PropTypes.any, + showApiKeys: PropTypes.arrayOf(PropTypes.any), + onCopyClick: PropTypes.func, + onShowAPIClick: PropTypes.func, + open: PropTypes.bool, + anchorEl: PropTypes.any, + onClose: PropTypes.func, + theme: PropTypes.any, + onEditClick: PropTypes.func, + onDeleteClick: PropTypes.func +} const APIKey = () => { const theme = useTheme() const customization = useSelector((state) => state.customization) @@ -59,6 +200,14 @@ const APIKey = () => { const [showApiKeys, setShowApiKeys] = useState([]) const openPopOver = Boolean(anchorEl) + const [search, setSearch] = useState('') + const onSearchChange = (event) => { + setSearch(event.target.value) + } + function filterKeys(data) { + return data.keyName.toLowerCase().indexOf(search.toLowerCase()) > -1 + } + const { confirm } = useConfirm() const getAllAPIKeysApi = useApi(apiKeyApi.getAllAPIKeys) @@ -106,7 +255,10 @@ const APIKey = () => { const deleteKey = async (key) => { const confirmPayload = { title: `Delete`, - description: `Delete key ${key.keyName}?`, + description: + key.chatFlows.length === 0 + ? `Delete key [${key.keyName}] ? ` + : `Delete key [${key.keyName}] ?\n There are ${key.chatFlows.length} chatflows using this key.`, confirmButtonName: 'Delete', cancelButtonName: 'Cancel' } @@ -171,12 +323,53 @@ const APIKey = () => { <> -

API Keys 

- - - }> - Create Key - + + +

API Keys 

+ + + + ) + }} + /> + + + + } + > + Create Key + + + +
+
{apiKeys.length <= 0 && ( @@ -193,72 +386,33 @@ const APIKey = () => { Key Name API Key + Usage Created - {apiKeys.map((key, index) => ( - - - {key.keyName} - - - {showApiKeys.includes(key.apiKey) - ? key.apiKey - : `${key.apiKey.substring(0, 2)}${'•'.repeat(18)}${key.apiKey.substring( - key.apiKey.length - 5 - )}`} - { - navigator.clipboard.writeText(key.apiKey) - setAnchorEl(event.currentTarget) - setTimeout(() => { - handleClosePopOver() - }, 1500) - }} - > - - - onShowApiKeyClick(key.apiKey)}> - {showApiKeys.includes(key.apiKey) ? : } - - - - Copied! - - - - {key.createdAt} - - edit(key)}> - - - - - deleteKey(key)}> - - - - + {apiKeys.filter(filterKeys).map((key, index) => ( + { + navigator.clipboard.writeText(key.apiKey) + setAnchorEl(event.currentTarget) + setTimeout(() => { + handleClosePopOver() + }, 1500) + }} + onShowAPIClick={() => onShowApiKeyClick(key.apiKey)} + open={openPopOver} + anchorEl={anchorEl} + onClose={handleClosePopOver} + theme={theme} + onEditClick={() => edit(key)} + onDeleteClick={() => deleteKey(key)} + /> ))} diff --git a/packages/ui/src/views/canvas/AddNodes.js b/packages/ui/src/views/canvas/AddNodes.js index c6134cb9..7bf3e7ff 100644 --- a/packages/ui/src/views/canvas/AddNodes.js +++ b/packages/ui/src/views/canvas/AddNodes.js @@ -21,7 +21,8 @@ import { Paper, Popper, Stack, - Typography + Typography, + Chip } from '@mui/material' import ExpandMoreIcon from '@mui/icons-material/ExpandMore' @@ -56,6 +57,28 @@ const AddNodes = ({ nodesData, node }) => { const prevOpen = useRef(open) const ps = useRef() + // Temporary method to handle Deprecating Vector Store and New ones + const categorizeVectorStores = (nodes, accordianCategories, isFilter) => { + const obj = { ...nodes } + const vsNodes = obj['Vector Stores'] ?? [] + const deprecatingNodes = [] + const newNodes = [] + for (const vsNode of vsNodes) { + if (vsNode.badge === 'DEPRECATING') deprecatingNodes.push(vsNode) + else newNodes.push(vsNode) + } + delete obj['Vector Stores'] + if (deprecatingNodes.length) { + obj['Vector Stores;DEPRECATING'] = deprecatingNodes + accordianCategories['Vector Stores;DEPRECATING'] = isFilter ? true : false + } + if (newNodes.length) { + obj['Vector Stores;NEW'] = newNodes + accordianCategories['Vector Stores;NEW'] = isFilter ? true : false + } + setNodes(obj) + } + const scrollTop = () => { const curr = ps.current if (curr) { @@ -95,6 +118,7 @@ const AddNodes = ({ nodesData, node }) => { return r }, Object.create(null)) setNodes(result) + categorizeVectorStores(result, accordianCategories, isFilter) setCategoryExpanded(accordianCategories) } @@ -137,6 +161,8 @@ const AddNodes = ({ nodesData, node }) => { groupByCategory(nodesData) dispatch({ type: SET_COMPONENT_NODES, componentNodes: nodesData }) } + + // eslint-disable-next-line react-hooks/exhaustive-deps }, [nodesData, dispatch]) return ( @@ -249,69 +275,135 @@ const AddNodes = ({ nodesData, node }) => { > {Object.keys(nodes) .sort() - .map((category) => ( - - } - aria-controls={`nodes-accordian-${category}`} - id={`nodes-accordian-header-${category}`} + .map((category) => + category === 'Vector Stores' ? ( + <> + ) : ( + - {category} - - - {nodes[category].map((node, index) => ( -
onDragStart(event, node)} - draggable - > - } + aria-controls={`nodes-accordian-${category}`} + id={`nodes-accordian-header-${category}`} + > + {category.split(';').length > 1 ? ( +
- - -
- {category.split(';')[0]} +   + +
+ ) : ( + {category} + )} + + + {nodes[category].map((node, index) => ( +
onDragStart(event, node)} + draggable + > + + + +
-
-
- -
-
- {index === nodes[category].length - 1 ? null : } -
- ))} -
- - ))} + > + {node.name} +
+ + + {node.label} +   + {node.badge && ( + + )} +
+ } + secondary={node.description} + /> + + + {index === nodes[category].length - 1 ? null : } +
+ ))} + + + ) + )} diff --git a/packages/ui/src/views/canvas/CanvasNode.js b/packages/ui/src/views/canvas/CanvasNode.js index cabe2329..e52de640 100644 --- a/packages/ui/src/views/canvas/CanvasNode.js +++ b/packages/ui/src/views/canvas/CanvasNode.js @@ -83,8 +83,10 @@ const CanvasNode = ({ data }) => { if (componentNode) { if (!data.version) { setWarningMessage(nodeVersionEmptyMessage(componentNode.version)) - } else { - if (componentNode.version > data.version) setWarningMessage(nodeOutdatedMessage(data.version, componentNode.version)) + } else if (data.version && componentNode.version > data.version) { + setWarningMessage(nodeOutdatedMessage(data.version, componentNode.version)) + } else if (componentNode.badge === 'DEPRECATING') { + setWarningMessage('This node will be deprecated in the next release. Change to a new node tagged with NEW') } } }, [canvas.componentNodes, data.name, data.version]) @@ -207,9 +209,11 @@ const CanvasNode = ({ data }) => { {data.inputAnchors.map((inputAnchor, index) => ( ))} - {data.inputParams.map((inputParam, index) => ( - - ))} + {data.inputParams + .filter((inputParam) => !inputParam.hidden) + .map((inputParam, index) => ( + + ))} {data.inputParams.find((param) => param.additionalParams) && (
{ const [edges, setEdges, onEdgesChange] = useEdgesState() const [selectedNode, setSelectedNode] = useState(null) + const [isUpsertButtonEnabled, setIsUpsertButtonEnabled] = useState(false) const reactFlowWrapper = useRef(null) @@ -167,6 +169,7 @@ const Canvas = () => { if (isConfirmed) { try { await chatflowsApi.deleteChatflow(chatflow.id) + localStorage.removeItem(`${chatflow.id}_INTERNAL`) navigate(-1) } catch (error) { const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}` @@ -339,6 +342,12 @@ const Canvas = () => { dispatch({ type: SET_DIRTY }) } + const checkIfUpsertAvailable = (nodes, edges) => { + const upsertNodeDetails = getUpsertDetails(nodes, edges) + if (upsertNodeDetails.length) setIsUpsertButtonEnabled(true) + else setIsUpsertButtonEnabled(false) + } + // ==============================|| useEffect ||============================== // // Get specific chatflow successful @@ -409,7 +418,13 @@ const Canvas = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [testChatflowApi.error]) - useEffect(() => setChatflow(canvasDataStore.chatflow), [canvasDataStore.chatflow]) + useEffect(() => { + setChatflow(canvasDataStore.chatflow) + if (canvasDataStore.chatflow) { + const flowData = canvasDataStore.chatflow.flowData ? JSON.parse(canvasDataStore.chatflow.flowData) : [] + checkIfUpsertAvailable(flowData.nodes || [], flowData.edges || []) + } + }, [canvasDataStore.chatflow]) // Initialization useEffect(() => { @@ -524,6 +539,7 @@ const Canvas = () => { /> + {isUpsertButtonEnabled && }
diff --git a/packages/ui/src/views/chatflows/APICodeDialog.js b/packages/ui/src/views/chatflows/APICodeDialog.js index 49c718cc..34c2281f 100644 --- a/packages/ui/src/views/chatflows/APICodeDialog.js +++ b/packages/ui/src/views/chatflows/APICodeDialog.js @@ -23,6 +23,7 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore' import { Dropdown } from 'ui-component/dropdown/Dropdown' import ShareChatbot from './ShareChatbot' import EmbedChat from './EmbedChat' +import Configuration from './Configuration' // Const import { baseURL } from 'store/constant' @@ -35,6 +36,7 @@ import cURLSVG from 'assets/images/cURL.svg' import EmbedSVG from 'assets/images/embed.svg' import ShareChatbotSVG from 'assets/images/sharing.png' import settingsSVG from 'assets/images/settings.svg' +import { IconBulb } from '@tabler/icons' // API import apiKeyApi from 'api/apikey' @@ -46,8 +48,8 @@ import useApi from 'hooks/useApi' import { CheckboxInput } from 'ui-component/checkbox/Checkbox' import { TableViewOnly } from 'ui-component/table/Table' -import { IconBulb } from '@tabler/icons' -import Configuration from './Configuration' +// Helpers +import { unshiftFiles, getConfigExamplesForJS, getConfigExamplesForPython, getConfigExamplesForCurl } from 'utils/genericHelper' function TabPanel(props) { const { children, value, index, ...other } = props @@ -77,67 +79,6 @@ function a11yProps(index) { } } -const unshiftFiles = (configData) => { - const filesConfig = configData.find((config) => config.name === 'files') - if (filesConfig) { - configData = configData.filter((config) => config.name !== 'files') - configData.unshift(filesConfig) - } - return configData -} - -const getConfigExamplesForJS = (configData, bodyType) => { - let finalStr = '' - configData = unshiftFiles(configData) - const loop = Math.min(configData.length, 4) - for (let i = 0; i < loop; i += 1) { - const config = configData[i] - let exampleVal = `"example"` - if (config.type === 'string') exampleVal = `"example"` - else if (config.type === 'boolean') exampleVal = `true` - else if (config.type === 'number') exampleVal = `1` - else if (config.name === 'files') exampleVal = `input.files[0]` - finalStr += bodyType === 'json' ? `\n "${config.name}": ${exampleVal},` : `formData.append("${config.name}", ${exampleVal})\n` - if (i === loop - 1 && bodyType !== 'json') finalStr += `formData.append("question", "Hey, how are you?")\n` - } - return finalStr -} - -const getConfigExamplesForPython = (configData, bodyType) => { - let finalStr = '' - configData = unshiftFiles(configData) - const loop = Math.min(configData.length, 4) - for (let i = 0; i < loop; i += 1) { - const config = configData[i] - let exampleVal = `"example"` - if (config.type === 'string') exampleVal = `"example"` - else if (config.type === 'boolean') exampleVal = `true` - else if (config.type === 'number') exampleVal = `1` - else if (config.name === 'files') continue - finalStr += bodyType === 'json' ? `\n "${config.name}": ${exampleVal},` : `\n "${config.name}": ${exampleVal},` - if (i === loop - 1 && bodyType !== 'json') finalStr += `\n "question": "Hey, how are you?"\n` - } - return finalStr -} - -const getConfigExamplesForCurl = (configData, bodyType) => { - let finalStr = '' - configData = unshiftFiles(configData) - const loop = Math.min(configData.length, 4) - for (let i = 0; i < loop; i += 1) { - const config = configData[i] - let exampleVal = `example` - if (config.type === 'string') exampleVal = bodyType === 'json' ? `"example"` : `example` - else if (config.type === 'boolean') exampleVal = `true` - else if (config.type === 'number') exampleVal = `1` - else if (config.name === 'files') exampleVal = `@/home/user1/Desktop/example${config.type}` - finalStr += bodyType === 'json' ? `"${config.name}": ${exampleVal}` : `\n -F "${config.name}=${exampleVal}"` - if (i === loop - 1) finalStr += bodyType === 'json' ? ` }` : ` \\\n -F "question=Hey, how are you?"` - else finalStr += bodyType === 'json' ? `, ` : ` \\` - } - return finalStr -} - const APICodeDialog = ({ show, dialogProps, onCancel }) => { const portalElement = document.getElementById('portal') const navigate = useNavigate() @@ -334,7 +275,8 @@ query({"question": "Hey, how are you?"}).then((response) => { const getConfigCodeWithFormData = (codeLang, configData) => { if (codeLang === 'Python') { configData = unshiftFiles(configData) - const fileType = configData[0].type + let fileType = configData[0].type + if (fileType.includes(',')) fileType = fileType.split(',')[0] return `import requests API_URL = "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}" @@ -384,7 +326,8 @@ query(formData).then((response) => { const getConfigCodeWithFormDataWithAuth = (codeLang, configData) => { if (codeLang === 'Python') { configData = unshiftFiles(configData) - const fileType = configData[0].type + let fileType = configData[0].type + if (fileType.includes(',')) fileType = fileType.split(',')[0] return `import requests API_URL = "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}" @@ -700,7 +643,11 @@ formData.append("openAIApiKey[openAIEmbeddings_0]", "sk-my-openai-2nd-key")` { + // eslint-disable-next-line + const { node, nodeId, ...rest } = obj + return rest + })} columns={Object.keys(nodeConfig[nodeLabel][0]).slice(-3)} /> diff --git a/packages/ui/src/views/chatflows/index.js b/packages/ui/src/views/chatflows/index.js index 6712623e..3c4b8972 100644 --- a/packages/ui/src/views/chatflows/index.js +++ b/packages/ui/src/views/chatflows/index.js @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom' import { useSelector } from 'react-redux' // material-ui -import { Grid, Box, Stack } from '@mui/material' +import { Grid, Box, Stack, Toolbar, ToggleButton, ButtonGroup, InputAdornment, TextField } from '@mui/material' import { useTheme } from '@mui/material/styles' // project imports @@ -11,7 +11,6 @@ import MainCard from 'ui-component/cards/MainCard' import ItemCard from 'ui-component/cards/ItemCard' import { gridSpacing } from 'store/constant' import WorkflowEmptySVG from 'assets/images/workflow_empty.svg' -import { StyledButton } from 'ui-component/button/StyledButton' import LoginDialog from 'ui-component/dialog/LoginDialog' // API @@ -24,7 +23,11 @@ import useApi from 'hooks/useApi' import { baseURL } from 'store/constant' // icons -import { IconPlus } from '@tabler/icons' +import { IconPlus, IconSearch, IconLayoutGrid, IconList } from '@tabler/icons' +import * as React from 'react' +import ToggleButtonGroup from '@mui/material/ToggleButtonGroup' +import { FlowListTable } from '../../ui-component/table/FlowListTable' +import { StyledButton } from '../../ui-component/button/StyledButton' // ==============================|| CHATFLOWS ||============================== // @@ -35,10 +38,28 @@ const Chatflows = () => { const [isLoading, setLoading] = useState(true) const [images, setImages] = useState({}) + const [search, setSearch] = useState('') const [loginDialogOpen, setLoginDialogOpen] = useState(false) const [loginDialogProps, setLoginDialogProps] = useState({}) const getAllChatflowsApi = useApi(chatflowsApi.getAllChatflows) + const [view, setView] = React.useState(localStorage.getItem('flowDisplayStyle') || 'card') + + const handleChange = (event, nextView) => { + localStorage.setItem('flowDisplayStyle', nextView) + setView(nextView) + } + + const onSearchChange = (event) => { + setSearch(event.target.value) + } + + function filterFlows(data) { + return ( + data.name.toLowerCase().indexOf(search.toLowerCase()) > -1 || + (data.category && data.category.toLowerCase().indexOf(search.toLowerCase()) > -1) + ) + } const onLoginClick = (username, password) => { localStorage.setItem('username', username) @@ -102,26 +123,86 @@ const Chatflows = () => { return ( - -

Chatflows

- - - - }> - Add New - + + + +

Chatflows

+ + + + ) + }} + /> + + + + + + + + + + + + + + + }> + Add New + + + +
+
+ {!isLoading && (!view || view === 'card') && getAllChatflowsApi.data && ( + + {getAllChatflowsApi.data.filter(filterFlows).map((data, index) => ( + + goToCanvas(data)} data={data} images={images[data.id]} /> + + ))} -
+ )} + {!isLoading && view === 'list' && getAllChatflowsApi.data && ( + + )}
- - {!isLoading && - getAllChatflowsApi.data && - getAllChatflowsApi.data.map((data, index) => ( - - goToCanvas(data)} data={data} images={images[data.id]} /> - - ))} - + {!isLoading && (!getAllChatflowsApi.data || getAllChatflowsApi.data.length === 0) && ( diff --git a/packages/ui/src/views/chatmessage/ChatMessage.js b/packages/ui/src/views/chatmessage/ChatMessage.js index 7cfd0474..c610f944 100644 --- a/packages/ui/src/views/chatmessage/ChatMessage.js +++ b/packages/ui/src/views/chatmessage/ChatMessage.js @@ -32,7 +32,7 @@ import { baseURL, maxScroll } from 'store/constant' import robotPNG from 'assets/images/robot.png' import userPNG from 'assets/images/account.png' -import { isValidURL, removeDuplicateURL } from 'utils/genericHelper' +import { isValidURL, removeDuplicateURL, setLocalStorageChatflow } from 'utils/genericHelper' export const ChatMessage = ({ open, chatflowid, isDialog }) => { const theme = useTheme() @@ -128,10 +128,9 @@ export const ChatMessage = ({ open, chatflowid, isDialog }) => { if (response.data) { const data = response.data - if (!chatId) { - setChatId(data.chatId) - localStorage.setItem(`${chatflowid}_INTERNAL`, data.chatId) - } + + if (!chatId) setChatId(data.chatId) + if (!isChatFlowAvailableToStream) { let text = '' if (data.text) text = data.text @@ -149,7 +148,7 @@ export const ChatMessage = ({ open, chatflowid, isDialog }) => { } ]) } - + setLocalStorageChatflow(chatflowid, data.chatId, messages) setLoading(false) setUserInput('') setTimeout(() => { @@ -202,7 +201,6 @@ export const ChatMessage = ({ open, chatflowid, isDialog }) => { if (getChatmessageApi.data?.length) { const chatId = getChatmessageApi.data[0]?.chatId setChatId(chatId) - localStorage.setItem(`${chatflowid}_INTERNAL`, chatId) const loadedMessages = getChatmessageApi.data.map((message) => { const obj = { message: message.content, @@ -214,6 +212,7 @@ export const ChatMessage = ({ open, chatflowid, isDialog }) => { return obj }) setMessages((prevMessages) => [...prevMessages, ...loadedMessages]) + setLocalStorageChatflow(chatflowid, chatId, messages) } // eslint-disable-next-line react-hooks/exhaustive-deps @@ -379,7 +378,10 @@ export const ChatMessage = ({ open, chatflowid, isDialog }) => { {message.sourceDocuments && (
{removeDuplicateURL(message).map((source, index) => { - const URL = isValidURL(source.metadata.source) + const URL = + source.metadata && source.metadata.source + ? isValidURL(source.metadata.source) + : undefined return ( { if (isConfirmed) { try { - const chatId = localStorage.getItem(`${chatflowid}_INTERNAL`) - await chatmessageApi.deleteChatmessage(chatflowid, { chatId, chatType: 'INTERNAL' }) + const chatDetails = localStorage.getItem(`${chatflowid}_INTERNAL`) + if (!chatDetails) return + const objChatDetails = JSON.parse(chatDetails) + await chatmessageApi.deleteChatmessage(chatflowid, { chatId: objChatDetails.chatId, chatType: 'INTERNAL' }) localStorage.removeItem(`${chatflowid}_INTERNAL`) resetChatDialog() enqueueSnackbar({ diff --git a/packages/ui/src/views/credentials/index.js b/packages/ui/src/views/credentials/index.js index 9db990a7..31e35831 100644 --- a/packages/ui/src/views/credentials/index.js +++ b/packages/ui/src/views/credentials/index.js @@ -4,7 +4,23 @@ import { enqueueSnackbar as enqueueSnackbarAction, closeSnackbar as closeSnackba import moment from 'moment' // material-ui -import { Button, Box, Stack, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Paper, IconButton } from '@mui/material' +import { + Button, + Box, + Stack, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Paper, + IconButton, + Toolbar, + TextField, + InputAdornment, + ButtonGroup +} from '@mui/material' import { useTheme } from '@mui/material/styles' // project imports @@ -25,7 +41,7 @@ import useConfirm from 'hooks/useConfirm' import useNotifier from 'utils/useNotifier' // Icons -import { IconTrash, IconEdit, IconX, IconPlus } from '@tabler/icons' +import { IconTrash, IconEdit, IconX, IconPlus, IconSearch } from '@tabler/icons' import CredentialEmptySVG from 'assets/images/credential_empty.svg' // const @@ -56,6 +72,14 @@ const Credentials = () => { const getAllCredentialsApi = useApi(credentialsApi.getAllCredentials) const getAllComponentsCredentialsApi = useApi(credentialsApi.getAllComponentsCredentials) + const [search, setSearch] = useState('') + const onSearchChange = (event) => { + setSearch(event.target.value) + } + function filterCredentials(data) { + return data.credentialName.toLowerCase().indexOf(search.toLowerCase()) > -1 + } + const listCredential = () => { const dialogProp = { title: 'Add New Credential', @@ -168,17 +192,53 @@ const Credentials = () => { <> -

Credentials 

- - - } - > - Add Credential - + + +

Credentials 

+ + + + ) + }} + /> + + + + } + > + Add Credential + + + +
+
{credentials.length <= 0 && ( @@ -205,7 +265,7 @@ const Credentials = () => { - {credentials.map((credential, index) => ( + {credentials.filter(filterCredentials).map((credential, index) => ( + ) +} + +TabPanel.propTypes = { + children: PropTypes.node, + index: PropTypes.number.isRequired, + value: PropTypes.number.isRequired +} + +function a11yProps(index) { + return { + id: `attachment-tab-${index}`, + 'aria-controls': `attachment-tabpanel-${index}` + } +} + +const VectorStoreDialog = ({ show, dialogProps, onCancel }) => { + const portalElement = document.getElementById('portal') + const { reactFlowInstance } = useContext(flowContext) + const dispatch = useDispatch() + + useNotifier() + const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args)) + const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args)) + const getConfigApi = useApi(configApi.getConfig) + + const [nodes, setNodes] = useState([]) + const [loading, setLoading] = useState(false) + const [isFormDataRequired, setIsFormDataRequired] = useState({}) + const [nodeConfigExpanded, setNodeConfigExpanded] = useState({}) + const [nodeCheckboxExpanded, setCheckboxExpanded] = useState({}) + const [tabValue, setTabValue] = useState(0) + const [expandedVectorNodeId, setExpandedVectorNodeId] = useState('') + const [configData, setConfigData] = useState({}) + + const reformatConfigData = (configData, nodes) => { + return configData.filter((item1) => nodes.some((item2) => item1.nodeId === item2.id)) + } + + const getCode = (codeLang, vectorNodeId, isMultiple, configData) => { + if (codeLang === 'Python') { + return `import requests + +API_URL = "${baseURL}/api/v1/vector/upsert/${dialogProps.chatflowid}" + +def query(payload): + response = requests.post(API_URL, json=payload) + return response.json() + +output = query({ + ${isMultiple ? `"stopNodeId": "${vectorNodeId}",\n ` : ``}"overrideConfig": {${getConfigExamplesForPython( + configData, + 'json', + isMultiple, + vectorNodeId + )} + } +}) +` + } else if (codeLang === 'JavaScript') { + return `async function query(data) { + const response = await fetch( + "${baseURL}/api/v1/vector/upsert/${dialogProps.chatflowid}", + { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(data) + } + ); + const result = await response.json(); + return result; +} + +query({ + ${isMultiple ? `"stopNodeId": "${vectorNodeId}",\n ` : ``}"overrideConfig": {${getConfigExamplesForJS( + configData, + 'json', + isMultiple, + vectorNodeId + )} + } +}).then((response) => { + console.log(response); +}); +` + } else if (codeLang === 'cURL') { + return `curl ${baseURL}/api/v1/vector/upsert/${dialogProps.chatflowid} \\ + -X POST \\ + ${ + isMultiple + ? `-d '{"stopNodeId": "${vectorNodeId}", "overrideConfig": {${getConfigExamplesForCurl( + configData, + 'json', + isMultiple, + vectorNodeId + )}}' \\` + : `-d '{"overrideConfig": {${getConfigExamplesForCurl(configData, 'json', isMultiple, vectorNodeId)}}' \\` + } + -H "Content-Type: application/json"` + } + return '' + } + + const getCodeWithFormData = (codeLang, vectorNodeId, isMultiple, configData) => { + if (codeLang === 'Python') { + configData = unshiftFiles(configData) + let fileType = configData[0].type + if (fileType.includes(',')) fileType = fileType.split(',')[0] + return `import requests + +API_URL = "${baseURL}/api/v1/vector/upsert/${dialogProps.chatflowid}" + +# use form data to upload files +form_data = { + "files": ${`('example${fileType}', open('example${fileType}', 'rb'))`} +} +body_data = {${getConfigExamplesForPython(configData, 'formData', isMultiple, vectorNodeId)}} + +def query(form_data, body_data): + response = requests.post(API_URL, files=form_data, data=body_data) + return response.json() + +output = query(form_data, body_data) +` + } else if (codeLang === 'JavaScript') { + return `// use FormData to upload files +let formData = new FormData(); +${getConfigExamplesForJS(configData, 'formData', isMultiple, vectorNodeId)} +async function query(formData) { + const response = await fetch( + "${baseURL}/api/v1/vector/upsert/${dialogProps.chatflowid}", + { + method: "POST", + body: formData + } + ); + const result = await response.json(); + return result; +} + +query(formData).then((response) => { + console.log(response); +}); +` + } else if (codeLang === 'cURL') { + return `curl ${baseURL}/api/v1/vector/upsert/${dialogProps.chatflowid} \\ + -X POST \\${getConfigExamplesForCurl(configData, 'formData', isMultiple, vectorNodeId)} \\ + -H "Content-Type: multipart/form-data"` + } + return '' + } + + const getLang = (codeLang) => { + if (codeLang === 'Python') { + return 'python' + } else if (codeLang === 'JavaScript') { + return 'javascript' + } else if (codeLang === 'cURL') { + return 'bash' + } + return 'python' + } + + const getSVG = (codeLang) => { + if (codeLang === 'Python') { + return pythonSVG + } else if (codeLang === 'JavaScript') { + return javascriptSVG + } else if (codeLang === 'Embed') { + return EmbedSVG + } else if (codeLang === 'cURL') { + return cURLSVG + } else if (codeLang === 'Share Chatbot') { + return ShareChatbotSVG + } else if (codeLang === 'Configuration') { + return settingsSVG + } + return pythonSVG + } + + const handleAccordionChange = (nodeLabel) => (event, isExpanded) => { + const accordianNodes = { ...nodeConfigExpanded } + accordianNodes[nodeLabel] = isExpanded + setNodeConfigExpanded(accordianNodes) + } + + const onCheckBoxChanged = (vectorNodeId) => { + const checkboxNodes = { ...nodeCheckboxExpanded } + if (Object.keys(checkboxNodes).includes(vectorNodeId)) checkboxNodes[vectorNodeId] = !checkboxNodes[vectorNodeId] + else checkboxNodes[vectorNodeId] = true + + if (checkboxNodes[vectorNodeId] === true) getConfigApi.request(dialogProps.chatflowid) + setCheckboxExpanded(checkboxNodes) + setExpandedVectorNodeId(vectorNodeId) + + const newIsFormDataRequired = { ...isFormDataRequired } + newIsFormDataRequired[vectorNodeId] = false + setIsFormDataRequired(newIsFormDataRequired) + const newNodes = nodes.find((node) => node.vectorNode.data.id === vectorNodeId)?.nodes ?? [] + + for (const node of newNodes) { + if (node.data.inputParams.find((param) => param.type === 'file')) { + newIsFormDataRequired[vectorNodeId] = true + setIsFormDataRequired(newIsFormDataRequired) + break + } + } + } + + const onUpsertClicked = async (vectorStoreNode) => { + setLoading(true) + try { + await vectorstoreApi.upsertVectorStore(dialogProps.chatflowid, { stopNodeId: vectorStoreNode.data.id }) + enqueueSnackbar({ + message: 'Succesfully upserted vector store. You can start chatting now!', + options: { + key: new Date().getTime() + Math.random(), + variant: 'success', + action: (key) => ( + + ) + } + }) + setLoading(false) + } catch (error) { + const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}` + enqueueSnackbar({ + message: errorData, + options: { + key: new Date().getTime() + Math.random(), + variant: 'error', + persist: true, + action: (key) => ( + + ) + } + }) + setLoading(false) + } + } + + const getNodeDetail = (node) => { + const nodeDetails = [] + const inputKeys = Object.keys(node.data.inputs) + for (let i = 0; i < node.data.inputParams.length; i += 1) { + if (inputKeys.includes(node.data.inputParams[i].name)) { + nodeDetails.push({ + label: node.data.inputParams[i].label, + name: node.data.inputParams[i].name, + type: node.data.inputParams[i].type, + value: + node.data.inputParams[i].type === 'file' + ? getFileName(node.data.inputs[node.data.inputParams[i].name]) + : node.data.inputs[node.data.inputParams[i].name] ?? '' + }) + } + } + return nodeDetails + } + + useEffect(() => { + if (getConfigApi.data) { + const newConfigData = { ...configData } + newConfigData[expandedVectorNodeId] = reformatConfigData( + getConfigApi.data, + nodes.find((node) => node.vectorNode.data.id === expandedVectorNodeId)?.nodes ?? [] + ) + setConfigData(newConfigData) + } + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [getConfigApi.data]) + + useEffect(() => { + if (dialogProps && reactFlowInstance) { + const nodes = reactFlowInstance.getNodes() + const edges = reactFlowInstance.getEdges() + setNodes(getUpsertDetails(nodes, edges)) + } + + return () => { + setNodes([]) + setLoading(false) + setIsFormDataRequired({}) + setNodeConfigExpanded({}) + setCheckboxExpanded({}) + setTabValue(0) + setConfigData({}) + } + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [dialogProps]) + + useEffect(() => { + if (show) dispatch({ type: SHOW_CANVAS_DIALOG }) + else dispatch({ type: HIDE_CANVAS_DIALOG }) + return () => dispatch({ type: HIDE_CANVAS_DIALOG }) + }, [show, dispatch]) + + const component = show ? ( + + + {dialogProps.title} + + + + {nodes.length > 0 && + nodes.map((data, index) => { + return ( +
+ {data.nodes.length > 0 && + data.nodes.map((node, index) => { + return ( + + } + aria-controls={`nodes-accordian-${node.data.name}`} + id={`nodes-accordian-header-${node.data.name}`} + > +
+
+ {node.data.name} +
+ {node.data.label} +
+ + {node.data.id} + +
+
+
+ + + +
+ ) + })} + + onCheckBoxChanged(data.vectorNode.data.id)} + /> + {nodeCheckboxExpanded[data.vectorNode.data.id] && ( +
+ setTabValue(val)} aria-label='tabs'> + {['Python', 'JavaScript', 'cURL'].map((codeLang, index) => ( + + } + iconPosition='start' + key={index} + label={codeLang} + {...a11yProps(index)} + > + ))} + +
+ )} + {nodeCheckboxExpanded[data.vectorNode.data.id] && + isFormDataRequired[data.vectorNode.data.id] !== undefined && + configData[data.vectorNode.data.id] && + configData[data.vectorNode.data.id].length > 0 && ( + <> +
+ {['Python', 'JavaScript', 'cURL'].map((codeLang, index) => ( + + 1 ? true : false, + configData[data.vectorNode.data.id] + ) + : getCode( + codeLang, + data.vectorNode.data.id, + nodes.length > 1 ? true : false, + configData[data.vectorNode.data.id] + ) + } + language={getLang(codeLang)} + showLineNumbers={false} + wrapLines + /> + + ))} +
+ + )} +
+
+ {loading && } + {!loading && ( + + )} +
+
+ ) + })} +
+
+
+ ) : null + + return createPortal(component, portalElement) +} + +VectorStoreDialog.propTypes = { + show: PropTypes.bool, + dialogProps: PropTypes.object, + onCancel: PropTypes.func +} + +export default VectorStoreDialog diff --git a/packages/ui/src/views/vectorstore/VectorStorePopUp.js b/packages/ui/src/views/vectorstore/VectorStorePopUp.js new file mode 100644 index 00000000..2e23e69c --- /dev/null +++ b/packages/ui/src/views/vectorstore/VectorStorePopUp.js @@ -0,0 +1,114 @@ +import { useState, useRef, useEffect } from 'react' +import { useDispatch } from 'react-redux' +import PropTypes from 'prop-types' + +import { Button } from '@mui/material' +import { IconDatabaseImport, IconX } from '@tabler/icons' + +// project import +import { StyledFab } from 'ui-component/button/StyledFab' +import VectorStoreDialog from './VectorStoreDialog' + +// api +import vectorstoreApi from 'api/vectorstore' + +// Hooks +import useNotifier from 'utils/useNotifier' + +// Const +import { enqueueSnackbar as enqueueSnackbarAction, closeSnackbar as closeSnackbarAction } from 'store/actions' + +export const VectorStorePopUp = ({ chatflowid }) => { + const dispatch = useDispatch() + + useNotifier() + const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args)) + const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args)) + + const [open, setOpen] = useState(false) + const [showExpandDialog, setShowExpandDialog] = useState(false) + const [expandDialogProps, setExpandDialogProps] = useState({}) + + const anchorRef = useRef(null) + const prevOpen = useRef(open) + + const handleToggle = () => { + setOpen((prevopen) => !prevopen) + const props = { + open: true, + title: 'Upsert Vector Store', + chatflowid + } + setExpandDialogProps(props) + setShowExpandDialog(true) + } + + const onUpsert = async () => { + try { + await vectorstoreApi.upsertVectorStore(chatflowid, {}) + enqueueSnackbar({ + message: 'Succesfully upserted vector store', + options: { + key: new Date().getTime() + Math.random(), + variant: 'success', + action: (key) => ( + + ) + } + }) + } catch (error) { + const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}` + enqueueSnackbar({ + message: errorData, + options: { + key: new Date().getTime() + Math.random(), + variant: 'error', + persist: true, + action: (key) => ( + + ) + } + }) + } + } + + useEffect(() => { + if (prevOpen.current === true && open === false) { + anchorRef.current.focus() + } + prevOpen.current = open + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [open, chatflowid]) + + return ( + <> + + {open ? : } + + { + setShowExpandDialog(false) + setOpen((prevopen) => !prevopen) + }} + > + + ) +} + +VectorStorePopUp.propTypes = { chatflowid: PropTypes.string }