mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 05:01:10 +03:00
Merge branch 'main' of github.com:0xi4o/Flowise into feature/chat-message-feedback
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||||
|
|
||||||
|
class GroqApi implements INodeCredential {
|
||||||
|
label: string
|
||||||
|
name: string
|
||||||
|
version: number
|
||||||
|
inputs: INodeParams[]
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.label = 'Groq API'
|
||||||
|
this.name = 'groqApi'
|
||||||
|
this.version = 1.0
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'Groq Api Key',
|
||||||
|
name: 'groqApiKey',
|
||||||
|
type: 'password'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { credClass: GroqApi }
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
import { flatten } from 'lodash'
|
import { flatten } from 'lodash'
|
||||||
import { AgentExecutor } from 'langchain/agents'
|
import { AgentExecutor } from 'langchain/agents'
|
||||||
import { pull } from 'langchain/hub'
|
import { HumanMessage } from '@langchain/core/messages'
|
||||||
|
import { ChatPromptTemplate, HumanMessagePromptTemplate } from '@langchain/core/prompts'
|
||||||
import { Tool } from '@langchain/core/tools'
|
import { Tool } from '@langchain/core/tools'
|
||||||
import type { PromptTemplate } from '@langchain/core/prompts'
|
import type { PromptTemplate } from '@langchain/core/prompts'
|
||||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||||
|
import { pull } from 'langchain/hub'
|
||||||
import { additionalCallbacks } from '../../../src/handler'
|
import { additionalCallbacks } from '../../../src/handler'
|
||||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { createReactAgent } from '../../../src/agents'
|
import { createReactAgent } from '../../../src/agents'
|
||||||
import { ChatOpenAI } from '../../chatmodels/ChatOpenAI/FlowiseChatOpenAI'
|
import { ChatOpenAI } from '../../chatmodels/ChatOpenAI/FlowiseChatOpenAI'
|
||||||
import { HumanMessage } from '@langchain/core/messages'
|
|
||||||
import { addImagesToMessages } from '../../../src/multiModalUtils'
|
import { addImagesToMessages } from '../../../src/multiModalUtils'
|
||||||
import { ChatPromptTemplate, HumanMessagePromptTemplate } from 'langchain/prompts'
|
|
||||||
|
|
||||||
class MRKLAgentChat_Agents implements INode {
|
class MRKLAgentChat_Agents implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { AgentExecutor } from 'langchain/agents'
|
|||||||
import { pull } from 'langchain/hub'
|
import { pull } from 'langchain/hub'
|
||||||
import { Tool } from '@langchain/core/tools'
|
import { Tool } from '@langchain/core/tools'
|
||||||
import type { PromptTemplate } from '@langchain/core/prompts'
|
import type { PromptTemplate } from '@langchain/core/prompts'
|
||||||
import { BaseLanguageModel } from 'langchain/base_language'
|
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||||
import { additionalCallbacks } from '../../../src/handler'
|
import { additionalCallbacks } from '../../../src/handler'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { BaseLanguageModel, BaseLanguageModelCallOptions } from '@langchain/core/language_models/base'
|
import { BaseLanguageModel, BaseLanguageModelCallOptions } from '@langchain/core/language_models/base'
|
||||||
import { BaseLLMOutputParser, BaseOutputParser } from '@langchain/core/output_parsers'
|
import { BaseLLMOutputParser, BaseOutputParser } from '@langchain/core/output_parsers'
|
||||||
|
import { HumanMessage } from '@langchain/core/messages'
|
||||||
import { ChatPromptTemplate, FewShotPromptTemplate, PromptTemplate, HumanMessagePromptTemplate } from '@langchain/core/prompts'
|
import { ChatPromptTemplate, FewShotPromptTemplate, PromptTemplate, HumanMessagePromptTemplate } from '@langchain/core/prompts'
|
||||||
import { OutputFixingParser } from 'langchain/output_parsers'
|
import { OutputFixingParser } from 'langchain/output_parsers'
|
||||||
import { LLMChain } from 'langchain/chains'
|
import { LLMChain } from 'langchain/chains'
|
||||||
@@ -10,7 +11,6 @@ import { checkInputs, Moderation, streamResponse } from '../../moderation/Modera
|
|||||||
import { formatResponse, injectOutputParser } from '../../outputparsers/OutputParserHelpers'
|
import { formatResponse, injectOutputParser } from '../../outputparsers/OutputParserHelpers'
|
||||||
import { ChatOpenAI } from '../../chatmodels/ChatOpenAI/FlowiseChatOpenAI'
|
import { ChatOpenAI } from '../../chatmodels/ChatOpenAI/FlowiseChatOpenAI'
|
||||||
import { addImagesToMessages } from '../../../src/multiModalUtils'
|
import { addImagesToMessages } from '../../../src/multiModalUtils'
|
||||||
import { HumanMessage } from 'langchain/schema'
|
|
||||||
|
|
||||||
class LLMChain_Chains implements INode {
|
class LLMChain_Chains implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class ChatMistral_ChatModels implements INode {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'ChatMistralAI'
|
this.label = 'ChatMistralAI'
|
||||||
this.name = 'chatMistralAI'
|
this.name = 'chatMistralAI'
|
||||||
this.version = 1.0
|
this.version = 2.0
|
||||||
this.type = 'ChatMistralAI'
|
this.type = 'ChatMistralAI'
|
||||||
this.icon = 'MistralAI.svg'
|
this.icon = 'MistralAI.svg'
|
||||||
this.category = 'Chat Models'
|
this.category = 'Chat Models'
|
||||||
@@ -40,21 +40,9 @@ class ChatMistral_ChatModels implements INode {
|
|||||||
{
|
{
|
||||||
label: 'Model Name',
|
label: 'Model Name',
|
||||||
name: 'modelName',
|
name: 'modelName',
|
||||||
type: 'options',
|
type: 'string',
|
||||||
options: [
|
description:
|
||||||
{
|
'Refer to <a target="_blank" href="https://docs.mistral.ai/guides/model-selection/">Model Selection</a> for more available models',
|
||||||
label: 'mistral-tiny',
|
|
||||||
name: 'mistral-tiny'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'mistral-small',
|
|
||||||
name: 'mistral-small'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'mistral-medium',
|
|
||||||
name: 'mistral-medium'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
default: 'mistral-tiny'
|
default: 'mistral-tiny'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import {
|
|||||||
ChatOpenAICallOptions
|
ChatOpenAICallOptions
|
||||||
} from '@langchain/openai'
|
} from '@langchain/openai'
|
||||||
import { BaseChatModelParams } from '@langchain/core/language_models/chat_models'
|
import { BaseChatModelParams } from '@langchain/core/language_models/chat_models'
|
||||||
import { IMultiModalOption } from '../../../src'
|
import { BaseMessageLike } from '@langchain/core/messages'
|
||||||
import { BaseMessageLike, LLMResult } from 'langchain/schema'
|
|
||||||
import { Callbacks } from '@langchain/core/callbacks/manager'
|
import { Callbacks } from '@langchain/core/callbacks/manager'
|
||||||
|
import { LLMResult } from '@langchain/core/outputs'
|
||||||
|
import { IMultiModalOption } from '../../../src'
|
||||||
|
|
||||||
export class ChatOpenAI extends LangchainChatOpenAI {
|
export class ChatOpenAI extends LangchainChatOpenAI {
|
||||||
configuredModel: string
|
configuredModel: string
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import { BaseCache } from '@langchain/core/caches'
|
||||||
|
import { ChatGroq, ChatGroqInput } from '@langchain/groq'
|
||||||
|
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||||
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
|
|
||||||
|
class Groq_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 = 'GroqChat'
|
||||||
|
this.name = 'groqChat'
|
||||||
|
this.version = 2.0
|
||||||
|
this.type = 'GroqChat'
|
||||||
|
this.icon = 'groq.png'
|
||||||
|
this.category = 'Chat Models'
|
||||||
|
this.description = 'Wrapper around Groq API with LPU Inference Engine'
|
||||||
|
this.baseClasses = [this.type, ...getBaseClasses(ChatGroq)]
|
||||||
|
this.credential = {
|
||||||
|
label: 'Connect Credential',
|
||||||
|
name: 'credential',
|
||||||
|
type: 'credential',
|
||||||
|
credentialNames: ['groqApi'],
|
||||||
|
optional: true
|
||||||
|
}
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'Cache',
|
||||||
|
name: 'cache',
|
||||||
|
type: 'BaseCache',
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Model Name',
|
||||||
|
name: 'modelName',
|
||||||
|
type: 'string',
|
||||||
|
placeholder: 'ft:gpt-3.5-turbo:my-org:custom_suffix:id'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Temperature',
|
||||||
|
name: 'temperature',
|
||||||
|
type: 'number',
|
||||||
|
step: 0.1,
|
||||||
|
default: 0.9,
|
||||||
|
optional: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
|
const modelName = nodeData.inputs?.modelName as string
|
||||||
|
const cache = nodeData.inputs?.cache as BaseCache
|
||||||
|
const temperature = nodeData.inputs?.temperature as string
|
||||||
|
const streaming = nodeData.inputs?.streaming as boolean
|
||||||
|
|
||||||
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
|
const groqApiKey = getCredentialParam('groqApiKey', credentialData, nodeData)
|
||||||
|
|
||||||
|
const obj: ChatGroqInput = {
|
||||||
|
modelName,
|
||||||
|
temperature: parseFloat(temperature),
|
||||||
|
apiKey: groqApiKey,
|
||||||
|
streaming: streaming ?? true
|
||||||
|
}
|
||||||
|
if (cache) obj.cache = cache
|
||||||
|
|
||||||
|
const model = new ChatGroq(obj)
|
||||||
|
return model
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { nodeClass: Groq_ChatModels }
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
import { FlowiseSummaryMemory, IMessage, INode, INodeData, INodeParams, MemoryMethods } from '../../../src/Interface'
|
import { FlowiseSummaryMemory, IMessage, INode, INodeData, INodeParams, MemoryMethods } from '../../../src/Interface'
|
||||||
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
||||||
import { ConversationSummaryMemory, ConversationSummaryMemoryInput } from 'langchain/memory'
|
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||||
import { BaseLanguageModel } from 'langchain/base_language'
|
|
||||||
import { BaseMessage } from '@langchain/core/messages'
|
import { BaseMessage } from '@langchain/core/messages'
|
||||||
|
import { ConversationSummaryMemory, ConversationSummaryMemoryInput } from 'langchain/memory'
|
||||||
|
|
||||||
class ConversationSummaryMemory_Memory implements INode {
|
class ConversationSummaryMemory_Memory implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|||||||
@@ -90,13 +90,18 @@ class CustomFunction_Utilities implements INode {
|
|||||||
|
|
||||||
// Some values might be a stringified JSON, parse it
|
// Some values might be a stringified JSON, parse it
|
||||||
for (const key in inputVars) {
|
for (const key in inputVars) {
|
||||||
if (typeof inputVars[key] === 'string' && inputVars[key].startsWith('{') && inputVars[key].endsWith('}')) {
|
let value = inputVars[key]
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
value = handleEscapeCharacters(value, true)
|
||||||
|
if (value.startsWith('{') && value.endsWith('}')) {
|
||||||
try {
|
try {
|
||||||
inputVars[key] = JSON.parse(inputVars[key])
|
value = JSON.parse(value)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
continue
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
inputVars[key] = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sandbox: any = { $input: input }
|
let sandbox: any = { $input: input }
|
||||||
@@ -105,11 +110,7 @@ class CustomFunction_Utilities implements INode {
|
|||||||
|
|
||||||
if (Object.keys(inputVars).length) {
|
if (Object.keys(inputVars).length) {
|
||||||
for (const item in inputVars) {
|
for (const item in inputVars) {
|
||||||
let value = inputVars[item]
|
sandbox[`$${item}`] = inputVars[item]
|
||||||
if (typeof value === 'string') {
|
|
||||||
value = handleEscapeCharacters(value, true)
|
|
||||||
}
|
|
||||||
sandbox[`$${item}`] = value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,13 +101,18 @@ class IfElseFunction_Utilities implements INode {
|
|||||||
|
|
||||||
// Some values might be a stringified JSON, parse it
|
// Some values might be a stringified JSON, parse it
|
||||||
for (const key in inputVars) {
|
for (const key in inputVars) {
|
||||||
if (typeof inputVars[key] === 'string' && inputVars[key].startsWith('{') && inputVars[key].endsWith('}')) {
|
let value = inputVars[key]
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
value = handleEscapeCharacters(value, true)
|
||||||
|
if (value.startsWith('{') && value.endsWith('}')) {
|
||||||
try {
|
try {
|
||||||
inputVars[key] = JSON.parse(inputVars[key])
|
value = JSON.parse(value)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
continue
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
inputVars[key] = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sandbox: any = { $input: input }
|
let sandbox: any = { $input: input }
|
||||||
@@ -116,11 +121,7 @@ class IfElseFunction_Utilities implements INode {
|
|||||||
|
|
||||||
if (Object.keys(inputVars).length) {
|
if (Object.keys(inputVars).length) {
|
||||||
for (const item in inputVars) {
|
for (const item in inputVars) {
|
||||||
let value = inputVars[item]
|
sandbox[`$${item}`] = inputVars[item]
|
||||||
if (typeof value === 'string') {
|
|
||||||
value = handleEscapeCharacters(value, true)
|
|
||||||
}
|
|
||||||
sandbox[`$${item}`] = value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"@langchain/cohere": "^0.0.5",
|
"@langchain/cohere": "^0.0.5",
|
||||||
"@langchain/community": "^0.0.30",
|
"@langchain/community": "^0.0.30",
|
||||||
"@langchain/google-genai": "^0.0.10",
|
"@langchain/google-genai": "^0.0.10",
|
||||||
|
"@langchain/groq": "^0.0.2",
|
||||||
"@langchain/mistralai": "^0.0.7",
|
"@langchain/mistralai": "^0.0.7",
|
||||||
"@langchain/openai": "^0.0.14",
|
"@langchain/openai": "^0.0.14",
|
||||||
"@langchain/pinecone": "^0.0.3",
|
"@langchain/pinecone": "^0.0.3",
|
||||||
@@ -72,7 +73,7 @@
|
|||||||
"lunary": "^0.6.16",
|
"lunary": "^0.6.16",
|
||||||
"mammoth": "^1.5.1",
|
"mammoth": "^1.5.1",
|
||||||
"moment": "^2.29.3",
|
"moment": "^2.29.3",
|
||||||
"mongodb": "^6.2.0",
|
"mongodb": "6.2.0",
|
||||||
"mysql2": "^3.5.1",
|
"mysql2": "^3.5.1",
|
||||||
"node-fetch": "^2.6.11",
|
"node-fetch": "^2.6.11",
|
||||||
"node-html-markdown": "^1.3.0",
|
"node-html-markdown": "^1.3.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ICommonObject, IFileUpload, IMultiModalOption, INodeData, MessageContentImageUrl } from './Interface'
|
import { ICommonObject, IFileUpload, IMultiModalOption, INodeData, MessageContentImageUrl } from './Interface'
|
||||||
import { ChatOpenAI as LangchainChatOpenAI } from 'langchain/chat_models/openai'
|
import { ChatOpenAI } from '../nodes/chatmodels/ChatOpenAI/FlowiseChatOpenAI'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { getStoragePath } from './utils'
|
import { getStoragePath } from './utils'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
@@ -12,7 +12,7 @@ export const addImagesToMessages = (
|
|||||||
const imageContent: MessageContentImageUrl[] = []
|
const imageContent: MessageContentImageUrl[] = []
|
||||||
let model = nodeData.inputs?.model
|
let model = nodeData.inputs?.model
|
||||||
|
|
||||||
if (model instanceof LangchainChatOpenAI && multiModalOption) {
|
if (model instanceof ChatOpenAI && multiModalOption) {
|
||||||
// Image Uploaded
|
// Image Uploaded
|
||||||
if (multiModalOption.image && multiModalOption.image.allowImageUploads && options?.uploads && options?.uploads.length > 0) {
|
if (multiModalOption.image && multiModalOption.image.allowImageUploads && options?.uploads && options?.uploads.length > 0) {
|
||||||
const imageUploads = getImageUploads(options.uploads)
|
const imageUploads = getImageUploads(options.uploads)
|
||||||
|
|||||||
@@ -5,12 +5,10 @@
|
|||||||
"badge": "NEW",
|
"badge": "NEW",
|
||||||
"nodes": [
|
"nodes": [
|
||||||
{
|
{
|
||||||
"width": 300,
|
|
||||||
"height": 327,
|
|
||||||
"id": "openAIAssistant_0",
|
"id": "openAIAssistant_0",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 895.3722263184736,
|
"x": 1237.914576178543,
|
||||||
"y": 118.50795801755544
|
"y": 140
|
||||||
},
|
},
|
||||||
"type": "customNode",
|
"type": "customNode",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -60,33 +58,36 @@
|
|||||||
],
|
],
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"selectedAssistant": "",
|
"selectedAssistant": "",
|
||||||
"tools": ["{{calculator_0.data.instance}}", "{{serper_0.data.instance}}", "{{customTool_0.data.instance}}"]
|
"tools": ["{{calculator_0.data.instance}}", "{{serper_0.data.instance}}", "{{customTool_0.data.instance}}"],
|
||||||
|
"inputModeration": "",
|
||||||
|
"disableFileDownload": ""
|
||||||
},
|
},
|
||||||
"outputAnchors": [
|
"outputAnchors": [
|
||||||
{
|
{
|
||||||
"id": "openAIAssistant_0-output-openAIAssistant-OpenAIAssistant",
|
"id": "openAIAssistant_0-output-openAIAssistant-OpenAIAssistant",
|
||||||
"name": "openAIAssistant",
|
"name": "openAIAssistant",
|
||||||
"label": "OpenAIAssistant",
|
"label": "OpenAIAssistant",
|
||||||
|
"description": "An agent that uses OpenAI Assistant API to pick the tool and args to call",
|
||||||
"type": "OpenAIAssistant"
|
"type": "OpenAIAssistant"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": {},
|
"outputs": {},
|
||||||
"selected": false
|
"selected": false
|
||||||
},
|
},
|
||||||
|
"width": 300,
|
||||||
|
"height": 419,
|
||||||
"selected": false,
|
"selected": false,
|
||||||
"dragging": false,
|
"dragging": false,
|
||||||
"positionAbsolute": {
|
"positionAbsolute": {
|
||||||
"x": 895.3722263184736,
|
"x": 1237.914576178543,
|
||||||
"y": 118.50795801755544
|
"y": 140
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"width": 300,
|
|
||||||
"height": 143,
|
|
||||||
"id": "calculator_0",
|
"id": "calculator_0",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 454.74423492660145,
|
"x": 854.0341531341463,
|
||||||
"y": -56.08375600705064
|
"y": 48.134746169036475
|
||||||
},
|
},
|
||||||
"type": "customNode",
|
"type": "customNode",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -106,26 +107,75 @@
|
|||||||
"id": "calculator_0-output-calculator-Calculator|Tool|StructuredTool|Runnable",
|
"id": "calculator_0-output-calculator-Calculator|Tool|StructuredTool|Runnable",
|
||||||
"name": "calculator",
|
"name": "calculator",
|
||||||
"label": "Calculator",
|
"label": "Calculator",
|
||||||
|
"description": "Perform calculations on response",
|
||||||
"type": "Calculator | Tool | StructuredTool | Runnable"
|
"type": "Calculator | Tool | StructuredTool | Runnable"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": {},
|
"outputs": {},
|
||||||
"selected": false
|
"selected": false
|
||||||
},
|
},
|
||||||
|
"width": 300,
|
||||||
|
"height": 142,
|
||||||
"selected": false,
|
"selected": false,
|
||||||
"positionAbsolute": {
|
"positionAbsolute": {
|
||||||
"x": 454.74423492660145,
|
"x": 854.0341531341463,
|
||||||
"y": -56.08375600705064
|
"y": 48.134746169036475
|
||||||
},
|
},
|
||||||
"dragging": false
|
"dragging": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"id": "serper_0",
|
||||||
|
"position": {
|
||||||
|
"x": 852.623106275503,
|
||||||
|
"y": 205.46647090775525
|
||||||
|
},
|
||||||
|
"type": "customNode",
|
||||||
|
"data": {
|
||||||
|
"id": "serper_0",
|
||||||
|
"label": "Serper",
|
||||||
|
"version": 1,
|
||||||
|
"name": "serper",
|
||||||
|
"type": "Serper",
|
||||||
|
"baseClasses": ["Serper", "Tool", "StructuredTool", "Runnable"],
|
||||||
|
"category": "Tools",
|
||||||
|
"description": "Wrapper around Serper.dev - Google Search API",
|
||||||
|
"inputParams": [
|
||||||
|
{
|
||||||
|
"label": "Connect Credential",
|
||||||
|
"name": "credential",
|
||||||
|
"type": "credential",
|
||||||
|
"credentialNames": ["serperApi"],
|
||||||
|
"id": "serper_0-input-credential-credential"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputAnchors": [],
|
||||||
|
"inputs": {},
|
||||||
|
"outputAnchors": [
|
||||||
|
{
|
||||||
|
"id": "serper_0-output-serper-Serper|Tool|StructuredTool|Runnable",
|
||||||
|
"name": "serper",
|
||||||
|
"label": "Serper",
|
||||||
|
"description": "Wrapper around Serper.dev - Google Search API",
|
||||||
|
"type": "Serper | Tool | StructuredTool | Runnable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": {},
|
||||||
|
"selected": false
|
||||||
|
},
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"height": 277,
|
"height": 276,
|
||||||
|
"selected": false,
|
||||||
|
"positionAbsolute": {
|
||||||
|
"x": 852.623106275503,
|
||||||
|
"y": 205.46647090775525
|
||||||
|
},
|
||||||
|
"dragging": false
|
||||||
|
},
|
||||||
|
{
|
||||||
"id": "customTool_0",
|
"id": "customTool_0",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 454.43871855431365,
|
"x": 850.6759101766447,
|
||||||
"y": 401.2171774551178
|
"y": 496.68759375469654
|
||||||
},
|
},
|
||||||
"type": "customNode",
|
"type": "customNode",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -155,63 +205,19 @@
|
|||||||
"id": "customTool_0-output-customTool-CustomTool|Tool|StructuredTool|Runnable",
|
"id": "customTool_0-output-customTool-CustomTool|Tool|StructuredTool|Runnable",
|
||||||
"name": "customTool",
|
"name": "customTool",
|
||||||
"label": "CustomTool",
|
"label": "CustomTool",
|
||||||
|
"description": "Use custom tool you've created in Flowise within chatflow",
|
||||||
"type": "CustomTool | Tool | StructuredTool | Runnable"
|
"type": "CustomTool | Tool | StructuredTool | Runnable"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": {},
|
"outputs": {},
|
||||||
"selected": false
|
"selected": false
|
||||||
},
|
},
|
||||||
"selected": false,
|
|
||||||
"positionAbsolute": {
|
|
||||||
"x": 454.43871855431365,
|
|
||||||
"y": 401.2171774551178
|
|
||||||
},
|
|
||||||
"dragging": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"height": 277,
|
"height": 276,
|
||||||
"id": "serper_0",
|
|
||||||
"position": {
|
|
||||||
"x": 452.2514874331948,
|
|
||||||
"y": 99.6087116015905
|
|
||||||
},
|
|
||||||
"type": "customNode",
|
|
||||||
"data": {
|
|
||||||
"id": "serper_0",
|
|
||||||
"label": "Serper",
|
|
||||||
"version": 1,
|
|
||||||
"name": "serper",
|
|
||||||
"type": "Serper",
|
|
||||||
"baseClasses": ["Serper", "Tool", "StructuredTool", "Runnable"],
|
|
||||||
"category": "Tools",
|
|
||||||
"description": "Wrapper around Serper.dev - Google Search API",
|
|
||||||
"inputParams": [
|
|
||||||
{
|
|
||||||
"label": "Connect Credential",
|
|
||||||
"name": "credential",
|
|
||||||
"type": "credential",
|
|
||||||
"credentialNames": ["serperApi"],
|
|
||||||
"id": "serper_0-input-credential-credential"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputAnchors": [],
|
|
||||||
"inputs": {},
|
|
||||||
"outputAnchors": [
|
|
||||||
{
|
|
||||||
"id": "serper_0-output-serper-Serper|Tool|StructuredTool|Runnable",
|
|
||||||
"name": "serper",
|
|
||||||
"label": "Serper",
|
|
||||||
"type": "Serper | Tool | StructuredTool | Runnable"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"outputs": {},
|
|
||||||
"selected": false
|
|
||||||
},
|
|
||||||
"selected": false,
|
"selected": false,
|
||||||
"positionAbsolute": {
|
"positionAbsolute": {
|
||||||
"x": 452.2514874331948,
|
"x": 850.6759101766447,
|
||||||
"y": 99.6087116015905
|
"y": 496.68759375469654
|
||||||
},
|
},
|
||||||
"dragging": false
|
"dragging": false
|
||||||
}
|
}
|
||||||
@@ -223,10 +229,7 @@
|
|||||||
"target": "openAIAssistant_0",
|
"target": "openAIAssistant_0",
|
||||||
"targetHandle": "openAIAssistant_0-input-tools-Tool",
|
"targetHandle": "openAIAssistant_0-input-tools-Tool",
|
||||||
"type": "buttonedge",
|
"type": "buttonedge",
|
||||||
"id": "calculator_0-calculator_0-output-calculator-Calculator|Tool|StructuredTool|Runnable-openAIAssistant_0-openAIAssistant_0-input-tools-Tool",
|
"id": "calculator_0-calculator_0-output-calculator-Calculator|Tool|StructuredTool|Runnable-openAIAssistant_0-openAIAssistant_0-input-tools-Tool"
|
||||||
"data": {
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "serper_0",
|
"source": "serper_0",
|
||||||
@@ -234,10 +237,7 @@
|
|||||||
"target": "openAIAssistant_0",
|
"target": "openAIAssistant_0",
|
||||||
"targetHandle": "openAIAssistant_0-input-tools-Tool",
|
"targetHandle": "openAIAssistant_0-input-tools-Tool",
|
||||||
"type": "buttonedge",
|
"type": "buttonedge",
|
||||||
"id": "serper_0-serper_0-output-serper-Serper|Tool|StructuredTool|Runnable-openAIAssistant_0-openAIAssistant_0-input-tools-Tool",
|
"id": "serper_0-serper_0-output-serper-Serper|Tool|StructuredTool|Runnable-openAIAssistant_0-openAIAssistant_0-input-tools-Tool"
|
||||||
"data": {
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "customTool_0",
|
"source": "customTool_0",
|
||||||
@@ -245,10 +245,7 @@
|
|||||||
"target": "openAIAssistant_0",
|
"target": "openAIAssistant_0",
|
||||||
"targetHandle": "openAIAssistant_0-input-tools-Tool",
|
"targetHandle": "openAIAssistant_0-input-tools-Tool",
|
||||||
"type": "buttonedge",
|
"type": "buttonedge",
|
||||||
"id": "customTool_0-customTool_0-output-customTool-CustomTool|Tool|StructuredTool|Runnable-openAIAssistant_0-openAIAssistant_0-input-tools-Tool",
|
"id": "customTool_0-customTool_0-output-customTool-CustomTool|Tool|StructuredTool|Runnable-openAIAssistant_0-openAIAssistant_0-input-tools-Tool"
|
||||||
"data": {
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -532,11 +532,45 @@ export const getVariableValue = (
|
|||||||
variableDict[`{{${variableFullPath}}}`] = handleEscapeCharacters(convertChatHistoryToText(chatHistory), false)
|
variableDict[`{{${variableFullPath}}}`] = handleEscapeCharacters(convertChatHistoryToText(chatHistory), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split by first occurrence of '.' to get just nodeId
|
// Resolve values with following case.
|
||||||
const [variableNodeId, _] = variableFullPath.split('.')
|
// 1: <variableNodeId>.data.instance
|
||||||
|
// 2: <variableNodeId>.data.instance.pathtokey
|
||||||
|
const variableFullPathParts = variableFullPath.split('.')
|
||||||
|
const variableNodeId = variableFullPathParts[0]
|
||||||
const executedNode = reactFlowNodes.find((nd) => nd.id === variableNodeId)
|
const executedNode = reactFlowNodes.find((nd) => nd.id === variableNodeId)
|
||||||
if (executedNode) {
|
if (executedNode) {
|
||||||
const variableValue = get(executedNode.data, 'instance')
|
let variableValue = get(executedNode.data, 'instance')
|
||||||
|
|
||||||
|
// Handle path such as `<variableNodeId>.data.instance.key`
|
||||||
|
if (variableFullPathParts.length > 3) {
|
||||||
|
let variableObj = null
|
||||||
|
switch (typeof variableValue) {
|
||||||
|
case 'string': {
|
||||||
|
const unEscapedVariableValue = handleEscapeCharacters(variableValue, true)
|
||||||
|
if (unEscapedVariableValue.startsWith('{') && unEscapedVariableValue.endsWith('}')) {
|
||||||
|
try {
|
||||||
|
variableObj = JSON.parse(unEscapedVariableValue)
|
||||||
|
} catch (e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'object': {
|
||||||
|
variableObj = variableValue
|
||||||
|
break
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (variableObj) {
|
||||||
|
variableObj = get(variableObj, variableFullPathParts.slice(3))
|
||||||
|
variableValue = handleEscapeCharacters(
|
||||||
|
typeof variableObj === 'object' ? JSON.stringify(variableObj) : variableObj,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isAcceptVariable) {
|
if (isAcceptVariable) {
|
||||||
variableDict[`{{${variableFullPath}}}`] = variableValue
|
variableDict[`{{${variableFullPath}}}`] = variableValue
|
||||||
} else {
|
} else {
|
||||||
@@ -855,7 +889,8 @@ export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNod
|
|||||||
'chatAnthropic_LlamaIndex',
|
'chatAnthropic_LlamaIndex',
|
||||||
'chatOllama',
|
'chatOllama',
|
||||||
'awsChatBedrock',
|
'awsChatBedrock',
|
||||||
'chatMistralAI'
|
'chatMistralAI',
|
||||||
|
'groqChat'
|
||||||
],
|
],
|
||||||
LLMs: ['azureOpenAI', 'openAI', 'ollama']
|
LLMs: ['azureOpenAI', 'openAI', 'ollama']
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user