Chore/LC v0.3 (#3517)

* bump langchain version to 0.3, upgrades on all chat models

* update all docs loader to have documents and text output options

* fix pnpm lock file
This commit is contained in:
Henry Heng
2024-11-28 11:06:12 +00:00
committed by GitHub
parent 126808b62a
commit 940c8fd3b0
82 changed files with 2373 additions and 1540 deletions
+1 -1
View File
@@ -68,7 +68,7 @@
},
"resolutions": {
"@google/generative-ai": "^0.15.0",
"@langchain/core": "0.2.18",
"@langchain/core": "0.3.18",
"@qdrant/openapi-typescript-fetch": "1.2.6",
"openai": "4.57.3",
"protobufjs": "7.4.0"
@@ -1,28 +1,28 @@
import { INodeParams, INodeCredential } from '../src/Interface'
class BaiduApi implements INodeCredential {
class BaiduQianfanApi implements INodeCredential {
label: string
name: string
version: number
inputs: INodeParams[]
constructor() {
this.label = 'Baidu API'
this.name = 'baiduApi'
this.version = 1.0
this.label = 'Baidu Qianfan API'
this.name = 'baiduQianfanApi'
this.version = 2.0
this.inputs = [
{
label: 'Baidu Api Key',
name: 'baiduApiKey',
type: 'password'
label: 'Qianfan Access Key',
name: 'qianfanAccessKey',
type: 'string'
},
{
label: 'Baidu Secret Key',
name: 'baiduSecretKey',
label: 'Qianfan Secret Key',
name: 'qianfanSecretKey',
type: 'password'
}
]
}
}
module.exports = { credClass: BaiduApi }
module.exports = { credClass: BaiduQianfanApi }
@@ -0,0 +1,69 @@
import { INodeParams, INodeCredential } from '../src/Interface'
class IBMWatsonxCredential implements INodeCredential {
label: string
name: string
version: number
description: string
inputs: INodeParams[]
constructor() {
this.label = 'IBM Watsonx'
this.name = 'ibmWatsonx'
this.version = 1.0
this.inputs = [
{
label: 'Version',
name: 'version',
type: 'string',
placeholder: 'YYYY-MM-DD'
},
{
label: 'Service URL',
name: 'serviceUrl',
type: 'string',
placeholder: '<SERVICE_URL>'
},
{
label: 'Project ID',
name: 'projectId',
type: 'string',
placeholder: '<PROJECT_ID>'
},
{
label: 'Watsonx AI Auth Type',
name: 'watsonxAIAuthType',
type: 'options',
options: [
{
label: 'IAM',
name: 'iam'
},
{
label: 'Bearer Token',
name: 'bearertoken'
}
],
default: 'iam'
},
{
label: 'Watsonx AI IAM API Key',
name: 'watsonxAIApikey',
type: 'password',
description: 'API Key for Watsonx AI when using IAM',
placeholder: '<YOUR-APIKEY>',
optional: true
},
{
label: 'Watsonx AI Bearer Token',
name: 'watsonxAIBearerToken',
type: 'password',
description: 'Bearer Token for Watsonx AI when using Bearer Token',
placeholder: '<YOUR-BEARER-TOKEN>',
optional: true
}
]
}
}
module.exports = { credClass: IBMWatsonxCredential }
@@ -0,0 +1,24 @@
import { INodeParams, INodeCredential } from '../src/Interface'
class XaiApi implements INodeCredential {
label: string
name: string
version: number
description: string
inputs: INodeParams[]
constructor() {
this.label = 'Xai API'
this.name = 'xaiApi'
this.version = 1.0
this.inputs = [
{
label: 'X AI API Key',
name: 'xaiApiKey',
type: 'password'
}
]
}
}
module.exports = { credClass: XaiApi }
+14 -53
View File
@@ -426,21 +426,8 @@
"name": "gemini-1.5-pro-002"
},
{
"label": "gemini-pro",
"name": "gemini-pro"
},
{
"label": "gemini-pro-vision",
"name": "gemini-pro-vision"
}
]
},
{
"name": "chatGooglePaLM",
"models": [
{
"label": "models/chat-bison-001",
"name": "models/chat-bison-001"
"label": "gemini-1.0-pro-latest (deprecated)",
"name": "gemini-1.0-pro-latest"
}
]
},
@@ -457,12 +444,20 @@
"name": "chatGoogleVertexAI",
"models": [
{
"label": "gemini-1.5-flash",
"name": "gemini-1.5-flash-preview-0514"
"label": "gemini-1.5-flash-002",
"name": "gemini-1.5-flash-002"
},
{
"label": "gemini-1.5-pro",
"name": "gemini-1.5-pro-preview-0409"
"label": "gemini-1.5-flash-001",
"name": "gemini-1.5-flash-001"
},
{
"label": "gemini-1.5-pro-002",
"name": "gemini-1.5-pro-002"
},
{
"label": "gemini-1.5-pro-001",
"name": "gemini-1.5-pro-001"
},
{
"label": "gemini-1.0-pro",
@@ -496,22 +491,6 @@
"label": "claude-3-haiku@20240307",
"name": "claude-3-haiku@20240307",
"description": "Fastest and most compact model for near-instant responsiveness"
},
{
"label": "chat-bison",
"name": "chat-bison"
},
{
"label": "codechat-bison",
"name": "codechat-bison"
},
{
"label": "chat-bison-32k",
"name": "chat-bison-32k"
},
{
"label": "codechat-bison-32k",
"name": "codechat-bison-32k"
}
]
},
@@ -1112,15 +1091,6 @@
}
]
},
{
"name": "GooglePaLM",
"models": [
{
"label": "models/text-bison-001",
"name": "models/text-bison-001"
}
]
},
{
"name": "googlevertexai",
"models": [
@@ -1267,15 +1237,6 @@
}
]
},
{
"name": "googlePaLMEmbeddings",
"models": [
{
"label": "models/embedding-gecko-001",
"name": "models/embedding-gecko-001"
}
]
},
{
"name": "googlevertexaiEmbeddings",
"models": [
@@ -38,7 +38,6 @@ class ConversationalRetrievalToolAgent_Agents implements INode {
baseClasses: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string
constructor(fields?: { sessionId?: string }) {
this.label = 'Conversational Retrieval Tool Agent'
@@ -50,7 +49,6 @@ class ConversationalRetrievalToolAgent_Agents implements INode {
this.icon = 'toolAgent.png'
this.description = `Agent that calls a vector store retrieval and uses Function Calling to pick the tools and args to call`
this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)]
this.badge = 'NEW'
this.inputs = [
{
label: 'Tools',
@@ -15,7 +15,6 @@ class AnthropicAgent_LlamaIndex_Agents implements INode {
tags: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string
constructor(fields?: { sessionId?: string }) {
this.label = 'Anthropic Agent'
@@ -24,7 +24,6 @@ class OpenAIFunctionAgent_LlamaIndex_Agents implements INode {
tags: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string
constructor(fields?: { sessionId?: string }) {
this.label = 'OpenAI Tool Agent'
@@ -35,7 +35,6 @@ class ToolAgent_Agents implements INode {
baseClasses: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string
constructor(fields?: { sessionId?: string }) {
this.label = 'Tool Agent'
@@ -191,6 +190,7 @@ class ToolAgent_Agents implements INode {
output = removeInvalidImageMarkdown(output)
// Claude 3 Opus tends to spit out <thinking>..</thinking> as well, discard that in final output
// https://docs.anthropic.com/en/docs/build-with-claude/tool-use#chain-of-thought
const regexPattern: RegExp = /<thinking>[\s\S]*?<\/thinking>/
const matches: RegExpMatchArray | null = output.match(regexPattern)
if (matches) {
@@ -57,7 +57,6 @@ class XMLAgent_Agents implements INode {
baseClasses: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string
constructor(fields?: { sessionId?: string }) {
this.label = 'XML Agent'
@@ -1,9 +1,9 @@
import { BaseCache } from '@langchain/core/caches'
import { ICommonObject, IMultiModalOption, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { BedrockChat } from './FlowiseAWSChatBedrock'
import { getModels, getRegions, MODEL_TYPE } from '../../../src/modelLoader'
import { BedrockChatFields } from '@langchain/community/chat_models/bedrock'
import { ChatBedrockConverseInput, ChatBedrockConverse } from '@langchain/aws'
import { BedrockChat } from './FlowiseAWSChatBedrock'
/**
* @author Michael Connor <mlconnor@yahoo.com>
@@ -23,12 +23,12 @@ class AWSChatBedrock_ChatModels implements INode {
constructor() {
this.label = 'AWS ChatBedrock'
this.name = 'awsChatBedrock'
this.version = 5.0
this.version = 6.0
this.type = 'AWSChatBedrock'
this.icon = 'aws.svg'
this.category = 'Chat Models'
this.description = 'Wrapper around AWS Bedrock large language models that use the Chat endpoint'
this.baseClasses = [this.type, ...getBaseClasses(BedrockChat)]
this.description = 'Wrapper around AWS Bedrock large language models that use the Converse API'
this.baseClasses = [this.type, ...getBaseClasses(ChatBedrockConverse)]
this.credential = {
label: 'AWS Credential',
name: 'credential',
@@ -64,6 +64,14 @@ class AWSChatBedrock_ChatModels implements INode {
type: 'string',
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Temperature',
name: 'temperature',
@@ -89,7 +97,7 @@ class AWSChatBedrock_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Only works with claude-3-* models when image is being uploaded from chat. Compatible with LLMChain, Conversation Chain, ReAct Agent, Conversational Agent, Tool Agent',
'Allow image input. Refer to the <a href="https://docs.flowiseai.com/using-flowise/uploads#image" target="_blank">docs</a> for more details.',
default: false,
optional: true
}
@@ -115,7 +123,7 @@ class AWSChatBedrock_ChatModels implements INode {
const cache = nodeData.inputs?.cache as BaseCache
const streaming = nodeData.inputs?.streaming as boolean
const obj: BedrockChatFields = {
const obj: ChatBedrockConverseInput = {
region: iRegion,
model: customModel ? customModel : iModel,
maxTokens: parseInt(iMax_tokens_to_sample, 10),
@@ -153,7 +161,7 @@ class AWSChatBedrock_ChatModels implements INode {
}
const amazonBedrock = new BedrockChat(nodeData.id, obj)
if (obj.model?.includes('anthropic.claude-3')) amazonBedrock.setMultiModalOption(multiModalOption)
amazonBedrock.setMultiModalOption(multiModalOption)
return amazonBedrock
}
}
@@ -1,5 +1,8 @@
import { BedrockChatFields, BedrockChat as LCBedrockChat } from '@langchain/community/chat_models/bedrock'
import { IVisionChatModal, IMultiModalOption } from '../../../src'
import { ChatBedrockConverse as LCBedrockChat, ChatBedrockConverseInput } from '@langchain/aws'
const DEFAULT_IMAGE_MODEL = 'anthropic.claude-3-haiku-20240307-v1:0'
const DEFAULT_IMAGE_MAX_TOKEN = 1024
export class BedrockChat extends LCBedrockChat implements IVisionChatModal {
configuredModel: string
@@ -7,7 +10,7 @@ export class BedrockChat extends LCBedrockChat implements IVisionChatModal {
multiModalOption: IMultiModalOption
id: string
constructor(id: string, fields: BedrockChatFields) {
constructor(id: string, fields: ChatBedrockConverseInput) {
super(fields)
this.id = id
this.configuredModel = fields?.model || ''
@@ -25,8 +28,8 @@ export class BedrockChat extends LCBedrockChat implements IVisionChatModal {
setVisionModel(): void {
if (!this.model.startsWith('claude-3')) {
this.model = 'anthropic.claude-3-haiku-20240307-v1:0'
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : 1024
this.model = DEFAULT_IMAGE_MODEL
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : DEFAULT_IMAGE_MAX_TOKEN
}
}
}
@@ -27,7 +27,7 @@ class AzureChatOpenAI_ChatModels implements INode {
constructor() {
this.label = 'Azure ChatOpenAI'
this.name = 'azureChatOpenAI'
this.version = 5.0
this.version = 6.0
this.type = 'AzureChatOpenAI'
this.icon = 'Azure.svg'
this.category = 'Chat Models'
@@ -69,6 +69,14 @@ class AzureChatOpenAI_ChatModels implements INode {
optional: true,
additionalParams: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Top Probability',
name: 'topP',
@@ -113,7 +121,7 @@ class AzureChatOpenAI_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Automatically uses gpt-4-vision-preview when image is being uploaded from chat. Only works with LLMChain, Conversation Chain, ReAct Agent, Conversational Agent, Tool Agent',
'Allow image input. Refer to the <a href="https://docs.flowiseai.com/using-flowise/uploads#image" target="_blank">docs</a> for more details.',
default: false,
optional: true
},
@@ -19,7 +19,7 @@ class ChatAlibabaTongyi_ChatModels implements INode {
constructor() {
this.label = 'ChatAlibabaTongyi'
this.name = 'chatAlibabaTongyi'
this.version = 1.0
this.version = 2.0
this.type = 'ChatAlibabaTongyi'
this.icon = 'alibaba-svgrepo-com.svg'
this.category = 'Chat Models'
@@ -51,6 +51,13 @@ class ChatAlibabaTongyi_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -59,12 +66,13 @@ class ChatAlibabaTongyi_ChatModels implements INode {
const cache = nodeData.inputs?.cache as BaseCache
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const alibabaApiKey = getCredentialParam('alibabaApiKey', credentialData, nodeData)
const obj: Partial<ChatAlibabaTongyi> & BaseChatModelParams = {
streaming: true,
streaming: streaming ?? true,
alibabaApiKey,
model: modelName,
temperature: temperature ? parseFloat(temperature) : undefined
@@ -21,7 +21,7 @@ class ChatAnthropic_ChatModels implements INode {
constructor() {
this.label = 'ChatAnthropic'
this.name = 'chatAnthropic'
this.version = 6.0
this.version = 7.0
this.type = 'ChatAnthropic'
this.icon = 'Anthropic.svg'
this.category = 'Chat Models'
@@ -55,6 +55,14 @@ class ChatAnthropic_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokensToSample',
@@ -84,7 +92,7 @@ class ChatAnthropic_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Automatically uses claude-3-* models when image is being uploaded from chat. Only works with LLMChain, Conversation Chain, ReAct Agent, Conversational Agent, Tool Agent',
'Allow image input. Refer to the <a href="https://docs.flowiseai.com/using-flowise/uploads#image" target="_blank">docs</a> for more details.',
default: false,
optional: true
}
@@ -2,6 +2,9 @@ import { AnthropicInput, ChatAnthropic as LangchainChatAnthropic } from '@langch
import { type BaseChatModelParams } from '@langchain/core/language_models/chat_models'
import { IVisionChatModal, IMultiModalOption } from '../../../src'
const DEFAULT_IMAGE_MODEL = 'claude-3-5-haiku-latest'
const DEFAULT_IMAGE_MAX_TOKEN = 2048
export class ChatAnthropic extends LangchainChatAnthropic implements IVisionChatModal {
configuredModel: string
configuredMaxToken: number
@@ -27,8 +30,8 @@ export class ChatAnthropic extends LangchainChatAnthropic implements IVisionChat
setVisionModel(): void {
if (!this.modelName.startsWith('claude-3')) {
this.modelName = 'claude-3-haiku-20240307'
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : 2048
this.modelName = DEFAULT_IMAGE_MODEL
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : DEFAULT_IMAGE_MAX_TOKEN
}
}
}
@@ -1,5 +1,5 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatBaiduWenxin } from '@langchain/community/chat_models/baiduwenxin'
import { ChatBaiduQianfan } from '@langchain/baidu-qianfan'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
@@ -18,17 +18,17 @@ class ChatBaiduWenxin_ChatModels implements INode {
constructor() {
this.label = 'ChatBaiduWenxin'
this.name = 'chatBaiduWenxin'
this.version = 1.0
this.version = 2.0
this.type = 'ChatBaiduWenxin'
this.icon = 'baiduwenxin.svg'
this.category = 'Chat Models'
this.description = 'Wrapper around BaiduWenxin Chat Endpoints'
this.baseClasses = [this.type, ...getBaseClasses(ChatBaiduWenxin)]
this.baseClasses = [this.type, ...getBaseClasses(ChatBaiduQianfan)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['baiduApi']
credentialNames: ['baiduQianfanApi']
}
this.inputs = [
{
@@ -50,6 +50,13 @@ class ChatBaiduWenxin_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -58,21 +65,22 @@ class ChatBaiduWenxin_ChatModels implements INode {
const cache = nodeData.inputs?.cache as BaseCache
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const baiduApiKey = getCredentialParam('baiduApiKey', credentialData, nodeData)
const baiduSecretKey = getCredentialParam('baiduSecretKey', credentialData, nodeData)
const qianfanAccessKey = getCredentialParam('qianfanAccessKey', credentialData, nodeData)
const qianfanSecretKey = getCredentialParam('qianfanSecretKey', credentialData, nodeData)
const obj: Partial<ChatBaiduWenxin> = {
streaming: true,
baiduApiKey,
baiduSecretKey,
const obj: Partial<ChatBaiduQianfan> = {
streaming: streaming ?? true,
qianfanAccessKey,
qianfanSecretKey,
modelName,
temperature: temperature ? parseFloat(temperature) : undefined
}
if (cache) obj.cache = cache
const model = new ChatBaiduWenxin(obj)
const model = new ChatBaiduQianfan(obj)
return model
}
}
@@ -19,11 +19,11 @@ class ChatCerebras_ChatModels implements INode {
constructor() {
this.label = 'ChatCerebras'
this.name = 'chatCerebras'
this.version = 1.0
this.version = 2.0
this.type = 'ChatCerebras'
this.icon = 'cerebras.png'
this.category = 'Chat Models'
this.description = 'Models available via Cerebras'
this.description = 'Wrapper around Cerebras Inference API'
this.baseClasses = [this.type, ...getBaseClasses(ChatOpenAI)]
this.credential = {
label: 'Connect Credential',
@@ -53,6 +53,14 @@ class ChatCerebras_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
@@ -19,7 +19,7 @@ class ChatCohere_ChatModels implements INode {
constructor() {
this.label = 'ChatCohere'
this.name = 'chatCohere'
this.version = 1.0
this.version = 2.0
this.type = 'ChatCohere'
this.icon = 'Cohere.svg'
this.category = 'Chat Models'
@@ -52,6 +52,13 @@ class ChatCohere_ChatModels implements INode {
step: 0.1,
default: 0.7,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -18,7 +18,7 @@ class ChatFireworks_ChatModels implements INode {
constructor() {
this.label = 'ChatFireworks'
this.name = 'chatFireworks'
this.version = 1.0
this.version = 2.0
this.type = 'ChatFireworks'
this.icon = 'Fireworks.png'
this.category = 'Chat Models'
@@ -51,6 +51,13 @@ class ChatFireworks_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -21,7 +21,7 @@ class GoogleGenerativeAI_ChatModels implements INode {
constructor() {
this.label = 'ChatGoogleGenerativeAI'
this.name = 'chatGoogleGenerativeAI'
this.version = 2.1
this.version = 3.0
this.type = 'ChatGoogleGenerativeAI'
this.icon = 'GoogleGemini.svg'
this.category = 'Chat Models'
@@ -47,7 +47,7 @@ class GoogleGenerativeAI_ChatModels implements INode {
name: 'modelName',
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'gemini-pro'
default: 'gemini-1.5-flash-latest'
},
{
label: 'Custom Model Name',
@@ -65,6 +65,14 @@ class GoogleGenerativeAI_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Output Tokens',
name: 'maxOutputTokens',
@@ -153,7 +161,7 @@ class GoogleGenerativeAI_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Automatically uses vision model when image is being uploaded from chat. Only works with LLMChain, Conversation Chain, ReAct Agent, Conversational Agent, Tool Agent',
'Allow image input. Refer to the <a href="https://docs.flowiseai.com/using-flowise/uploads#image" target="_blank">docs</a> for more details.',
default: false,
optional: true
}
@@ -26,6 +26,9 @@ import { isStructuredTool } from '@langchain/core/utils/function_calling'
import { zodToJsonSchema } from 'zod-to-json-schema'
import { BaseLanguageModelCallOptions } from '@langchain/core/language_models/base'
const DEFAULT_IMAGE_MAX_TOKEN = 8192
const DEFAULT_IMAGE_MODEL = 'gemini-1.5-flash-latest'
interface TokenUsage {
completionTokens?: number
promptTokens?: number
@@ -362,9 +365,9 @@ export class ChatGoogleGenerativeAI extends LangchainChatGoogleGenerativeAI impl
}
setVisionModel(): void {
if (this.modelName !== 'gemini-pro-vision' && this.modelName !== 'gemini-1.5-pro-latest') {
this.modelName = 'gemini-1.5-pro-latest'
this.maxOutputTokens = this.configuredMaxToken ? this.configuredMaxToken : 8192
if (this.modelName === 'gemini-1.0-pro-latest') {
this.modelName = DEFAULT_IMAGE_MODEL
this.maxOutputTokens = this.configuredMaxToken ? this.configuredMaxToken : DEFAULT_IMAGE_MAX_TOKEN
}
}
}
@@ -607,13 +610,13 @@ function convertResponseContentToChatGenerationChunk(
index: number
}
): ChatGenerationChunk | null {
if (!response.candidates || response.candidates.length === 0) {
if (!response || !response.candidates || response.candidates.length === 0) {
return null
}
const functionCalls = response.functionCalls()
const [candidate] = response.candidates
const { content, ...generationInfo } = candidate
const text = content?.parts[0]?.text ?? ''
const text = content?.parts?.[0]?.text ?? ''
const toolCallChunks: ToolCallChunk[] = []
if (functionCalls) {
@@ -1,128 +0,0 @@
import { ChatGooglePaLM, GooglePaLMChatInput } from '@langchain/community/chat_models/googlepalm'
import { BaseCache } from '@langchain/core/caches'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
class ChatGooglePaLM_ChatModels implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'ChatGooglePaLM'
this.name = 'chatGooglePaLM'
this.version = 3.0
this.type = 'ChatGooglePaLM'
this.icon = 'GooglePaLM.svg'
this.category = 'Chat Models'
this.description = 'Wrapper around Google MakerSuite PaLM large language models using the Chat endpoint'
this.baseClasses = [this.type, ...getBaseClasses(ChatGooglePaLM)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['googleMakerSuite']
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model Name',
name: 'modelName',
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'models/chat-bison-001'
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
default: 0.7,
optional: true,
description:
'Controls the randomness of the output.\n' +
'Values can range from [0.0,1.0], inclusive. A value closer to 1.0 ' +
'will produce responses that are more varied and creative, while ' +
'a value closer to 0.0 will typically result in more straightforward ' +
'responses from the model.'
},
{
label: 'Top Probability',
name: 'topP',
type: 'number',
step: 0.1,
optional: true,
additionalParams: true,
description:
'Top-p changes how the model selects tokens for output.\n' +
'Tokens are selected from most probable to least until ' +
'the sum of their probabilities equals the top-p value.\n' +
'For example, if tokens A, B, and C have a probability of .3, .2, and .1 ' +
'and the top-p value is .5, then the model will select either A or B ' +
'as the next token (using temperature).'
},
{
label: 'Top-k',
name: 'topK',
type: 'number',
step: 1,
optional: true,
additionalParams: true,
description:
'Top-k changes how the model selects tokens for output.\n' +
'A top-k of 1 means the selected token is the most probable among ' +
'all tokens in the model vocabulary (also called greedy decoding), ' +
'while a top-k of 3 means that the next token is selected from ' +
'among the 3 most probable tokens (using temperature).'
}
// 'The "examples" field should contain a list of pairs of strings to use as prior turns for this conversation.'
// NB: While 'examples:[]' exists in langchain.ts backend, it is unlikely to be actually used there, since ChatOpenAI doesn't support it
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.CHAT, 'chatGooglePaLM')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string
const temperature = nodeData.inputs?.temperature as string
const topP = nodeData.inputs?.topP as string
const topK = nodeData.inputs?.topK as string
const cache = nodeData.inputs?.cache as BaseCache
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const googleMakerSuiteKey = getCredentialParam('googleMakerSuiteKey', credentialData, nodeData)
const obj: Partial<GooglePaLMChatInput> = {
modelName: modelName,
temperature: parseFloat(temperature),
apiKey: googleMakerSuiteKey
}
if (topP) obj.topP = parseFloat(topP)
if (topK) obj.topK = parseFloat(topK)
if (cache) obj.cache = cache
const model = new ChatGooglePaLM(obj)
return model
}
}
module.exports = { nodeClass: ChatGooglePaLM_ChatModels }
@@ -1 +0,0 @@
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.991 28.555c1.064 0 1.926-.624 1.926-1.394V15.074h-3.852v12.087c0 .77.862 1.394 1.926 1.394Z" fill="#F9AB00" stroke="#F9AB00"/><path d="M23.01 16.825a6.301 6.301 0 0 0-6.606-1.467c-.322.117-.39.525-.148.767l7.294 7.294a.61.61 0 0 0 1.01-.238 6.3 6.3 0 0 0-1.55-6.356Z" fill="#5BB974" stroke="#5BB974"/><path d="M8.516 16.825a6.301 6.301 0 0 1 6.606-1.467c.322.117.39.525.148.767l-7.294 7.294a.61.61 0 0 1-1.01-.238 6.3 6.3 0 0 1 1.55-6.356Z" fill="#129EAF" stroke="#129EAF"/><path d="M22.433 10.781c-2.856 0-5.314 1.726-6.419 4.204-.139.312.102.647.443.647h11.62a.681.681 0 0 0 .613-.984c-1.17-2.296-3.532-3.867-6.258-3.867Z" fill="#AF5CF7" stroke="#AF5CF7"/><path d="M17.05 7.486c-2.02 2.02-2.538 4.977-1.567 7.51.122.32.53.386.77.145l8.218-8.217a.681.681 0 0 0-.262-1.13c-2.453-.795-5.233-.235-7.16 1.692Z" fill="#FF8BCB" stroke="#FF8BCB"/><path d="M14.476 7.486c2.02 2.02 2.538 4.977 1.566 7.51-.122.32-.529.386-.77.145L7.055 6.924a.681.681 0 0 1 .262-1.13C9.769 5 12.549 5.56 14.476 7.486Z" fill="#FA7B17" stroke="#FA7B17"/><path d="M9.093 10.781c2.856 0 5.314 1.726 6.418 4.204.14.312-.1.647-.442.647H3.449a.681.681 0 0 1-.613-.984c1.17-2.296 3.532-3.867 6.257-3.867Z" fill="#4285F4" stroke="#4285F4"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

@@ -1,9 +1,51 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatVertexAI, ChatVertexAIInput } from '@langchain/google-vertexai'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { ChatVertexAI as LcChatVertexAI, ChatVertexAIInput } from '@langchain/google-vertexai'
import {
ICommonObject,
IMultiModalOption,
INode,
INodeData,
INodeOptionsValue,
INodeParams,
IVisionChatModal
} from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
const DEFAULT_IMAGE_MAX_TOKEN = 8192
const DEFAULT_IMAGE_MODEL = 'gemini-1.5-flash-latest'
class ChatVertexAI extends LcChatVertexAI implements IVisionChatModal {
configuredModel: string
configuredMaxToken: number
multiModalOption: IMultiModalOption
id: string
constructor(id: string, fields?: ChatVertexAIInput) {
// @ts-ignore
super(fields ?? {})
this.id = id
this.configuredModel = fields?.modelName || ''
this.configuredMaxToken = fields?.maxOutputTokens ?? 2048
}
revertToOriginalModel(): void {
this.modelName = this.configuredModel
this.maxOutputTokens = this.configuredMaxToken
}
setMultiModalOption(multiModalOption: IMultiModalOption): void {
this.multiModalOption = multiModalOption
}
setVisionModel(): void {
if (!this.modelName.startsWith('claude-3')) {
this.modelName = DEFAULT_IMAGE_MODEL
this.maxOutputTokens = this.configuredMaxToken ? this.configuredMaxToken : DEFAULT_IMAGE_MAX_TOKEN
}
}
}
class GoogleVertexAI_ChatModels implements INode {
label: string
name: string
@@ -19,7 +61,7 @@ class GoogleVertexAI_ChatModels implements INode {
constructor() {
this.label = 'ChatGoogleVertexAI'
this.name = 'chatGoogleVertexAI'
this.version = 4.0
this.version = 5.0
this.type = 'ChatGoogleVertexAI'
this.icon = 'GoogleVertex.svg'
this.category = 'Chat Models'
@@ -45,8 +87,7 @@ class GoogleVertexAI_ChatModels implements INode {
label: 'Model Name',
name: 'modelName',
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'chat-bison'
loadMethod: 'listModels'
},
{
label: 'Temperature',
@@ -56,6 +97,23 @@ class GoogleVertexAI_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Allow Image Uploads',
name: 'allowImageUploads',
type: 'boolean',
description:
'Allow image input. Refer to the <a href="https://docs.flowiseai.com/using-flowise/uploads#image" target="_blank">docs</a> for more details.',
default: false,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Output Tokens',
name: 'maxOutputTokens',
@@ -120,10 +178,20 @@ class GoogleVertexAI_ChatModels implements INode {
const topP = nodeData.inputs?.topP as string
const cache = nodeData.inputs?.cache as BaseCache
const topK = nodeData.inputs?.topK as string
const streaming = nodeData.inputs?.streaming as boolean
const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
const multiModalOption: IMultiModalOption = {
image: {
allowImageUploads: allowImageUploads ?? false
}
}
const obj: ChatVertexAIInput = {
temperature: parseFloat(temperature),
model: modelName
model: modelName,
streaming: streaming ?? true
}
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
@@ -132,7 +200,9 @@ class GoogleVertexAI_ChatModels implements INode {
if (cache) obj.cache = cache
if (topK) obj.topK = parseFloat(topK)
const model = new ChatVertexAI(obj)
const model = new ChatVertexAI(nodeData.id, obj)
model.setMultiModalOption(multiModalOption)
return model
}
}
@@ -0,0 +1,120 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatWatsonx, ChatWatsonxInput } from '@langchain/community/chat_models/ibm'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
interface WatsonxAuth {
watsonxAIApikey?: string
watsonxAIBearerToken?: string
watsonxAIUsername?: string
watsonxAIPassword?: string
watsonxAIUrl?: string
watsonxAIAuthType?: string
}
class ChatIBMWatsonx_ChatModels implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'ChatIBMWatsonx'
this.name = 'chatIBMWatsonx'
this.version = 1.0
this.type = 'ChatIBMWatsonx'
this.icon = 'ibm.png'
this.category = 'Chat Models'
this.description = 'Wrapper around IBM watsonx.ai foundation models'
this.baseClasses = [this.type, ...getBaseClasses(ChatWatsonx)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['ibmWatsonx']
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model',
name: 'modelName',
type: 'string',
placeholder: 'mistralai/mistral-large'
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
type: 'number',
step: 1,
optional: true,
additionalParams: true
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const cache = nodeData.inputs?.cache as BaseCache
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string
const maxTokens = nodeData.inputs?.maxTokens as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const version = getCredentialParam('version', credentialData, nodeData)
const serviceUrl = getCredentialParam('serviceUrl', credentialData, nodeData)
const projectId = getCredentialParam('projectId', credentialData, nodeData)
const watsonxAIAuthType = getCredentialParam('watsonxAIAuthType', credentialData, nodeData)
const watsonxAIApikey = getCredentialParam('watsonxAIApikey', credentialData, nodeData)
const watsonxAIBearerToken = getCredentialParam('watsonxAIBearerToken', credentialData, nodeData)
const auth = {
version,
serviceUrl,
projectId,
watsonxAIAuthType,
watsonxAIApikey,
watsonxAIBearerToken
}
const obj: ChatWatsonxInput & WatsonxAuth = {
...auth,
streaming: streaming ?? true,
model: modelName,
temperature: temperature ? parseFloat(temperature) : undefined
}
if (cache) obj.cache = cache
if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
const model = new ChatWatsonx(obj)
return model
}
}
module.exports = { nodeClass: ChatIBMWatsonx_ChatModels }
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

@@ -19,7 +19,7 @@ class ChatLocalAI_ChatModels implements INode {
constructor() {
this.label = 'ChatLocalAI'
this.name = 'chatLocalAI'
this.version = 2.0
this.version = 3.0
this.type = 'ChatLocalAI'
this.icon = 'localai.png'
this.category = 'Chat Models'
@@ -59,6 +59,14 @@ class ChatLocalAI_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
@@ -93,6 +101,8 @@ class ChatLocalAI_ChatModels implements INode {
const topP = nodeData.inputs?.topP as string
const timeout = nodeData.inputs?.timeout as string
const basePath = nodeData.inputs?.basePath as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const localAIApiKey = getCredentialParam('localAIApiKey', credentialData, nodeData)
@@ -101,7 +111,8 @@ class ChatLocalAI_ChatModels implements INode {
const obj: Partial<OpenAIChatInput> & BaseLLMParams & { openAIApiKey?: string } = {
temperature: parseFloat(temperature),
modelName,
openAIApiKey: 'sk-'
openAIApiKey: 'sk-',
streaming: streaming ?? true
}
if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
@@ -19,7 +19,7 @@ class ChatMistral_ChatModels implements INode {
constructor() {
this.label = 'ChatMistralAI'
this.name = 'chatMistralAI'
this.version = 3.0
this.version = 4.0
this.type = 'ChatMistralAI'
this.icon = 'MistralAI.svg'
this.category = 'Chat Models'
@@ -55,6 +55,14 @@ class ChatMistral_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Output Tokens',
name: 'maxOutputTokens',
@@ -20,7 +20,7 @@ class ChatOllama_ChatModels implements INode {
constructor() {
this.label = 'ChatOllama'
this.name = 'chatOllama'
this.version = 4.0
this.version = 5.0
this.type = 'ChatOllama'
this.icon = 'Ollama.svg'
this.category = 'Chat Models'
@@ -59,10 +59,19 @@ class ChatOllama_ChatModels implements INode {
label: 'Allow Image Uploads',
name: 'allowImageUploads',
type: 'boolean',
description: 'Allow image uploads for multimodal models. e.g. llama3.2-vision',
description:
'Allow image input. Refer to the <a href="https://docs.flowiseai.com/using-flowise/uploads#image" target="_blank">docs</a> for more details.',
default: false,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'JSON Mode',
name: 'jsonMode',
@@ -223,13 +232,15 @@ class ChatOllama_ChatModels implements INode {
const tfsZ = nodeData.inputs?.tfsZ as string
const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
const jsonMode = nodeData.inputs?.jsonMode as boolean
const streaming = nodeData.inputs?.streaming as boolean
const cache = nodeData.inputs?.cache as BaseCache
const obj: ChatOllamaInput & BaseChatModelParams = {
baseUrl,
temperature: parseFloat(temperature),
model: modelName
model: modelName,
streaming: streaming ?? true
}
if (topP) obj.topP = parseFloat(topP)
@@ -23,7 +23,7 @@ class ChatOpenAI_ChatModels implements INode {
constructor() {
this.label = 'ChatOpenAI'
this.name = 'chatOpenAI'
this.version = 7.0
this.version = 8.0
this.type = 'ChatOpenAI'
this.icon = 'openai.svg'
this.category = 'Chat Models'
@@ -57,6 +57,14 @@ class ChatOpenAI_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
@@ -132,7 +140,7 @@ class ChatOpenAI_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Automatically uses gpt-4-vision-preview when image is being uploaded from chat. Only works with LLMChain, Conversation Chain, ReAct Agent, Conversational Agent, Tool Agent',
'Allow image input. Refer to the <a href="https://docs.flowiseai.com/using-flowise/uploads#image" target="_blank">docs</a> for more details.',
default: false,
optional: true
},
@@ -33,9 +33,6 @@ export class ChatOpenAI extends LangchainChatOpenAI implements IVisionChatModal
}
setVisionModel(): void {
if (this.modelName !== 'gpt-4-turbo' && !this.modelName.includes('vision')) {
this.modelName = 'gpt-4-turbo'
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : 1024
}
// pass
}
}
@@ -19,7 +19,7 @@ class ChatOpenAICustom_ChatModels implements INode {
constructor() {
this.label = 'ChatOpenAI Custom'
this.name = 'chatOpenAICustom'
this.version = 3.0
this.version = 4.0
this.type = 'ChatOpenAI-Custom'
this.icon = 'openai.svg'
this.category = 'Chat Models'
@@ -53,6 +53,14 @@ class ChatOpenAICustom_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
@@ -18,7 +18,7 @@ class ChatTogetherAI_ChatModels implements INode {
constructor() {
this.label = 'ChatTogetherAI'
this.name = 'chatTogetherAI'
this.version = 1.0
this.version = 2.0
this.type = 'ChatTogetherAI'
this.icon = 'togetherai.png'
this.category = 'Chat Models'
@@ -51,6 +51,13 @@ class ChatTogetherAI_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -0,0 +1,105 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatXAI, ChatXAIInput } from '@langchain/xai'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
class ChatXAI_ChatModels implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'ChatXAI'
this.name = 'chatXAI'
this.version = 1.0
this.type = 'ChatXAI'
this.icon = 'xai.png'
this.category = 'Chat Models'
this.description = 'Wrapper around Grok from XAI'
this.baseClasses = [this.type, ...getBaseClasses(ChatXAI)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['xaiApi']
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model',
name: 'modelName',
type: 'string',
placeholder: 'grok-beta'
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
type: 'number',
step: 1,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
type: 'number',
step: 1,
optional: true,
additionalParams: true
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const cache = nodeData.inputs?.cache as BaseCache
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string
const maxTokens = nodeData.inputs?.maxTokens as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const xaiApiKey = getCredentialParam('xaiApiKey', credentialData, nodeData)
const obj: ChatXAIInput = {
apiKey: xaiApiKey,
streaming: streaming ?? true,
model: modelName,
temperature: temperature ? parseFloat(temperature) : undefined
}
if (cache) obj.cache = cache
if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
const model = new ChatXAI(obj)
return model
}
}
module.exports = { nodeClass: ChatXAI_ChatModels }
Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

@@ -19,7 +19,7 @@ class Groq_ChatModels implements INode {
constructor() {
this.label = 'GroqChat'
this.name = 'groqChat'
this.version = 3.0
this.version = 4.0
this.type = 'GroqChat'
this.icon = 'groq.png'
this.category = 'Chat Models'
@@ -53,6 +53,13 @@ class Groq_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -3,7 +3,8 @@ import { omit } from 'lodash'
import { Document } from '@langchain/core/documents'
import { TextSplitter } from 'langchain/text_splitter'
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, IDocument, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { handleEscapeCharacters } from '../../../src/utils'
class API_DocumentLoaders implements INode {
label: string
@@ -15,11 +16,12 @@ class API_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs?: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'API Loader'
this.name = 'apiLoader'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'api.svg'
this.category = 'Document Loaders'
@@ -88,6 +90,20 @@ class API_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData): Promise<any> {
const headers = nodeData.inputs?.headers as string
@@ -97,6 +113,7 @@ class API_DocumentLoaders implements INode {
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -161,7 +178,15 @@ class API_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,6 +1,6 @@
import { omit } from 'lodash'
import { INode, INodeData, INodeParams, ICommonObject } from '../../../src/Interface'
import { getCredentialData, getCredentialParam } from '../../../src/utils'
import { INode, INodeData, INodeParams, ICommonObject, INodeOutputsValue } from '../../../src/Interface'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
import { TextSplitter } from 'langchain/text_splitter'
import { ApifyDatasetLoader } from '@langchain/community/document_loaders/web/apify_dataset'
import { Document } from '@langchain/core/documents'
@@ -16,16 +16,23 @@ class ApifyWebsiteContentCrawler_DocumentLoaders implements INode {
baseClasses: string[]
inputs: INodeParams[]
credential: INodeParams
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Apify Website Content Crawler'
this.name = 'apifyWebsiteContentCrawler'
this.type = 'Document'
this.icon = 'apify-symbol-transparent.svg'
this.version = 2.0
this.version = 3.0
this.category = 'Document Loaders'
this.description = 'Load data from Apify Website Content Crawler'
this.baseClasses = [this.type]
this.credential = {
label: 'Connect Apify API',
name: 'credential',
type: 'credential',
credentialNames: ['apifyApi']
}
this.inputs = [
{
label: 'Text Splitter',
@@ -112,18 +119,27 @@ class ApifyWebsiteContentCrawler_DocumentLoaders implements INode {
additionalParams: true
}
]
this.credential = {
label: 'Connect Apify API',
name: 'credential',
type: 'credential',
credentialNames: ['apifyApi']
}
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -203,7 +219,15 @@ class ApifyWebsiteContentCrawler_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,8 +1,8 @@
import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, IDocument, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { BraveSearch } from '@langchain/community/tools/brave_search'
import { getCredentialData, getCredentialParam } from '../../../src/utils'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
import { Document } from '@langchain/core/documents'
class BraveSearchAPI_DocumentLoaders implements INode {
@@ -16,11 +16,12 @@ class BraveSearchAPI_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'BraveSearch API Document Loader'
this.name = 'braveSearchApiLoader'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'brave.svg'
this.category = 'Document Loaders'
@@ -65,6 +66,20 @@ class BraveSearchAPI_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -72,6 +87,7 @@ class BraveSearchAPI_DocumentLoaders implements INode {
const query = nodeData.inputs?.query as string
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -134,7 +150,15 @@ class BraveSearchAPI_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -3,9 +3,9 @@ import { omit } from 'lodash'
import { CheerioWebBaseLoader, WebBaseLoaderParams } from '@langchain/community/document_loaders/web/cheerio'
import { test } from 'linkifyjs'
import { parse } from 'css-what'
import { webCrawl, xmlScrape } from '../../../src'
import { SelectorType } from 'cheerio'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INodeOutputsValue, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { handleEscapeCharacters, webCrawl, xmlScrape } from '../../../src/utils'
class Cheerio_DocumentLoaders implements INode {
label: string
@@ -17,11 +17,12 @@ class Cheerio_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Cheerio Web Scraper'
this.name = 'cheerioWebScraper'
this.version = 1.1
this.version = 2.0
this.type = 'Document'
this.icon = 'cheerio.svg'
this.category = 'Document Loaders'
@@ -99,6 +100,20 @@ class Cheerio_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -107,6 +122,7 @@ class Cheerio_DocumentLoaders implements INode {
const relativeLinksMethod = nodeData.inputs?.relativeLinksMethod as string
const selectedLinks = nodeData.inputs?.selectedLinks as string[]
let limit = parseInt(nodeData.inputs?.limit as string)
const output = nodeData.outputs?.output as string
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
@@ -212,7 +228,15 @@ class Cheerio_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,8 +1,8 @@
import { omit } from 'lodash'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { ConfluencePagesLoader, ConfluencePagesLoaderParams } from '@langchain/community/document_loaders/web/confluence'
import { getCredentialData, getCredentialParam } from '../../../src'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
import { ICommonObject, INode, INodeData, INodeParams, INodeOutputsValue } from '../../../src/Interface'
class Confluence_DocumentLoaders implements INode {
label: string
@@ -15,11 +15,12 @@ class Confluence_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Confluence'
this.name = 'confluence'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'confluence.svg'
this.category = 'Document Loaders'
@@ -79,6 +80,20 @@ class Confluence_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -88,6 +103,7 @@ class Confluence_DocumentLoaders implements INode {
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -157,7 +173,15 @@ class Confluence_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,8 +1,8 @@
import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { CSVLoader } from '@langchain/community/document_loaders/fs/csv'
import { getFileFromStorage, handleEscapeCharacters } from '../../../src'
import { ICommonObject, IDocument, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
class Csv_DocumentLoaders implements INode {
label: string
@@ -11,7 +11,6 @@ class CustomDocumentLoader_DocumentLoaders implements INode {
type: string
icon: string
category: string
badge: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
@@ -14,7 +14,6 @@ class DocStore_DocumentLoaders implements INode {
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
badge: string
constructor() {
this.label = 'Document Store'
@@ -1,8 +1,8 @@
import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, IDocument, INode, INodeData, INodeParams, INodeOutputsValue } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { DocxLoader } from '@langchain/community/document_loaders/fs/docx'
import { getFileFromStorage } from '../../../src'
import { getFileFromStorage, handleEscapeCharacters } from '../../../src'
class Docx_DocumentLoaders implements INode {
label: string
@@ -14,11 +14,12 @@ class Docx_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Docx File'
this.name = 'docxFile'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'docx.svg'
this.category = 'Document Loaders'
@@ -57,6 +58,20 @@ class Docx_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -64,6 +79,7 @@ class Docx_DocumentLoaders implements INode {
const docxFileBase64 = nodeData.inputs?.docxFile as string
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -153,7 +169,15 @@ class Docx_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,6 +1,6 @@
import { omit } from 'lodash'
import { getCredentialData, getCredentialParam } from '../../../src'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src'
import { ICommonObject, IDocument, INode, INodeData, INodeParams, INodeOutputsValue } from '../../../src/Interface'
import { FigmaFileLoader, FigmaLoaderParams } from '@langchain/community/document_loaders/web/figma'
import { TextSplitter } from 'langchain/text_splitter'
@@ -15,11 +15,12 @@ class Figma_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Figma'
this.name = 'figma'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'figma.svg'
this.category = 'Document Loaders'
@@ -80,6 +81,20 @@ class Figma_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -88,6 +103,7 @@ class Figma_DocumentLoaders implements INode {
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -146,7 +162,15 @@ class Figma_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,5 +1,5 @@
import { omit } from 'lodash'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { TextLoader } from 'langchain/document_loaders/fs/text'
import { JSONLinesLoader, JSONLoader } from 'langchain/document_loaders/fs/json'
@@ -9,7 +9,7 @@ import { DocxLoader } from '@langchain/community/document_loaders/fs/docx'
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
import { Document } from '@langchain/core/documents'
import { getFileFromStorage } from '../../../src/storageUtils'
import { mapMimeTypeToExt } from '../../../src/utils'
import { handleEscapeCharacters, mapMimeTypeToExt } from '../../../src/utils'
class File_DocumentLoaders implements INode {
label: string
@@ -21,11 +21,12 @@ class File_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'File Loader'
this.name = 'fileLoader'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'file.svg'
this.category = 'Document Loaders'
@@ -92,6 +93,20 @@ class File_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -101,6 +116,7 @@ class File_DocumentLoaders implements INode {
const pdfUsage = nodeData.inputs?.pdfUsage
const pointerName = nodeData.inputs?.pointerName as string
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -229,7 +245,15 @@ class File_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,8 +1,8 @@
import { TextSplitter } from 'langchain/text_splitter'
import { Document, DocumentInterface } from '@langchain/core/documents'
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
import { INode, INodeData, INodeParams, ICommonObject } from '../../../src/Interface'
import { getCredentialData, getCredentialParam } from '../../../src/utils'
import { INode, INodeData, INodeParams, ICommonObject, INodeOutputsValue } from '../../../src/Interface'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
import axios, { AxiosResponse, AxiosRequestHeaders } from 'axios'
import { z } from 'zod'
import { zodToJsonSchema } from 'zod-to-json-schema'
@@ -259,16 +259,23 @@ class FireCrawl_DocumentLoaders implements INode {
baseClasses: string[]
inputs: INodeParams[]
credential: INodeParams
outputs: INodeOutputsValue[]
constructor() {
this.label = 'FireCrawl'
this.name = 'fireCrawl'
this.type = 'Document'
this.icon = 'firecrawl.png'
this.version = 1.0
this.version = 2.0
this.category = 'Document Loaders'
this.description = 'Load data from URL using FireCrawl'
this.baseClasses = [this.type]
this.credential = {
label: 'FireCrawl API',
name: 'credential',
type: 'credential',
credentialNames: ['fireCrawlApi']
}
this.inputs = [
{
label: 'Text Splitter',
@@ -303,12 +310,20 @@ class FireCrawl_DocumentLoaders implements INode {
}
// ... (other input parameters)
]
this.credential = {
label: 'FireCrawl API',
name: 'credential',
type: 'credential',
credentialNames: ['fireCrawlApi']
}
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -323,6 +338,7 @@ class FireCrawl_DocumentLoaders implements INode {
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const firecrawlApiToken = getCredentialParam('firecrawlApiToken', credentialData, nodeData)
const firecrawlApiUrl = getCredentialParam('firecrawlApiUrl', credentialData, nodeData, 'https://api.firecrawl.dev')
const output = nodeData.outputs?.output as string
const urlPatternsExcludes = nodeData.inputs?.urlPatternsExcludes
? (nodeData.inputs.urlPatternsExcludes.split(',') as string[])
@@ -375,7 +391,15 @@ class FireCrawl_DocumentLoaders implements INode {
return finaldocs
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,5 +1,5 @@
import { omit } from 'lodash'
import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { TextLoader } from 'langchain/document_loaders/fs/text'
import { DirectoryLoader } from 'langchain/document_loaders/fs/directory'
@@ -7,6 +7,7 @@ import { JSONLinesLoader, JSONLoader } from 'langchain/document_loaders/fs/json'
import { CSVLoader } from '@langchain/community/document_loaders/fs/csv'
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf'
import { DocxLoader } from '@langchain/community/document_loaders/fs/docx'
import { handleEscapeCharacters } from '../../../src/utils'
class Folder_DocumentLoaders implements INode {
label: string
@@ -18,11 +19,12 @@ class Folder_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Folder with Files'
this.name = 'folderFiles'
this.version = 3.0
this.version = 4.0
this.type = 'Document'
this.icon = 'folder.svg'
this.category = 'Document Loaders'
@@ -95,6 +97,20 @@ class Folder_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData): Promise<any> {
@@ -105,6 +121,7 @@ class Folder_DocumentLoaders implements INode {
const pdfUsage = nodeData.inputs?.pdfUsage
const pointerName = nodeData.inputs?.pointerName as string
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -206,7 +223,15 @@ class Folder_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,7 +1,8 @@
import { omit } from 'lodash'
import { IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { IDocument, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { GitbookLoader } from '@langchain/community/document_loaders/web/gitbook'
import { handleEscapeCharacters } from '../../../src/utils'
class Gitbook_DocumentLoaders implements INode {
label: string
@@ -13,11 +14,12 @@ class Gitbook_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs?: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'GitBook'
this.name = 'gitbook'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'gitbook.svg'
this.category = 'Document Loaders'
@@ -64,6 +66,20 @@ class Gitbook_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData): Promise<any> {
const webPath = nodeData.inputs?.webPath as string
@@ -71,6 +87,7 @@ class Gitbook_DocumentLoaders implements INode {
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -120,7 +137,15 @@ class Gitbook_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -2,7 +2,7 @@ import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { GithubRepoLoader, GithubRepoLoaderParams } from '@langchain/community/document_loaders/web/github'
import { getCredentialData, getCredentialParam } from '../../../src'
import { getCredentialData, getCredentialParam, handleEscapeCharacters, INodeOutputsValue } from '../../../src'
class Github_DocumentLoaders implements INode {
label: string
@@ -15,11 +15,12 @@ class Github_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Github'
this.name = 'github'
this.version = 2.0
this.version = 3.0
this.type = 'Document'
this.icon = 'github.svg'
this.category = 'Document Loaders'
@@ -106,6 +107,20 @@ class Github_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -118,6 +133,7 @@ class Github_DocumentLoaders implements INode {
const maxRetries = nodeData.inputs?.maxRetries as string
const ignorePath = nodeData.inputs?.ignorePath as string
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -181,7 +197,15 @@ class Github_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -2,7 +2,7 @@ import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { JSONLoader } from 'langchain/document_loaders/fs/json'
import { getFileFromStorage } from '../../../src'
import { getFileFromStorage, handleEscapeCharacters, INodeOutputsValue } from '../../../src'
class Json_DocumentLoaders implements INode {
label: string
@@ -14,11 +14,12 @@ class Json_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Json File'
this.name = 'jsonFile'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'json.svg'
this.category = 'Document Loaders'
@@ -65,6 +66,20 @@ class Json_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -73,6 +88,7 @@ class Json_DocumentLoaders implements INode {
const pointersName = nodeData.inputs?.pointersName as string
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -169,7 +185,15 @@ class Json_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -2,7 +2,7 @@ import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import jsonpointer from 'jsonpointer'
import { getFileFromStorage } from '../../../src'
import { getFileFromStorage, handleEscapeCharacters, INodeOutputsValue } from '../../../src'
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
import { Document } from '@langchain/core/documents'
import type { readFile as ReadFileT } from 'node:fs/promises'
@@ -37,11 +37,12 @@ class Jsonlines_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Json Lines File'
this.name = 'jsonlinesFile'
this.version = 2.0
this.version = 3.0
this.type = 'Document'
this.icon = 'jsonlines.svg'
this.category = 'Document Loaders'
@@ -93,6 +94,20 @@ class Jsonlines_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -101,6 +116,7 @@ class Jsonlines_DocumentLoaders implements INode {
const pointerName = nodeData.inputs?.pointerName as string
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -193,7 +209,15 @@ class Jsonlines_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -2,7 +2,7 @@ import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { NotionAPILoader, NotionAPILoaderOptions } from '@langchain/community/document_loaders/web/notionapi'
import { getCredentialData, getCredentialParam } from '../../../src'
import { getCredentialData, getCredentialParam, handleEscapeCharacters, INodeOutputsValue } from '../../../src'
class NotionDB_DocumentLoaders implements INode {
label: string
@@ -15,11 +15,12 @@ class NotionDB_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Notion Database'
this.name = 'notionDB'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'notion-db.svg'
this.category = 'Document Loaders'
@@ -64,6 +65,20 @@ class NotionDB_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -71,6 +86,7 @@ class NotionDB_DocumentLoaders implements INode {
const databaseId = nodeData.inputs?.databaseId as string
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -133,7 +149,15 @@ class NotionDB_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,7 +1,8 @@
import { omit } from 'lodash'
import { IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { IDocument, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { NotionLoader } from '@langchain/community/document_loaders/fs/notion'
import { handleEscapeCharacters } from '../../../src/utils'
class NotionFolder_DocumentLoaders implements INode {
label: string
@@ -13,11 +14,12 @@ class NotionFolder_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Notion Folder'
this.name = 'notionFolder'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'notion-folder.svg'
this.category = 'Document Loaders'
@@ -57,6 +59,20 @@ class NotionFolder_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData): Promise<any> {
@@ -64,6 +80,7 @@ class NotionFolder_DocumentLoaders implements INode {
const notionFolder = nodeData.inputs?.notionFolder as string
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -112,7 +129,15 @@ class NotionFolder_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -2,7 +2,7 @@ import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { NotionAPILoader, NotionAPILoaderOptions } from '@langchain/community/document_loaders/web/notionapi'
import { getCredentialData, getCredentialParam } from '../../../src'
import { getCredentialData, getCredentialParam, handleEscapeCharacters, INodeOutputsValue } from '../../../src'
class NotionPage_DocumentLoaders implements INode {
label: string
@@ -15,11 +15,12 @@ class NotionPage_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Notion Page'
this.name = 'notionPage'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'notion-page.svg'
this.category = 'Document Loaders'
@@ -65,6 +66,20 @@ class NotionPage_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -72,6 +87,7 @@ class NotionPage_DocumentLoaders implements INode {
const pageId = nodeData.inputs?.pageId as string
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -130,7 +146,15 @@ class NotionPage_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -2,7 +2,7 @@ import { omit } from 'lodash'
import { IDocument, ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf'
import { getFileFromStorage } from '../../../src'
import { getFileFromStorage, handleEscapeCharacters, INodeOutputsValue } from '../../../src'
class Pdf_DocumentLoaders implements INode {
label: string
@@ -14,11 +14,12 @@ class Pdf_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Pdf File'
this.name = 'pdfFile'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'pdf.svg'
this.category = 'Document Loaders'
@@ -80,6 +81,20 @@ class Pdf_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -89,6 +104,7 @@ class Pdf_DocumentLoaders implements INode {
const metadata = nodeData.inputs?.metadata
const legacyBuild = nodeData.inputs?.legacyBuild as boolean
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -162,7 +178,15 @@ class Pdf_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
private async extractDocs(usage: string, bf: Buffer, legacyBuild: boolean, textSplitter: TextSplitter, docs: IDocument[]) {
@@ -8,7 +8,7 @@ import {
PlaywrightWebBaseLoaderOptions
} from '@langchain/community/document_loaders/web/playwright'
import { test } from 'linkifyjs'
import { webCrawl, xmlScrape } from '../../../src'
import { handleEscapeCharacters, INodeOutputsValue, webCrawl, xmlScrape } from '../../../src'
class Playwright_DocumentLoaders implements INode {
label: string
@@ -20,11 +20,12 @@ class Playwright_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Playwright Web Scraper'
this.name = 'playwrightWebScraper'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'playwright.svg'
this.category = 'Document Loaders'
@@ -132,6 +133,20 @@ class Playwright_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -143,6 +158,7 @@ class Playwright_DocumentLoaders implements INode {
let waitUntilGoToOption = nodeData.inputs?.waitUntilGoToOption as 'load' | 'domcontentloaded' | 'networkidle' | 'commit' | undefined
let waitForSelector = nodeData.inputs?.waitForSelector as string
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -251,7 +267,15 @@ class Playwright_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -3,7 +3,7 @@ import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../.
import { TextSplitter } from 'langchain/text_splitter'
import { Browser, Page, PuppeteerWebBaseLoader, PuppeteerWebBaseLoaderOptions } from '@langchain/community/document_loaders/web/puppeteer'
import { test } from 'linkifyjs'
import { webCrawl, xmlScrape } from '../../../src'
import { handleEscapeCharacters, INodeOutputsValue, webCrawl, xmlScrape } from '../../../src'
import { PuppeteerLifeCycleEvent } from 'puppeteer'
class Puppeteer_DocumentLoaders implements INode {
@@ -16,11 +16,12 @@ class Puppeteer_DocumentLoaders implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Puppeteer Web Scraper'
this.name = 'puppeteerWebScraper'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'puppeteer.svg'
this.category = 'Document Loaders'
@@ -128,6 +129,20 @@ class Puppeteer_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -139,6 +154,7 @@ class Puppeteer_DocumentLoaders implements INode {
let waitUntilGoToOption = nodeData.inputs?.waitUntilGoToOption as PuppeteerLifeCycleEvent
let waitForSelector = nodeData.inputs?.waitForSelector as string
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -247,7 +263,15 @@ class Puppeteer_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,6 +1,6 @@
import { omit } from 'lodash'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getCredentialData, getCredentialParam } from '../../../src/utils'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
import { S3Client, GetObjectCommand, S3ClientConfig, ListObjectsV2Command, ListObjectsV2Output } from '@aws-sdk/client-s3'
import { getRegions, MODEL_TYPE } from '../../../src/modelLoader'
import { Readable } from 'node:stream'
@@ -27,11 +27,12 @@ class S3_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs?: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'S3 Directory'
this.name = 's3Directory'
this.version = 3.0
this.version = 4.0
this.type = 'Document'
this.icon = 's3.svg'
this.category = 'Document Loaders'
@@ -117,6 +118,20 @@ class S3_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
loadMethods = {
@@ -134,6 +149,7 @@ class S3_DocumentLoaders implements INode {
const pdfUsage = nodeData.inputs?.pdfUsage
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -313,7 +329,15 @@ class S3_DocumentLoaders implements INode {
// remove the temp directory before returning docs
fsDefault.rmSync(tempDir, { recursive: true })
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
} catch (e: any) {
fsDefault.rmSync(tempDir, { recursive: true })
throw new Error(`Failed to load data from bucket ${bucketName}: ${e.message}`)
@@ -1,5 +1,5 @@
import { omit } from 'lodash'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { S3Loader } from '@langchain/community/document_loaders/web/s3'
import {
UnstructuredLoader,
@@ -8,7 +8,7 @@ import {
SkipInferTableTypes,
HiResModelName
} from '@langchain/community/document_loaders/fs/unstructured'
import { getCredentialData, getCredentialParam } from '../../../src/utils'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
import { S3Client, GetObjectCommand, S3ClientConfig } from '@aws-sdk/client-s3'
import { getRegions, MODEL_TYPE } from '../../../src/modelLoader'
import { Readable } from 'node:stream'
@@ -27,11 +27,12 @@ class S3_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs?: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'S3'
this.name = 'S3'
this.version = 3.0
this.version = 4.0
this.type = 'Document'
this.icon = 's3.svg'
this.category = 'Document Loaders'
@@ -434,6 +435,20 @@ class S3_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
loadMethods = {
@@ -466,6 +481,7 @@ class S3_DocumentLoaders implements INode {
const newAfterNChars = nodeData.inputs?.newAfterNChars as number
const maxCharacters = nodeData.inputs?.maxCharacters as number
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -594,7 +610,15 @@ class S3_DocumentLoaders implements INode {
fsDefault.rmSync(path.dirname(filePath), { recursive: true })
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
} catch {
fsDefault.rmSync(path.dirname(filePath), { recursive: true })
throw new Error(`Failed to load file ${filePath} using unstructured loader.`)
@@ -2,7 +2,7 @@ import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { SearchApiLoader } from '@langchain/community/document_loaders/web/searchapi'
import { getCredentialData, getCredentialParam } from '../../../src'
import { getCredentialData, getCredentialParam, handleEscapeCharacters, INodeOutputsValue } from '../../../src'
// Provides access to multiple search engines using the SearchApi.
// For available parameters & engines, refer to: https://www.searchapi.io/docs/google
@@ -17,11 +17,12 @@ class SearchAPI_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'SearchApi For Web Search'
this.name = 'searchApi'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'searchapi.svg'
this.category = 'Document Loaders'
@@ -74,6 +75,20 @@ class SearchAPI_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -82,6 +97,7 @@ class SearchAPI_DocumentLoaders implements INode {
const customParameters = nodeData.inputs?.customParameters
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -146,7 +162,15 @@ class SearchAPI_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,8 +1,8 @@
import { omit } from 'lodash'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { SerpAPILoader } from '@langchain/community/document_loaders/web/serpapi'
import { getCredentialData, getCredentialParam } from '../../../src'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src'
import { ICommonObject, IDocument, INode, INodeData, INodeParams, INodeOutputsValue } from '../../../src/Interface'
class SerpAPI_DocumentLoaders implements INode {
label: string
@@ -15,11 +15,12 @@ class SerpAPI_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'SerpApi For Web Search'
this.name = 'serpApi'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'serp.svg'
this.category = 'Document Loaders'
@@ -64,6 +65,20 @@ class SerpAPI_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -71,6 +86,7 @@ class SerpAPI_DocumentLoaders implements INode {
const query = nodeData.inputs?.query as string
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -121,7 +137,15 @@ class SerpAPI_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -2,8 +2,8 @@ import { omit } from 'lodash'
import { TextSplitter } from 'langchain/text_splitter'
import { Document, DocumentInterface } from '@langchain/core/documents'
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
import { INode, INodeData, INodeParams, ICommonObject } from '../../../src/Interface'
import { getCredentialData, getCredentialParam } from '../../../src/utils'
import { INode, INodeData, INodeParams, ICommonObject, INodeOutputsValue } from '../../../src/Interface'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
import SpiderApp from './SpiderApp'
interface SpiderLoaderParameters {
@@ -85,11 +85,12 @@ class Spider_DocumentLoaders implements INode {
baseClasses: string[]
inputs: INodeParams[]
credential: INodeParams
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Spider Document Loaders'
this.name = 'spiderDocumentLoaders'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'spider.svg'
this.category = 'Document Loaders'
@@ -168,6 +169,20 @@ class Spider_DocumentLoaders implements INode {
type: 'credential',
credentialNames: ['spiderApi']
}
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -180,6 +195,7 @@ class Spider_DocumentLoaders implements INode {
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const spiderApiKey = getCredentialParam('spiderApiKey', credentialData, nodeData)
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -244,7 +260,15 @@ class Spider_DocumentLoaders implements INode {
)
}))
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -7,8 +7,8 @@ import {
HiResModelName,
UnstructuredLoader as LCUnstructuredLoader
} from '@langchain/community/document_loaders/fs/unstructured'
import { getCredentialData, getCredentialParam } from '../../../src/utils'
import { getFileFromStorage } from '../../../src'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
import { getFileFromStorage, INodeOutputsValue } from '../../../src'
import { UnstructuredLoader } from './Unstructured'
class UnstructuredFile_DocumentLoaders implements INode {
@@ -22,6 +22,7 @@ class UnstructuredFile_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Unstructured File Loader'
@@ -434,6 +435,20 @@ class UnstructuredFile_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -457,6 +472,7 @@ class UnstructuredFile_DocumentLoaders implements INode {
const newAfterNChars = nodeData.inputs?.newAfterNChars as string
const maxCharacters = nodeData.inputs?.maxCharacters as string
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -582,7 +598,15 @@ class UnstructuredFile_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1,5 +1,5 @@
import { omit } from 'lodash'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import {
UnstructuredDirectoryLoader,
UnstructuredLoaderOptions,
@@ -7,7 +7,7 @@ import {
SkipInferTableTypes,
HiResModelName
} from '@langchain/community/document_loaders/fs/unstructured'
import { getCredentialData, getCredentialParam } from '../../../src/utils'
import { getCredentialData, getCredentialParam, handleEscapeCharacters } from '../../../src/utils'
class UnstructuredFolder_DocumentLoaders implements INode {
label: string
@@ -20,11 +20,12 @@ class UnstructuredFolder_DocumentLoaders implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
outputs: INodeOutputsValue[]
constructor() {
this.label = 'Unstructured Folder Loader'
this.name = 'unstructuredFolderLoader'
this.version = 2.0
this.version = 3.0
this.type = 'Document'
this.icon = 'unstructured-folder.svg'
this.category = 'Document Loaders'
@@ -400,6 +401,20 @@ class UnstructuredFolder_DocumentLoaders implements INode {
additionalParams: true
}
]
this.outputs = [
{
label: 'Document',
name: 'document',
description: 'Array of document objects containing metadata and pageContent',
baseClasses: [...this.baseClasses, 'json']
},
{
label: 'Text',
name: 'text',
description: 'Concatenated string from pageContent of documents',
baseClasses: ['string', 'json']
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
@@ -423,6 +438,7 @@ class UnstructuredFolder_DocumentLoaders implements INode {
const newAfterNChars = nodeData.inputs?.newAfterNChars as number
const maxCharacters = nodeData.inputs?.maxCharacters as number
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string
const output = nodeData.outputs?.output as string
let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
@@ -487,7 +503,15 @@ class UnstructuredFolder_DocumentLoaders implements INode {
}))
}
return docs
if (output === 'document') {
return docs
} else {
let finaltext = ''
for (const doc of docs) {
finaltext += `${doc.pageContent}\n`
}
return handleEscapeCharacters(finaltext, false)
}
}
}
@@ -1 +0,0 @@
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.991 28.555c1.064 0 1.926-.624 1.926-1.394V15.074h-3.852v12.087c0 .77.862 1.394 1.926 1.394Z" fill="#F9AB00" stroke="#F9AB00"/><path d="M23.01 16.825a6.301 6.301 0 0 0-6.606-1.467c-.322.117-.39.525-.148.767l7.294 7.294a.61.61 0 0 0 1.01-.238 6.3 6.3 0 0 0-1.55-6.356Z" fill="#5BB974" stroke="#5BB974"/><path d="M8.516 16.825a6.301 6.301 0 0 1 6.606-1.467c.322.117.39.525.148.767l-7.294 7.294a.61.61 0 0 1-1.01-.238 6.3 6.3 0 0 1 1.55-6.356Z" fill="#129EAF" stroke="#129EAF"/><path d="M22.433 10.781c-2.856 0-5.314 1.726-6.419 4.204-.139.312.102.647.443.647h11.62a.681.681 0 0 0 .613-.984c-1.17-2.296-3.532-3.867-6.258-3.867Z" fill="#AF5CF7" stroke="#AF5CF7"/><path d="M17.05 7.486c-2.02 2.02-2.538 4.977-1.567 7.51.122.32.53.386.77.145l8.218-8.217a.681.681 0 0 0-.262-1.13c-2.453-.795-5.233-.235-7.16 1.692Z" fill="#FF8BCB" stroke="#FF8BCB"/><path d="M14.476 7.486c2.02 2.02 2.538 4.977 1.566 7.51-.122.32-.529.386-.77.145L7.055 6.924a.681.681 0 0 1 .262-1.13C9.769 5 12.549 5.56 14.476 7.486Z" fill="#FA7B17" stroke="#FA7B17"/><path d="M9.093 10.781c2.856 0 5.314 1.726 6.418 4.204.14.312-.1.647-.442.647H3.449a.681.681 0 0 1-.613-.984c1.17-2.296 3.532-3.867 6.257-3.867Z" fill="#4285F4" stroke="#4285F4"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

@@ -1,67 +0,0 @@
import { GooglePaLMEmbeddings, GooglePaLMEmbeddingsParams } from '@langchain/community/embeddings/googlepalm'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
class GooglePaLMEmbedding_Embeddings implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'Google PaLM Embeddings'
this.name = 'googlePaLMEmbeddings'
this.version = 2.0
this.type = 'GooglePaLMEmbeddings'
this.icon = 'GooglePaLM.svg'
this.category = 'Embeddings'
this.description = 'Google MakerSuite PaLM API to generate embeddings for a given text'
this.baseClasses = [this.type, ...getBaseClasses(GooglePaLMEmbeddings)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['googleMakerSuite']
}
this.inputs = [
{
label: 'Model Name',
name: 'modelName',
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'models/embedding-gecko-001'
}
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.EMBEDDING, 'googlePaLMEmbeddings')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const googleMakerSuiteKey = getCredentialParam('googleMakerSuiteKey', credentialData, nodeData)
const obj: Partial<GooglePaLMEmbeddingsParams> = {
modelName: modelName,
apiKey: googleMakerSuiteKey
}
const model = new GooglePaLMEmbeddings(obj)
return model
}
}
module.exports = { nodeClass: GooglePaLMEmbedding_Embeddings }
@@ -1,5 +1,4 @@
import { GoogleAuthOptions } from 'google-auth-library'
import { GoogleVertexAIEmbeddings, GoogleVertexAIEmbeddingsParams } from '@langchain/community/embeddings/googlevertexai'
import { VertexAIEmbeddings, GoogleVertexAIEmbeddingsInput } from '@langchain/google-vertexai'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
@@ -24,7 +23,7 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
this.icon = 'GoogleVertex.svg'
this.category = 'Embeddings'
this.description = 'Google vertexAI API to generate embeddings for a given text'
this.baseClasses = [this.type, ...getBaseClasses(GoogleVertexAIEmbeddings)]
this.baseClasses = [this.type, ...getBaseClasses(VertexAIEmbeddings)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
@@ -59,7 +58,7 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
const projectID = getCredentialParam('projectID', credentialData, nodeData)
const authOptions: GoogleAuthOptions = {}
const authOptions: any = {}
if (Object.keys(credentialData).length !== 0) {
if (!googleApplicationCredentialFilePath && !googleApplicationCredential)
throw new Error('Please specify your Google Application Credential')
@@ -75,11 +74,12 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
if (projectID) authOptions.projectId = projectID
}
const obj: GoogleVertexAIEmbeddingsParams = {}
if (modelName) obj.model = modelName
const obj: GoogleVertexAIEmbeddingsInput = {
model: modelName
}
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
const model = new GoogleVertexAIEmbeddings(obj)
const model = new VertexAIEmbeddings(obj)
return model
}
}
@@ -1 +0,0 @@
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.991 28.555c1.064 0 1.926-.624 1.926-1.394V15.074h-3.852v12.087c0 .77.862 1.394 1.926 1.394Z" fill="#F9AB00" stroke="#F9AB00"/><path d="M23.01 16.825a6.301 6.301 0 0 0-6.606-1.467c-.322.117-.39.525-.148.767l7.294 7.294a.61.61 0 0 0 1.01-.238 6.3 6.3 0 0 0-1.55-6.356Z" fill="#5BB974" stroke="#5BB974"/><path d="M8.516 16.825a6.301 6.301 0 0 1 6.606-1.467c.322.117.39.525.148.767l-7.294 7.294a.61.61 0 0 1-1.01-.238 6.3 6.3 0 0 1 1.55-6.356Z" fill="#129EAF" stroke="#129EAF"/><path d="M22.433 10.781c-2.856 0-5.314 1.726-6.419 4.204-.139.312.102.647.443.647h11.62a.681.681 0 0 0 .613-.984c-1.17-2.296-3.532-3.867-6.258-3.867Z" fill="#AF5CF7" stroke="#AF5CF7"/><path d="M17.05 7.486c-2.02 2.02-2.538 4.977-1.567 7.51.122.32.53.386.77.145l8.218-8.217a.681.681 0 0 0-.262-1.13c-2.453-.795-5.233-.235-7.16 1.692Z" fill="#FF8BCB" stroke="#FF8BCB"/><path d="M14.476 7.486c2.02 2.02 2.538 4.977 1.566 7.51-.122.32-.529.386-.77.145L7.055 6.924a.681.681 0 0 1 .262-1.13C9.769 5 12.549 5.56 14.476 7.486Z" fill="#FA7B17" stroke="#FA7B17"/><path d="M9.093 10.781c2.856 0 5.314 1.726 6.418 4.204.14.312-.1.647-.442.647H3.449a.681.681 0 0 1-.613-.984c1.17-2.296 3.532-3.867 6.257-3.867Z" fill="#4285F4" stroke="#4285F4"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

@@ -1,169 +0,0 @@
import { GooglePaLM, GooglePaLMTextInput } from '@langchain/community/llms/googlepalm'
import { BaseCache } from '@langchain/core/caches'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
class GooglePaLM_LLMs implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'GooglePaLM'
this.name = 'GooglePaLM'
this.version = 3.0
this.type = 'GooglePaLM'
this.icon = 'GooglePaLM.svg'
this.category = 'LLMs'
this.description = 'Wrapper around Google MakerSuite PaLM large language models'
this.baseClasses = [this.type, ...getBaseClasses(GooglePaLM)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['googleMakerSuite']
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model Name',
name: 'modelName',
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'models/text-bison-001'
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
default: 0.7,
optional: true,
description:
'Controls the randomness of the output.\n' +
'Values can range from [0.0,1.0], inclusive. A value closer to 1.0 ' +
'will produce responses that are more varied and creative, while ' +
'a value closer to 0.0 will typically result in more straightforward ' +
'responses from the model.'
},
{
label: 'Max Output Tokens',
name: 'maxOutputTokens',
type: 'number',
step: 1,
optional: true,
additionalParams: true,
description: 'Maximum number of tokens to generate in the completion.'
},
{
label: 'Top Probability',
name: 'topP',
type: 'number',
step: 0.1,
optional: true,
additionalParams: true,
description:
'Top-p changes how the model selects tokens for output.\n' +
'Tokens are selected from most probable to least until ' +
'the sum of their probabilities equals the top-p value.\n' +
'For example, if tokens A, B, and C have a probability of .3, .2, and .1 ' +
'and the top-p value is .5, then the model will select either A or B ' +
'as the next token (using temperature).'
},
{
label: 'Top-k',
name: 'topK',
type: 'number',
step: 1,
optional: true,
additionalParams: true,
description:
'Top-k changes how the model selects tokens for output.\n' +
'A top-k of 1 means the selected token is the most probable among ' +
'all tokens in the model vocabulary (also called greedy decoding), ' +
'while a top-k of 3 means that the next token is selected from ' +
'among the 3 most probable tokens (using temperature).'
},
{
label: 'Stop Sequences',
name: 'stopSequencesObj',
type: 'json',
optional: true,
additionalParams: true
//default: { list:[] },
//description:
// 'The "list" field should contain a list of character strings (up to 5) that will stop output generation.\n' +
// ' * If specified, the API will stop at the first appearance of a stop sequence.\n' +
// 'Note: The stop sequence will not be included as part of the response.'
}
/*
{
label: 'Safety Settings',
name: 'safetySettings',
type: 'json',
optional: true,
additionalParams: true
}
*/
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.LLM, 'GooglePaLM')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string
const temperature = nodeData.inputs?.temperature as string
const maxOutputTokens = nodeData.inputs?.maxOutputTokens as string
const topP = nodeData.inputs?.topP as string
const topK = nodeData.inputs?.topK as string
const stopSequencesObj = nodeData.inputs?.stopSequencesObj
const cache = nodeData.inputs?.cache as BaseCache
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const googleMakerSuiteKey = getCredentialParam('googleMakerSuiteKey', credentialData, nodeData)
const obj: Partial<GooglePaLMTextInput> = {
modelName: modelName,
temperature: parseFloat(temperature),
apiKey: googleMakerSuiteKey
}
if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10)
if (topP) obj.topP = parseFloat(topP)
if (topK) obj.topK = parseFloat(topK)
if (cache) obj.cache = cache
let parsedStopSequences: any | undefined = undefined
if (stopSequencesObj) {
try {
parsedStopSequences = typeof stopSequencesObj === 'object' ? stopSequencesObj : JSON.parse(stopSequencesObj)
obj.stopSequences = parsedStopSequences.list || []
} catch (exception) {
throw new Error("Invalid JSON in the GooglePaLM's stopSequences: " + exception)
}
}
const model = new GooglePaLM(obj)
return model
}
}
module.exports = { nodeClass: GooglePaLM_LLMs }
@@ -1,6 +1,5 @@
import { GoogleAuthOptions } from 'google-auth-library'
import { BaseCache } from '@langchain/core/caches'
import { GoogleVertexAI, GoogleVertexAITextInput } from '@langchain/community/llms/googlevertexai'
import { VertexAI, VertexAIInput } from '@langchain/google-vertexai'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
@@ -25,7 +24,7 @@ class GoogleVertexAI_LLMs implements INode {
this.icon = 'GoogleVertex.svg'
this.category = 'LLMs'
this.description = 'Wrapper around GoogleVertexAI large language models'
this.baseClasses = [this.type, ...getBaseClasses(GoogleVertexAI)]
this.baseClasses = [this.type, ...getBaseClasses(VertexAI)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
@@ -89,7 +88,7 @@ class GoogleVertexAI_LLMs implements INode {
const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
const projectID = getCredentialParam('projectID', credentialData, nodeData)
const authOptions: GoogleAuthOptions = {}
const authOptions: any = {}
if (Object.keys(credentialData).length !== 0) {
if (!googleApplicationCredentialFilePath && !googleApplicationCredential)
throw new Error('Please specify your Google Application Credential')
@@ -112,7 +111,7 @@ class GoogleVertexAI_LLMs implements INode {
const topP = nodeData.inputs?.topP as string
const cache = nodeData.inputs?.cache as BaseCache
const obj: Partial<GoogleVertexAITextInput> = {
const obj: Partial<VertexAIInput> = {
temperature: parseFloat(temperature),
model: modelName
}
@@ -122,7 +121,7 @@ class GoogleVertexAI_LLMs implements INode {
if (topP) obj.topP = parseFloat(topP)
if (cache) obj.cache = cache
const model = new GoogleVertexAI(obj)
const model = new VertexAI(obj)
return model
}
}
@@ -15,7 +15,6 @@ class AWSBedrockKBRetriever_Retrievers implements INode {
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
badge: string
constructor() {
this.label = 'AWS Bedrock Knowledge Base Retriever'
@@ -24,7 +23,6 @@ class AWSBedrockKBRetriever_Retrievers implements INode {
this.type = 'AWSBedrockKBRetriever'
this.icon = 'AWSBedrockKBRetriever.svg'
this.category = 'Retrievers'
this.badge = 'NEW'
this.description = 'Connect to AWS Bedrock Knowledge Base API and retrieve relevant chunks'
this.baseClasses = [this.type, 'BaseRetriever']
this.credential = {
@@ -12,7 +12,6 @@ class DocStore_VectorStores implements INode {
baseClasses: string[]
inputs: INodeParams[]
outputs: INodeOutputsValue[]
badge: string
constructor() {
this.label = 'Document Store (Vector)'
@@ -20,7 +19,6 @@ class DocStore_VectorStores implements INode {
this.version = 1.0
this.type = 'DocumentStoreVS'
this.icon = 'dstore.svg'
this.badge = 'New'
this.category = 'Vector Stores'
this.description = `Search and retrieve documents from Document Store`
this.baseClasses = [this.type]
@@ -18,7 +18,6 @@ class MeilisearchRetriever_node implements INode {
baseClasses: string[]
inputs: INodeParams[]
credential: INodeParams
badge: string
outputs: INodeOutputsValue[]
author?: string
@@ -29,7 +28,6 @@ class MeilisearchRetriever_node implements INode {
this.type = 'Meilisearch'
this.icon = 'Meilisearch.png'
this.category = 'Vector Stores'
this.badge = 'NEW'
this.description = `Upsert embedded data and perform similarity search upon query using Meilisearch hybrid search functionality`
this.baseClasses = ['BaseRetriever']
this.credential = {
+12 -10
View File
@@ -36,23 +36,25 @@
"@google-ai/generativelanguage": "^2.5.0",
"@google/generative-ai": "^0.15.0",
"@huggingface/inference": "^2.6.1",
"@langchain/anthropic": "^0.2.1",
"@langchain/aws": "^0.0.9",
"@langchain/anthropic": "0.3.7",
"@langchain/aws": "0.1.2",
"@langchain/baidu-qianfan": "^0.1.0",
"@langchain/cohere": "^0.0.7",
"@langchain/community": "^0.2.17",
"@langchain/core": "0.2.18",
"@langchain/community": "^0.3.11",
"@langchain/core": "0.3.18",
"@langchain/exa": "^0.0.5",
"@langchain/google-genai": "^0.0.22",
"@langchain/google-vertexai": "^0.0.19",
"@langchain/groq": "^0.0.8",
"@langchain/google-genai": "0.1.3",
"@langchain/google-vertexai": "^0.1.2",
"@langchain/groq": "0.1.2",
"@langchain/langgraph": "^0.0.22",
"@langchain/mistralai": "^0.0.26",
"@langchain/mongodb": "^0.0.1",
"@langchain/ollama": "^0.0.2",
"@langchain/openai": "^0.0.30",
"@langchain/ollama": "0.1.2",
"@langchain/openai": "0.3.13",
"@langchain/pinecone": "^0.0.3",
"@langchain/qdrant": "^0.0.5",
"@langchain/weaviate": "^0.0.1",
"@langchain/xai": "^0.0.1",
"@mendable/firecrawl-js": "^0.0.28",
"@mistralai/mistralai": "0.1.3",
"@notionhq/client": "^2.2.8",
@@ -88,7 +90,7 @@
"ioredis": "^5.3.2",
"jsdom": "^22.1.0",
"jsonpointer": "^5.0.1",
"langchain": "^0.2.11",
"langchain": "^0.3.5",
"langfuse": "3.3.4",
"langfuse-langchain": "^3.3.4",
"langsmith": "0.1.6",
+14 -6
View File
@@ -7,7 +7,7 @@ import { OutputParserException, BaseOutputParser, BaseLLMOutputParser } from '@l
import { BaseLanguageModel } from '@langchain/core/language_models/base'
import { CallbackManager, CallbackManagerForChainRun, Callbacks } from '@langchain/core/callbacks/manager'
import { ToolInputParsingException, Tool, StructuredToolInterface } from '@langchain/core/tools'
import { Runnable, RunnableSequence, RunnablePassthrough } from '@langchain/core/runnables'
import { Runnable, RunnableSequence, RunnablePassthrough, type RunnableConfig } from '@langchain/core/runnables'
import { Serializable } from '@langchain/core/load/serializable'
import { renderTemplate } from '@langchain/core/prompts'
import { ChatGeneration } from '@langchain/core/outputs'
@@ -36,6 +36,7 @@ type AgentExecutorOutput = ChainValues
interface AgentExecutorIteratorInput {
agentExecutor: AgentExecutor
inputs: Record<string, string>
config?: RunnableConfig
callbacks?: Callbacks
tags?: string[]
metadata?: Record<string, unknown>
@@ -51,6 +52,8 @@ export class AgentExecutorIterator extends Serializable implements AgentExecutor
inputs: Record<string, string>
config?: RunnableConfig
callbacks: Callbacks
tags: string[] | undefined
@@ -95,6 +98,7 @@ export class AgentExecutorIterator extends Serializable implements AgentExecutor
this.metadata = fields.metadata
this.runName = fields.runName
this.runManager = fields.runManager
this.config = fields.config
}
/**
@@ -276,6 +280,8 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
*/
handleParsingErrors: boolean | string | ((e: OutputParserException | ToolInputParsingException) => string) = false
handleToolRuntimeErrors?: (e: Error) => string
get inputKeys() {
return this.agent.inputKeys
}
@@ -340,7 +346,7 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
return this.maxIterations === undefined || iterations < this.maxIterations
}
async _call(inputs: ChainValues, runManager?: CallbackManagerForChainRun): Promise<AgentExecutorOutput> {
async _call(inputs: ChainValues, runManager?: CallbackManagerForChainRun, config?: RunnableConfig): Promise<AgentExecutorOutput> {
const toolsByName = Object.fromEntries(this.tools.map((t) => [t.name?.toLowerCase(), t]))
const steps: AgentStep[] = []
@@ -365,7 +371,7 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
while (this.shouldContinue(iterations)) {
let output
try {
output = await this.agent.plan(steps, inputs, runManager?.getChild())
output = await this.agent.plan(steps, inputs, runManager?.getChild(), config)
} catch (e) {
if (e instanceof OutputParserException) {
let observation
@@ -509,11 +515,12 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
nameToolMap: Record<string, Tool>,
inputs: ChainValues,
intermediateSteps: AgentStep[],
runManager?: CallbackManagerForChainRun
runManager?: CallbackManagerForChainRun,
config?: RunnableConfig
): Promise<AgentFinish | AgentStep[]> {
let output
try {
output = await this.agent.plan(intermediateSteps, inputs, runManager?.getChild())
output = await this.agent.plan(intermediateSteps, inputs, runManager?.getChild(), config)
} catch (e) {
if (e instanceof OutputParserException) {
let observation
@@ -656,10 +663,11 @@ export class AgentExecutor extends BaseChain<ChainValues, AgentExecutorOutput> {
throw new Error(`Got unsupported early_stopping_method: ${earlyStoppingMethod}`)
}
async *_streamIterator(inputs: Record<string, any>): AsyncGenerator<ChainValues> {
async *_streamIterator(inputs: Record<string, any>, options?: Partial<RunnableConfig>): AsyncGenerator<ChainValues> {
const agentExecutorIterator = new AgentExecutorIterator({
inputs,
agentExecutor: this,
config: options,
metadata: this.metadata,
tags: this.tags,
callbacks: this.callbacks
+21 -3
View File
@@ -6,7 +6,7 @@ import lunary from 'lunary'
import { RunTree, RunTreeConfig, Client as LangsmithClient } from 'langsmith'
import { Langfuse, LangfuseTraceClient, LangfuseSpanClient, LangfuseGenerationClient } from 'langfuse'
import { BaseCallbackHandler } from '@langchain/core/callbacks/base'
import { BaseCallbackHandler, NewTokenIndices, HandleLLMNewTokenCallbackFields } from '@langchain/core/callbacks/base'
import { LangChainTracer, LangChainTracerFields } from '@langchain/core/tracers/tracer_langchain'
import { BaseTracer, Run } from '@langchain/core/tracers/base'
import { ChainValues } from '@langchain/core/utils/types'
@@ -17,6 +17,8 @@ import { getCredentialData, getCredentialParam, getEnvironmentVariable } from '.
import { ICommonObject, IDatabaseEntity, INodeData, IServerSideEventStreamer } from './Interface'
import { LangWatch, LangWatchSpan, LangWatchTrace, autoconvertTypedValues } from 'langwatch'
import { DataSource } from 'typeorm'
import { ChatGenerationChunk } from '@langchain/core/outputs'
import { AIMessageChunk } from '@langchain/core/messages'
interface AgentRun extends Run {
actions: AgentAction[]
@@ -183,7 +185,14 @@ export class CustomChainHandler extends BaseCallbackHandler {
if (this.skipK > 0) this.skipK -= 1
}
handleLLMNewToken(token: string) {
handleLLMNewToken(
token: string,
idx?: NewTokenIndices,
runId?: string,
parentRunId?: string,
tags?: string[],
fields?: HandleLLMNewTokenCallbackFields
): void | Promise<void> {
if (this.skipK === 0) {
if (!this.isLLMStarted) {
this.isLLMStarted = true
@@ -192,7 +201,16 @@ export class CustomChainHandler extends BaseCallbackHandler {
}
}
if (this.sseStreamer) {
this.sseStreamer.streamTokenEvent(this.chatId, token)
if (token) {
const chunk = fields?.chunk as ChatGenerationChunk
const message = chunk?.message as AIMessageChunk
const toolCalls = message?.tool_call_chunks || []
// Only stream when token is not empty and not a tool call
if (toolCalls.length === 0) {
this.sseStreamer.streamTokenEvent(this.chatId, token)
}
}
}
}
}
@@ -92,11 +92,11 @@ export const utilGetUploadsConfig = async (chatflowid: string): Promise<IUploadC
'supervisor',
'seqStart'
]
const imgUploadLLMNodes = ['chatOpenAI', 'chatAnthropic', 'awsChatBedrock', 'azureChatOpenAI', 'chatGoogleGenerativeAI', 'chatOllama']
if (nodes.some((node) => imgUploadAllowedNodes.includes(node.data.name))) {
nodes.forEach((node: IReactFlowNode) => {
if (imgUploadLLMNodes.indexOf(node.data.name) > -1) {
const data = node.data
if (data.category === 'Chat Models' && data.inputs?.['allowImageUploads'] === true) {
// TODO: for now the maxUploadSize is hardcoded to 5MB, we need to add it to the node properties
node.data.inputParams.map((param: INodeParams) => {
if (param.name === 'allowImageUploads' && node.data.inputs?.['allowImageUploads']) {
+14 -24
View File
@@ -1269,6 +1269,7 @@ export const findAvailableConfigs = (reactFlowNodes: IReactFlowNode[], component
* @returns {boolean}
*/
export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNodeData: INodeData) => {
/** Deprecated, add streaming input param to the component instead **/
const streamAvailableLLMs = {
'Chat Models': [
'azureChatOpenAI',
@@ -1299,9 +1300,18 @@ export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNod
for (const flowNode of reactFlowNodes) {
const data = flowNode.data
if (data.category === 'Chat Models' || data.category === 'LLMs') {
isChatOrLLMsExist = true
const validLLMs = streamAvailableLLMs[data.category]
if (!validLLMs.includes(data.name)) return false
if (data.inputs?.streaming === false || data.inputs?.streaming === 'false') {
return false
}
if (data.inputs?.streaming === true || data.inputs?.streaming === 'true') {
isChatOrLLMsExist = true // passed, proceed to next check
}
/** Deprecated, add streaming input param to the component instead **/
if (!Object.prototype.hasOwnProperty.call(data.inputs, 'streaming') && !data.inputs?.streaming) {
isChatOrLLMsExist = true
const validLLMs = streamAvailableLLMs[data.category]
if (!validLLMs.includes(data.name)) return false
}
}
}
@@ -1312,29 +1322,9 @@ export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNod
isValidChainOrAgent = !blacklistChains.includes(endingNodeData.name)
} else if (endingNodeData.category === 'Agents') {
// Agent that are available to stream
const whitelistAgents = [
'openAIFunctionAgent',
'mistralAIToolAgent',
'csvAgent',
'airtableAgent',
'conversationalRetrievalAgent',
'openAIToolAgent',
'toolAgent',
'conversationalRetrievalToolAgent',
'openAIToolAgentLlamaIndex'
]
const whitelistAgents = ['csvAgent', 'airtableAgent', 'toolAgent', 'conversationalRetrievalToolAgent', 'openAIToolAgentLlamaIndex']
isValidChainOrAgent = whitelistAgents.includes(endingNodeData.name)
// Anthropic streaming has some bug where the log is being sent, temporarily disabled
const model = endingNodeData.inputs?.model
if (endingNodeData.name.includes('toolAgent')) {
if (typeof model === 'string' && model.includes('chatAnthropic')) {
return false
} else if (typeof model === 'object' && 'id' in model && model['id'].includes('chatAnthropic')) {
return false
}
}
// If agent is openAIAssistant, streaming is enabled
if (endingNodeData.name === 'openAIAssistant') return true
} else if (endingNodeData.category === 'Engine') {
+924 -865
View File
File diff suppressed because it is too large Load Diff