mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
- update LangchainJS version
- add types & interfaces - small ui bug fix - update marketplace files
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutor, AgentExecutor } from 'langchain/agents'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { BaseChatMemory } from 'langchain/memory'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class ConversationalAgent_Agents implements INode {
|
||||
label: string
|
||||
@@ -17,6 +22,7 @@ class ConversationalAgent_Agents implements INode {
|
||||
this.category = 'Agents'
|
||||
this.icon = 'agent.svg'
|
||||
this.description = 'Conversational agent for a chat model. It will utilize chat specific prompts'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Allowed Tools',
|
||||
@@ -37,16 +43,10 @@ class ConversationalAgent_Agents implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['AgentExecutor']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { initializeAgentExecutor } = await import('langchain/agents')
|
||||
|
||||
const model = nodeData.inputs?.model
|
||||
const tools = nodeData.inputs?.tools
|
||||
const memory = nodeData.inputs?.memory
|
||||
const model = nodeData.inputs?.model as BaseChatModel
|
||||
const tools = nodeData.inputs?.tools as Tool[]
|
||||
const memory = nodeData.inputs?.memory as BaseChatMemory
|
||||
|
||||
const executor = await initializeAgentExecutor(tools, model, 'chat-conversational-react-description', true)
|
||||
executor.memory = memory
|
||||
@@ -54,7 +54,7 @@ class ConversationalAgent_Agents implements INode {
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string): Promise<string> {
|
||||
const executor = nodeData.instance
|
||||
const executor = nodeData.instance as AgentExecutor
|
||||
const result = await executor.call({ input })
|
||||
|
||||
return result?.output
|
||||
|
||||
+12
-14
@@ -1,6 +1,10 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutor, AgentExecutor } from 'langchain/agents'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class MRLKAgentChat_Agents implements INode {
|
||||
class MRKLAgentChat_Agents implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
@@ -11,12 +15,13 @@ class MRLKAgentChat_Agents implements INode {
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'MRLK Agent for Chat Models'
|
||||
this.name = 'mrlkAgentChat'
|
||||
this.label = 'MRKL Agent for Chat Models'
|
||||
this.name = 'mrklAgentChat'
|
||||
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.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Allowed Tools',
|
||||
@@ -32,27 +37,20 @@ class MRLKAgentChat_Agents implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['AgentExecutor']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { initializeAgentExecutor } = await import('langchain/agents')
|
||||
|
||||
const model = nodeData.inputs?.model
|
||||
const tools = nodeData.inputs?.tools
|
||||
const model = nodeData.inputs?.model as BaseChatModel
|
||||
const tools = nodeData.inputs?.tools as Tool[]
|
||||
|
||||
const executor = await initializeAgentExecutor(tools, model, 'chat-zero-shot-react-description', true)
|
||||
|
||||
return executor
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string): Promise<string> {
|
||||
const executor = nodeData.instance
|
||||
const executor = nodeData.instance as AgentExecutor
|
||||
const result = await executor.call({ input })
|
||||
|
||||
return result?.output
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: MRLKAgentChat_Agents }
|
||||
module.exports = { nodeClass: MRKLAgentChat_Agents }
|
||||
|
Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 650 B |
+13
-15
@@ -1,6 +1,10 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutor, AgentExecutor } from 'langchain/agents'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { BaseLLM } from 'langchain/llms/base'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class MRLKAgentLLM_Agents implements INode {
|
||||
class MRKLAgentLLM_Agents implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
@@ -11,12 +15,13 @@ class MRLKAgentLLM_Agents implements INode {
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'MRLK Agent for LLMs'
|
||||
this.name = 'mrlkAgentLLM'
|
||||
this.label = 'MRKL Agent for LLMs'
|
||||
this.name = 'mrklAgentLLM'
|
||||
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.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Allowed Tools',
|
||||
@@ -27,32 +32,25 @@ class MRLKAgentLLM_Agents implements INode {
|
||||
{
|
||||
label: 'LLM Model',
|
||||
name: 'model',
|
||||
type: 'BaseLanguageModel'
|
||||
type: 'BaseLLM'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['AgentExecutor']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { initializeAgentExecutor } = await import('langchain/agents')
|
||||
|
||||
const model = nodeData.inputs?.model
|
||||
const tools = nodeData.inputs?.tools
|
||||
const model = nodeData.inputs?.model as BaseLLM
|
||||
const tools = nodeData.inputs?.tools as Tool[]
|
||||
|
||||
const executor = await initializeAgentExecutor(tools, model, 'zero-shot-react-description', true)
|
||||
|
||||
return executor
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string): Promise<string> {
|
||||
const executor = nodeData.instance
|
||||
const executor = nodeData.instance as AgentExecutor
|
||||
const result = await executor.call({ input })
|
||||
|
||||
return result?.output
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: MRLKAgentLLM_Agents }
|
||||
module.exports = { nodeClass: MRKLAgentLLM_Agents }
|
||||
|
Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 650 B |
+8
-11
@@ -1,5 +1,8 @@
|
||||
import { ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ConversationalRetrievalQAChain } from 'langchain/chains'
|
||||
import { BaseLLM } from 'langchain/llms/base'
|
||||
import { BaseRetriever } from 'langchain/schema'
|
||||
|
||||
class ConversationalRetrievalQAChain_Chains implements INode {
|
||||
label: string
|
||||
@@ -18,11 +21,12 @@ class ConversationalRetrievalQAChain_Chains implements INode {
|
||||
this.icon = 'chain.svg'
|
||||
this.category = 'Chains'
|
||||
this.description = 'Document QA - built on RetrievalQAChain to provide a chat history component'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(ConversationalRetrievalQAChain)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'LLM',
|
||||
name: 'llm',
|
||||
type: 'BaseLanguageModel'
|
||||
type: 'BaseLLM'
|
||||
},
|
||||
{
|
||||
label: 'Vector Store Retriever',
|
||||
@@ -32,23 +36,16 @@ class ConversationalRetrievalQAChain_Chains implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { ConversationalRetrievalQAChain } = await import('langchain/chains')
|
||||
return getBaseClasses(ConversationalRetrievalQAChain)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { ConversationalRetrievalQAChain } = await import('langchain/chains')
|
||||
|
||||
const llm = nodeData.inputs?.llm
|
||||
const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever
|
||||
const llm = nodeData.inputs?.llm as BaseLLM
|
||||
const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever as BaseRetriever
|
||||
|
||||
const chain = ConversationalRetrievalQAChain.fromLLM(llm, vectorStoreRetriever)
|
||||
return chain
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string> {
|
||||
const chain = nodeData.instance
|
||||
const chain = nodeData.instance as ConversationalRetrievalQAChain
|
||||
let chatHistory = ''
|
||||
|
||||
if (options && options.chatHistory) {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { BasePromptTemplate } from 'langchain/prompts'
|
||||
|
||||
class LLMChain_Chains implements INode {
|
||||
label: string
|
||||
@@ -18,10 +21,11 @@ class LLMChain_Chains implements INode {
|
||||
this.icon = 'chain.svg'
|
||||
this.category = 'Chains'
|
||||
this.description = 'Chain to run queries against LLMs'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(LLMChain)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'LLM',
|
||||
name: 'llm',
|
||||
label: 'Language Model',
|
||||
name: 'model',
|
||||
type: 'BaseLanguageModel'
|
||||
},
|
||||
{
|
||||
@@ -43,24 +47,17 @@ class LLMChain_Chains implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { LLMChain } = await import('langchain/chains')
|
||||
return getBaseClasses(LLMChain)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { LLMChain } = await import('langchain/chains')
|
||||
const model = nodeData.inputs?.model as BaseLanguageModel
|
||||
const prompt = nodeData.inputs?.prompt as BasePromptTemplate
|
||||
|
||||
const llm = nodeData.inputs?.llm
|
||||
const prompt = nodeData.inputs?.prompt
|
||||
|
||||
const chain = new LLMChain({ llm, prompt })
|
||||
const chain = new LLMChain({ llm: model, prompt })
|
||||
return chain
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string): Promise<string> {
|
||||
const inputVariables = nodeData.instance.prompt.inputVariables // ["product"]
|
||||
const chain = nodeData.instance
|
||||
const inputVariables = nodeData.instance.prompt.inputVariables as string[] // ["product"]
|
||||
const chain = nodeData.instance as LLMChain
|
||||
|
||||
if (inputVariables.length === 1) {
|
||||
const res = await chain.run(input)
|
||||
@@ -71,7 +68,7 @@ class LLMChain_Chains implements INode {
|
||||
|
||||
const promptValues = JSON.parse(promptValuesStr.replace(/\s/g, ''))
|
||||
|
||||
let seen = []
|
||||
let seen: string[] = []
|
||||
|
||||
for (const variable of inputVariables) {
|
||||
seen.push(variable)
|
||||
@@ -81,13 +78,17 @@ class LLMChain_Chains implements INode {
|
||||
}
|
||||
|
||||
if (seen.length === 1) {
|
||||
const lastValue = seen.pop()
|
||||
if (!lastValue) throw new Error('Please provide Prompt Values')
|
||||
const options = {
|
||||
...promptValues,
|
||||
[seen.pop()]: input
|
||||
[lastValue]: input
|
||||
}
|
||||
const res = await chain.call(options)
|
||||
return res?.text
|
||||
} else throw new Error('Please provide Prompt Values')
|
||||
} else {
|
||||
throw new Error('Please provide Prompt Values')
|
||||
}
|
||||
} else {
|
||||
const res = await chain.run(input)
|
||||
return res
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { RetrievalQAChain } from 'langchain/chains'
|
||||
import { BaseLLM } from 'langchain/llms/base'
|
||||
import { BaseRetriever } from 'langchain/schema'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class RetrievalQAChain_Chains implements INode {
|
||||
label: string
|
||||
@@ -17,11 +21,12 @@ class RetrievalQAChain_Chains implements INode {
|
||||
this.icon = 'chain.svg'
|
||||
this.category = 'Chains'
|
||||
this.description = 'QA chain to answer a question based on the retrieved documents'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(RetrievalQAChain)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'LLM',
|
||||
name: 'llm',
|
||||
type: 'BaseLanguageModel'
|
||||
type: 'BaseLLM'
|
||||
},
|
||||
{
|
||||
label: 'Vector Store Retriever',
|
||||
@@ -31,21 +36,16 @@ class RetrievalQAChain_Chains implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['BaseChain']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { RetrievalQAChain } = await import('langchain/chains')
|
||||
const llm = nodeData.inputs?.llm
|
||||
const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever
|
||||
const llm = nodeData.inputs?.llm as BaseLLM
|
||||
const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever as BaseRetriever
|
||||
|
||||
const chain = RetrievalQAChain.fromLLM(llm, vectorStoreRetriever)
|
||||
return chain
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string): Promise<string> {
|
||||
const chain = nodeData.instance
|
||||
const chain = nodeData.instance as RetrievalQAChain
|
||||
const obj = {
|
||||
query: input
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ChatOpenAI } from 'langchain/chat_models/openai'
|
||||
|
||||
class ChatOpenAI_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -18,6 +19,7 @@ class ChatOpenAI_ChatModels implements INode {
|
||||
this.icon = 'openai.png'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Wrapper around OpenAI large language models that use the Chat endpoint'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(ChatOpenAI)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'OpenAI Api Key',
|
||||
@@ -29,6 +31,18 @@ class ChatOpenAI_ChatModels implements INode {
|
||||
name: 'modelName',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
label: 'gpt-4',
|
||||
name: 'gpt-4'
|
||||
},
|
||||
{
|
||||
label: 'gpt-4-0314',
|
||||
name: 'gpt-4-0314'
|
||||
},
|
||||
{
|
||||
label: 'gpt-4-32k-0314',
|
||||
name: 'gpt-4-32k-0314'
|
||||
},
|
||||
{
|
||||
label: 'gpt-3.5-turbo',
|
||||
name: 'gpt-3.5-turbo'
|
||||
@@ -51,14 +65,7 @@ class ChatOpenAI_ChatModels implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { ChatOpenAI } = await import('langchain/chat_models')
|
||||
return getBaseClasses(ChatOpenAI)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { ChatOpenAI } = await import('langchain/chat_models')
|
||||
|
||||
const temperature = nodeData.inputs?.temperature as string
|
||||
const modelName = nodeData.inputs?.modelName as string
|
||||
const openAIApiKey = nodeData.inputs?.openAIApiKey as string
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { GithubRepoLoader, GithubRepoLoaderParams } from 'langchain/document_loaders/web/github'
|
||||
|
||||
class Github_DocumentLoaders implements INode {
|
||||
label: string
|
||||
@@ -13,10 +15,11 @@ class Github_DocumentLoaders implements INode {
|
||||
constructor() {
|
||||
this.label = 'Github'
|
||||
this.name = 'github'
|
||||
this.type = 'Github'
|
||||
this.type = 'Document'
|
||||
this.icon = 'github.png'
|
||||
this.category = 'Document Loaders'
|
||||
this.description = `Load data from a GitHub repository`
|
||||
this.baseClasses = [this.type]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Repo Link',
|
||||
@@ -46,23 +49,17 @@ class Github_DocumentLoaders implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['Document']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { GithubRepoLoader } = await import('langchain/document_loaders')
|
||||
|
||||
const repoLink = nodeData.inputs?.repoLink as string
|
||||
const branch = nodeData.inputs?.branch as string
|
||||
const accessToken = nodeData.inputs?.accessToken as string
|
||||
const textSplitter = nodeData.inputs?.textSplitter
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
|
||||
const options = {
|
||||
const options: GithubRepoLoaderParams = {
|
||||
branch,
|
||||
recursive: false,
|
||||
unknown: 'warn'
|
||||
} as any
|
||||
}
|
||||
|
||||
if (accessToken) options.accessToken = accessToken
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { PDFLoader } from 'langchain/document_loaders/fs/pdf'
|
||||
|
||||
class Pdf_DocumentLoaders implements INode {
|
||||
label: string
|
||||
@@ -13,10 +15,11 @@ class Pdf_DocumentLoaders implements INode {
|
||||
constructor() {
|
||||
this.label = 'Pdf File'
|
||||
this.name = 'pdfFile'
|
||||
this.type = 'PDF'
|
||||
this.type = 'Document'
|
||||
this.icon = 'pdf.svg'
|
||||
this.category = 'Document Loaders'
|
||||
this.description = `Load data from PDF files`
|
||||
this.baseClasses = [this.type]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Pdf File',
|
||||
@@ -49,14 +52,8 @@ class Pdf_DocumentLoaders implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['Document']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { PDFLoader } = await import('langchain/document_loaders')
|
||||
|
||||
const textSplitter = nodeData.inputs?.textSplitter
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
const pdfFileBase64 = nodeData.inputs?.pdfFile as string
|
||||
const usage = nodeData.inputs?.usage as string
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { TextLoader } from 'langchain/document_loaders/fs/text'
|
||||
|
||||
class Text_DocumentLoaders implements INode {
|
||||
label: string
|
||||
@@ -13,10 +15,11 @@ class Text_DocumentLoaders implements INode {
|
||||
constructor() {
|
||||
this.label = 'Text File'
|
||||
this.name = 'textFile'
|
||||
this.type = 'Text'
|
||||
this.type = 'Document'
|
||||
this.icon = 'textFile.svg'
|
||||
this.category = 'Document Loaders'
|
||||
this.description = `Load data from text files`
|
||||
this.baseClasses = [this.type]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Txt File',
|
||||
@@ -33,13 +36,8 @@ class Text_DocumentLoaders implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['Document']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { TextLoader } = await import('langchain/document_loaders')
|
||||
const textSplitter = nodeData.inputs?.textSplitter
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
const txtFileBase64 = nodeData.inputs?.txtFile as string
|
||||
const splitDataURI = txtFileBase64.split(',')
|
||||
splitDataURI.pop()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { OpenAIEmbeddings } from 'langchain/embeddings/openai'
|
||||
|
||||
class OpenAIEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
@@ -18,6 +19,7 @@ class OpenAIEmbedding_Embeddings implements INode {
|
||||
this.icon = 'openai.png'
|
||||
this.category = 'Embeddings'
|
||||
this.description = 'OpenAI API to generate embeddings for a given text'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(OpenAIEmbeddings)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'OpenAI Api Key',
|
||||
@@ -27,13 +29,7 @@ class OpenAIEmbedding_Embeddings implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { OpenAIEmbeddings } = await import('langchain/embeddings')
|
||||
return getBaseClasses(OpenAIEmbeddings)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { OpenAIEmbeddings } = await import('langchain/embeddings')
|
||||
const openAIApiKey = nodeData.inputs?.openAIApiKey as string
|
||||
|
||||
const model = new OpenAIEmbeddings({ openAIApiKey })
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { HuggingFaceInference } from 'langchain/llms/hf'
|
||||
|
||||
class HuggingFaceInference_LLMs implements INode {
|
||||
label: string
|
||||
@@ -17,7 +18,8 @@ class HuggingFaceInference_LLMs implements INode {
|
||||
this.type = 'HuggingFaceInference'
|
||||
this.icon = 'huggingface.png'
|
||||
this.category = 'LLMs'
|
||||
this.description = 'Wrapper around OpenAI large language models'
|
||||
this.description = 'Wrapper around HuggingFace large language models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(HuggingFaceInference)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Model',
|
||||
@@ -42,14 +44,7 @@ class HuggingFaceInference_LLMs implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { HuggingFaceInference } = await import('langchain/llms')
|
||||
return getBaseClasses(HuggingFaceInference)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { HuggingFaceInference } = await import('langchain/llms')
|
||||
|
||||
const temperature = nodeData.inputs?.temperature as string
|
||||
const model = nodeData.inputs?.model as string
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { OpenAI } from 'langchain/llms/openai'
|
||||
|
||||
class OpenAI_LLMs implements INode {
|
||||
label: string
|
||||
@@ -18,6 +19,7 @@ class OpenAI_LLMs implements INode {
|
||||
this.icon = 'openai.png'
|
||||
this.category = 'LLMs'
|
||||
this.description = 'Wrapper around OpenAI large language models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(OpenAI)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'OpenAI Api Key',
|
||||
@@ -59,14 +61,7 @@ class OpenAI_LLMs implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { OpenAI } = await import('langchain/llms')
|
||||
return getBaseClasses(OpenAI)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { OpenAI } = await import('langchain/llms')
|
||||
|
||||
const temperature = nodeData.inputs?.temperature as string
|
||||
const modelName = nodeData.inputs?.modelName as string
|
||||
const openAIApiKey = nodeData.inputs?.openAIApiKey as string
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { BufferMemory } from 'langchain/memory'
|
||||
|
||||
class BufferMemory_Memory implements INode {
|
||||
label: string
|
||||
@@ -17,7 +18,8 @@ class BufferMemory_Memory implements INode {
|
||||
this.type = 'BufferMemory'
|
||||
this.icon = 'memory.svg'
|
||||
this.category = 'Memory'
|
||||
this.description = 'Perform calculations on response'
|
||||
this.description = 'Remembers previous conversational back and forths directly'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(BufferMemory)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Memory Key',
|
||||
@@ -34,13 +36,7 @@ class BufferMemory_Memory implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { BufferMemory } = await import('langchain/memory')
|
||||
return getBaseClasses(BufferMemory)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { BufferMemory } = await import('langchain/memory')
|
||||
const memoryKey = nodeData.inputs?.memoryKey as string
|
||||
const inputKey = nodeData.inputs?.inputKey as string
|
||||
return new BufferMemory({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate } from 'langchain/prompts'
|
||||
|
||||
class ChatPromptTemplate_Prompts implements INode {
|
||||
label: string
|
||||
@@ -18,6 +19,7 @@ class ChatPromptTemplate_Prompts implements INode {
|
||||
this.icon = 'prompt.svg'
|
||||
this.category = 'Prompts'
|
||||
this.description = 'Schema to represent a chat prompt'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(ChatPromptTemplate)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'System Message',
|
||||
@@ -36,13 +38,7 @@ class ChatPromptTemplate_Prompts implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { ChatPromptTemplate } = await import('langchain/prompts')
|
||||
return getBaseClasses(ChatPromptTemplate)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate } = await import('langchain/prompts')
|
||||
const systemMessagePrompt = nodeData.inputs?.systemMessagePrompt as string
|
||||
const humanMessagePrompt = nodeData.inputs?.humanMessagePrompt as string
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getInputVariables } from '../../../src/utils'
|
||||
import { FewShotPromptTemplate, FewShotPromptTemplateInput, PromptTemplate } from 'langchain/prompts'
|
||||
import { Example } from 'langchain/schema'
|
||||
import { TemplateFormat } from 'langchain/dist/prompts/template'
|
||||
|
||||
class FewShotPromptTemplate_Prompts implements INode {
|
||||
label: string
|
||||
@@ -18,6 +21,7 @@ class FewShotPromptTemplate_Prompts implements INode {
|
||||
this.icon = 'prompt.svg'
|
||||
this.category = 'Prompts'
|
||||
this.description = 'Prompt template you can build with examples'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(FewShotPromptTemplate)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Examples',
|
||||
@@ -32,7 +36,7 @@ class FewShotPromptTemplate_Prompts implements INode {
|
||||
{
|
||||
label: 'Example Prompt',
|
||||
name: 'examplePrompt',
|
||||
type: 'BasePromptTemplate'
|
||||
type: 'PromptTemplate'
|
||||
},
|
||||
{
|
||||
label: 'Prefix',
|
||||
@@ -73,27 +77,19 @@ class FewShotPromptTemplate_Prompts implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { FewShotPromptTemplate } = await import('langchain/prompts')
|
||||
return getBaseClasses(FewShotPromptTemplate)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { FewShotPromptTemplate } = await import('langchain/prompts')
|
||||
|
||||
const examplesStr = nodeData.inputs?.examples as string
|
||||
|
||||
const prefix = nodeData.inputs?.prefix as string
|
||||
const suffix = nodeData.inputs?.suffix as string
|
||||
const exampleSeparator = nodeData.inputs?.exampleSeparator as string
|
||||
const templateFormat = nodeData.inputs?.templateFormat
|
||||
const examplePrompt = nodeData.inputs?.examplePrompt
|
||||
const templateFormat = nodeData.inputs?.templateFormat as TemplateFormat
|
||||
const examplePrompt = nodeData.inputs?.examplePrompt as PromptTemplate
|
||||
|
||||
const inputVariables = getInputVariables(suffix)
|
||||
const examples = JSON.parse(examplesStr.replace(/\s/g, ''))
|
||||
const examples: Example[] = JSON.parse(examplesStr.replace(/\s/g, ''))
|
||||
|
||||
try {
|
||||
const prompt = new FewShotPromptTemplate({
|
||||
const obj: FewShotPromptTemplateInput = {
|
||||
examples,
|
||||
examplePrompt,
|
||||
prefix,
|
||||
@@ -101,7 +97,8 @@ class FewShotPromptTemplate_Prompts implements INode {
|
||||
inputVariables,
|
||||
exampleSeparator,
|
||||
templateFormat
|
||||
})
|
||||
}
|
||||
const prompt = new FewShotPromptTemplate(obj)
|
||||
return prompt
|
||||
} catch (e) {
|
||||
throw new Error(e)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getInputVariables } from '../../../src/utils'
|
||||
import { PromptTemplate, PromptTemplateInput } from 'langchain/prompts'
|
||||
|
||||
class PromptTemplate_Prompts implements INode {
|
||||
label: string
|
||||
@@ -18,6 +19,7 @@ class PromptTemplate_Prompts implements INode {
|
||||
this.icon = 'prompt.svg'
|
||||
this.category = 'Prompts'
|
||||
this.description = 'Schema to represent a basic prompt for an LLM'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(PromptTemplate)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Template',
|
||||
@@ -29,19 +31,12 @@ class PromptTemplate_Prompts implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { PromptTemplate } = await import('langchain/prompts')
|
||||
return getBaseClasses(PromptTemplate)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { PromptTemplate } = await import('langchain/prompts')
|
||||
|
||||
const template = nodeData.inputs?.template as string
|
||||
const inputVariables = getInputVariables(template)
|
||||
|
||||
try {
|
||||
const options = {
|
||||
const options: PromptTemplateInput = {
|
||||
template,
|
||||
inputVariables
|
||||
}
|
||||
|
||||
+3
-7
@@ -1,5 +1,6 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { RecursiveCharacterTextSplitter, RecursiveCharacterTextSplitterParams } from 'langchain/text_splitter'
|
||||
|
||||
class RecursiveCharacterTextSplitter_TextSplitters implements INode {
|
||||
label: string
|
||||
@@ -18,6 +19,7 @@ class RecursiveCharacterTextSplitter_TextSplitters implements INode {
|
||||
this.icon = 'textsplitter.svg'
|
||||
this.category = 'Text Splitters'
|
||||
this.description = `Split documents recursively by different characters - starting with "\n\n", then "\n", then " "`
|
||||
this.baseClasses = [this.type, ...getBaseClasses(RecursiveCharacterTextSplitter)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Chunk Size',
|
||||
@@ -35,17 +37,11 @@ class RecursiveCharacterTextSplitter_TextSplitters implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { RecursiveCharacterTextSplitter } = await import('langchain/text_splitter')
|
||||
return getBaseClasses(RecursiveCharacterTextSplitter)
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { RecursiveCharacterTextSplitter } = await import('langchain/text_splitter')
|
||||
const chunkSize = nodeData.inputs?.chunkSize as string
|
||||
const chunkOverlap = nodeData.inputs?.chunkOverlap as string
|
||||
|
||||
const obj = {} as any
|
||||
const obj = {} as RecursiveCharacterTextSplitterParams
|
||||
|
||||
if (chunkSize) obj.chunkSize = parseInt(chunkSize, 10)
|
||||
if (chunkOverlap) obj.chunkOverlap = parseInt(chunkOverlap, 10)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { INode } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { Calculator } from 'langchain/tools/calculator'
|
||||
|
||||
class Calculator implements INode {
|
||||
class Calculator_Tools implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
@@ -17,17 +18,12 @@ class Calculator implements INode {
|
||||
this.icon = 'calculator.svg'
|
||||
this.category = 'Tools'
|
||||
this.description = 'Perform calculations on response'
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { Calculator } = await import('langchain/tools')
|
||||
return getBaseClasses(Calculator)
|
||||
this.baseClasses = [this.type, ...getBaseClasses(Calculator)]
|
||||
}
|
||||
|
||||
async init(): Promise<any> {
|
||||
const { Calculator } = await import('langchain/tools')
|
||||
return new Calculator()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: Calculator }
|
||||
module.exports = { nodeClass: Calculator_Tools }
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { INode } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { RequestsGetTool } from 'langchain/tools'
|
||||
|
||||
class RequestsGet_Tools implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Requests Get'
|
||||
this.name = 'requestsGet'
|
||||
this.type = 'RequestsGet'
|
||||
this.icon = 'requestsget.svg'
|
||||
this.category = 'Tools'
|
||||
this.description = 'Execute HTTP GET requests'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(RequestsGetTool)]
|
||||
}
|
||||
|
||||
async init(): Promise<any> {
|
||||
return new RequestsGetTool()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: RequestsGet_Tools }
|
||||
@@ -0,0 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-http-get" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M7 8h-2a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h2v-4h-1"></path>
|
||||
<path d="M14 8h-4v8h4"></path>
|
||||
<path d="M10 12h2.5"></path>
|
||||
<path d="M17 8h4"></path>
|
||||
<path d="M19 8v8"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 487 B |
@@ -0,0 +1,29 @@
|
||||
import { INode } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { RequestsPostTool } from 'langchain/tools'
|
||||
|
||||
class RequestsPost_Tools implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Requests Post'
|
||||
this.name = 'requestsPost'
|
||||
this.type = 'RequestsPost'
|
||||
this.icon = 'requestspost.svg'
|
||||
this.category = 'Tools'
|
||||
this.description = 'Execute HTTP POST requests'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(RequestsPostTool)]
|
||||
}
|
||||
|
||||
async init(): Promise<any> {
|
||||
return new RequestsPostTool()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: RequestsPost_Tools }
|
||||
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-http-post" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M3 12h2a2 2 0 1 0 0 -4h-2v8"></path>
|
||||
<path d="M12 8a2 2 0 0 1 2 2v4a2 2 0 1 1 -4 0v-4a2 2 0 0 1 2 -2z"></path>
|
||||
<path d="M17 15a1 1 0 0 0 1 1h2a1 1 0 0 0 1 -1v-2a1 1 0 0 0 -1 -1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 553 B |
@@ -1,7 +1,8 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { SerpAPI } from 'langchain/tools'
|
||||
|
||||
class SerpAPI implements INode {
|
||||
class SerpAPI_Tools implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
@@ -25,18 +26,13 @@ class SerpAPI implements INode {
|
||||
type: 'password'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
const { SerpAPI } = await import('langchain/tools')
|
||||
return getBaseClasses(SerpAPI)
|
||||
this.baseClasses = [this.type, ...getBaseClasses(SerpAPI)]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { SerpAPI } = await import('langchain/tools')
|
||||
const apiKey = nodeData.inputs?.apiKey as string
|
||||
return new SerpAPI(apiKey)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: SerpAPI }
|
||||
module.exports = { nodeClass: SerpAPI_Tools }
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { Chroma } from 'langchain/vectorstores/chroma'
|
||||
import { Embeddings } from 'langchain/embeddings/base'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class Chroma_Existing_VectorStores implements INode {
|
||||
label: string
|
||||
@@ -17,6 +20,7 @@ class Chroma_Existing_VectorStores implements INode {
|
||||
this.icon = 'chroma.svg'
|
||||
this.category = 'Vector Stores'
|
||||
this.description = 'Load existing index from Chroma (i.e: Document has been upserted)'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(Chroma)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Embeddings',
|
||||
@@ -31,15 +35,9 @@ class Chroma_Existing_VectorStores implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['BaseRetriever']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { Chroma } = await import('langchain/vectorstores')
|
||||
|
||||
const collectionName = nodeData.inputs?.collectionName as string
|
||||
const embeddings = nodeData.inputs?.embeddings
|
||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||
|
||||
const vectorStore = await Chroma.fromExistingCollection(embeddings, {
|
||||
collectionName
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { Chroma } from 'langchain/vectorstores/chroma'
|
||||
import { Embeddings } from 'langchain/embeddings/base'
|
||||
import { Document } from 'langchain/document'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class ChromaUpsert_VectorStores implements INode {
|
||||
label: string
|
||||
@@ -17,6 +21,7 @@ class ChromaUpsert_VectorStores implements INode {
|
||||
this.icon = 'chroma.svg'
|
||||
this.category = 'Vector Stores'
|
||||
this.description = 'Upsert documents to Chroma'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(Chroma)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Document',
|
||||
@@ -36,28 +41,20 @@ class ChromaUpsert_VectorStores implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['BaseRetriever']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { Chroma } = await import('langchain/vectorstores')
|
||||
const { Document } = await import('langchain/document')
|
||||
|
||||
const collectionName = nodeData.inputs?.collectionName as string
|
||||
const docs = nodeData.inputs?.document
|
||||
const embeddings = nodeData.inputs?.embeddings
|
||||
const docs = nodeData.inputs?.document as Document[]
|
||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||
|
||||
const finalDocs = []
|
||||
for (let i = 0; i < docs.length; i += 1) {
|
||||
finalDocs.push(new Document(docs[i]))
|
||||
}
|
||||
|
||||
const result = await Chroma.fromDocuments(finalDocs, embeddings, {
|
||||
const vectorStore = await Chroma.fromDocuments(finalDocs, embeddings, {
|
||||
collectionName
|
||||
})
|
||||
|
||||
const retriever = result.asRetriever()
|
||||
const retriever = vectorStore.asRetriever()
|
||||
return retriever
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { PineconeClient } from '@pinecone-database/pinecone'
|
||||
import { PineconeStore } from 'langchain/vectorstores/pinecone'
|
||||
import { Embeddings } from 'langchain/embeddings/base'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class Pinecone_Existing_VectorStores implements INode {
|
||||
label: string
|
||||
@@ -18,6 +21,7 @@ class Pinecone_Existing_VectorStores implements INode {
|
||||
this.icon = 'pinecone.png'
|
||||
this.category = 'Vector Stores'
|
||||
this.description = 'Load existing index from Pinecone (i.e: Document has been upserted)'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(PineconeStore)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Embeddings',
|
||||
@@ -42,17 +46,11 @@ class Pinecone_Existing_VectorStores implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['BaseRetriever']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { PineconeStore } = await import('langchain/vectorstores')
|
||||
|
||||
const pineconeApiKey = nodeData.inputs?.pineconeApiKey as string
|
||||
const pineconeEnv = nodeData.inputs?.pineconeEnv as string
|
||||
const index = nodeData.inputs?.pineconeIndex as string
|
||||
const embeddings = nodeData.inputs?.embeddings
|
||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||
|
||||
const client = new PineconeClient()
|
||||
await client.init({
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { PineconeClient } from '@pinecone-database/pinecone'
|
||||
import { PineconeStore } from 'langchain/vectorstores/pinecone'
|
||||
import { Embeddings } from 'langchain/embeddings/base'
|
||||
import { Document } from 'langchain/document'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class PineconeUpsert_VectorStores implements INode {
|
||||
label: string
|
||||
@@ -18,6 +22,7 @@ class PineconeUpsert_VectorStores implements INode {
|
||||
this.icon = 'pinecone.png'
|
||||
this.category = 'Vector Stores'
|
||||
this.description = 'Upsert documents to Pinecone'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(PineconeStore)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Document',
|
||||
@@ -47,19 +52,12 @@ class PineconeUpsert_VectorStores implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['BaseRetriever']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { PineconeStore } = await import('langchain/vectorstores')
|
||||
const { Document } = await import('langchain/document')
|
||||
|
||||
const pineconeApiKey = nodeData.inputs?.pineconeApiKey as string
|
||||
const pineconeEnv = nodeData.inputs?.pineconeEnv as string
|
||||
const index = nodeData.inputs?.pineconeIndex as string
|
||||
const docs = nodeData.inputs?.document
|
||||
const embeddings = nodeData.inputs?.embeddings
|
||||
const docs = nodeData.inputs?.document as Document[]
|
||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||
|
||||
const client = new PineconeClient()
|
||||
await client.init({
|
||||
@@ -74,11 +72,10 @@ class PineconeUpsert_VectorStores implements INode {
|
||||
finalDocs.push(new Document(docs[i]))
|
||||
}
|
||||
|
||||
const result = await PineconeStore.fromDocuments(finalDocs, embeddings, {
|
||||
const vectorStore = await PineconeStore.fromDocuments(finalDocs, embeddings, {
|
||||
pineconeIndex
|
||||
})
|
||||
|
||||
const retriever = result.asRetriever()
|
||||
const retriever = vectorStore.asRetriever()
|
||||
return retriever
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"dotenv": "^16.0.0",
|
||||
"express": "^4.17.3",
|
||||
"form-data": "^4.0.0",
|
||||
"langchain": "^0.0.44",
|
||||
"langchain": "^0.0.53",
|
||||
"moment": "^2.29.3",
|
||||
"node-fetch": "2",
|
||||
"pdfjs-dist": "^3.5.141",
|
||||
|
||||
@@ -75,7 +75,6 @@ export interface INodeProperties {
|
||||
|
||||
export interface INode extends INodeProperties {
|
||||
inputs?: INodeParams[]
|
||||
getBaseClasses?(): Promise<string[]>
|
||||
getInstance?(nodeData: INodeData): Promise<string>
|
||||
run?(nodeData: INodeData, input: string, options?: ICommonObject): Promise<string>
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
"strictPropertyInitialization": false,
|
||||
"useUnknownInCatchVariables": false,
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node16"
|
||||
"module": "commonjs"
|
||||
},
|
||||
"include": ["src", "nodes"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user