mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
Merge pull request #1570 from FlowiseAI/feature/ConversationChain
Feature/Add Verbose to Chains
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||||
import { ConversationChain } from 'langchain/chains'
|
import { ConversationChain } from 'langchain/chains'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses, handleEscapeCharacters } from '../../../src/utils'
|
||||||
import { ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate } from 'langchain/prompts'
|
import { ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate } from 'langchain/prompts'
|
||||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||||
import { flatten } from 'lodash'
|
|
||||||
import { Document } from 'langchain/document'
|
|
||||||
import { RunnableSequence } from 'langchain/schema/runnable'
|
import { RunnableSequence } from 'langchain/schema/runnable'
|
||||||
import { StringOutputParser } from 'langchain/schema/output_parser'
|
import { StringOutputParser } from 'langchain/schema/output_parser'
|
||||||
|
import { ConsoleCallbackHandler as LCConsoleCallbackHandler } from '@langchain/core/tracers/console'
|
||||||
|
|
||||||
let systemMessage = `The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.`
|
let systemMessage = `The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.`
|
||||||
const inputKey = 'input'
|
const inputKey = 'input'
|
||||||
@@ -27,7 +26,7 @@ class ConversationChain_Chains implements INode {
|
|||||||
constructor(fields?: { sessionId?: string }) {
|
constructor(fields?: { sessionId?: string }) {
|
||||||
this.label = 'Conversation Chain'
|
this.label = 'Conversation Chain'
|
||||||
this.name = 'conversationChain'
|
this.name = 'conversationChain'
|
||||||
this.version = 1.0
|
this.version = 2.0
|
||||||
this.type = 'ConversationChain'
|
this.type = 'ConversationChain'
|
||||||
this.icon = 'conv.svg'
|
this.icon = 'conv.svg'
|
||||||
this.category = 'Chains'
|
this.category = 'Chains'
|
||||||
@@ -44,6 +43,14 @@ class ConversationChain_Chains implements INode {
|
|||||||
name: 'memory',
|
name: 'memory',
|
||||||
type: 'BaseMemory'
|
type: 'BaseMemory'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Chat Prompt Template',
|
||||||
|
name: 'chatPromptTemplate',
|
||||||
|
type: 'ChatPromptTemplate',
|
||||||
|
description: 'Override existing prompt with Chat Prompt Template. Human Message must includes {input} variable',
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
|
/* Deprecated
|
||||||
{
|
{
|
||||||
label: 'Document',
|
label: 'Document',
|
||||||
name: 'document',
|
name: 'document',
|
||||||
@@ -52,15 +59,17 @@ class ConversationChain_Chains implements INode {
|
|||||||
'Include whole document into the context window, if you get maximum context length error, please use model with higher context window like Claude 100k, or gpt4 32k',
|
'Include whole document into the context window, if you get maximum context length error, please use model with higher context window like Claude 100k, or gpt4 32k',
|
||||||
optional: true,
|
optional: true,
|
||||||
list: true
|
list: true
|
||||||
},
|
},*/
|
||||||
{
|
{
|
||||||
label: 'System Message',
|
label: 'System Message',
|
||||||
name: 'systemMessagePrompt',
|
name: 'systemMessagePrompt',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
rows: 4,
|
rows: 4,
|
||||||
|
description: 'If Chat Prompt Template is provided, this will be ignored',
|
||||||
additionalParams: true,
|
additionalParams: true,
|
||||||
optional: true,
|
optional: true,
|
||||||
placeholder: 'You are a helpful assistant that write codes'
|
default: systemMessage,
|
||||||
|
placeholder: systemMessage
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
this.sessionId = fields?.sessionId
|
this.sessionId = fields?.sessionId
|
||||||
@@ -76,15 +85,21 @@ class ConversationChain_Chains implements INode {
|
|||||||
const chain = prepareChain(nodeData, this.sessionId, options.chatHistory)
|
const chain = prepareChain(nodeData, this.sessionId, options.chatHistory)
|
||||||
|
|
||||||
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
||||||
const callbacks = await additionalCallbacks(nodeData, options)
|
const additionalCallback = await additionalCallbacks(nodeData, options)
|
||||||
|
|
||||||
let res = ''
|
let res = ''
|
||||||
|
let callbacks = [loggerHandler, ...additionalCallback]
|
||||||
|
|
||||||
|
if (process.env.DEBUG === 'true') {
|
||||||
|
callbacks.push(new LCConsoleCallbackHandler())
|
||||||
|
}
|
||||||
|
|
||||||
if (options.socketIO && options.socketIOClientId) {
|
if (options.socketIO && options.socketIOClientId) {
|
||||||
const handler = new CustomChainHandler(options.socketIO, options.socketIOClientId)
|
const handler = new CustomChainHandler(options.socketIO, options.socketIOClientId)
|
||||||
res = await chain.invoke({ input }, { callbacks: [loggerHandler, handler, ...callbacks] })
|
callbacks.push(handler)
|
||||||
|
res = await chain.invoke({ input }, { callbacks })
|
||||||
} else {
|
} else {
|
||||||
res = await chain.invoke({ input }, { callbacks: [loggerHandler, ...callbacks] })
|
res = await chain.invoke({ input }, { callbacks })
|
||||||
}
|
}
|
||||||
|
|
||||||
await memory.addChatMessages(
|
await memory.addChatMessages(
|
||||||
@@ -108,28 +123,27 @@ class ConversationChain_Chains implements INode {
|
|||||||
const prepareChatPrompt = (nodeData: INodeData) => {
|
const prepareChatPrompt = (nodeData: INodeData) => {
|
||||||
const memory = nodeData.inputs?.memory as FlowiseMemory
|
const memory = nodeData.inputs?.memory as FlowiseMemory
|
||||||
const prompt = nodeData.inputs?.systemMessagePrompt as string
|
const prompt = nodeData.inputs?.systemMessagePrompt as string
|
||||||
const docs = nodeData.inputs?.document as Document[]
|
const chatPromptTemplate = nodeData.inputs?.chatPromptTemplate as ChatPromptTemplate
|
||||||
|
|
||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
if (chatPromptTemplate && chatPromptTemplate.promptMessages.length) {
|
||||||
const finalDocs = []
|
const sysPrompt = chatPromptTemplate.promptMessages[0]
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
const humanPrompt = chatPromptTemplate.promptMessages[chatPromptTemplate.promptMessages.length - 1]
|
||||||
if (flattenDocs[i] && flattenDocs[i].pageContent) {
|
const chatPrompt = ChatPromptTemplate.fromMessages([
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
sysPrompt,
|
||||||
|
new MessagesPlaceholder(memory.memoryKey ?? 'chat_history'),
|
||||||
|
humanPrompt
|
||||||
|
])
|
||||||
|
|
||||||
|
if ((chatPromptTemplate as any).promptValues) {
|
||||||
|
// @ts-ignore
|
||||||
|
chatPrompt.promptValues = (chatPromptTemplate as any).promptValues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return chatPrompt
|
||||||
}
|
}
|
||||||
|
|
||||||
let finalText = ''
|
|
||||||
for (let i = 0; i < finalDocs.length; i += 1) {
|
|
||||||
finalText += finalDocs[i].pageContent
|
|
||||||
}
|
|
||||||
|
|
||||||
const replaceChar: string[] = ['{', '}']
|
|
||||||
for (const char of replaceChar) finalText = finalText.replaceAll(char, '')
|
|
||||||
|
|
||||||
if (finalText) systemMessage = `${systemMessage}\nThe AI has the following context:\n${finalText}`
|
|
||||||
|
|
||||||
const chatPrompt = ChatPromptTemplate.fromMessages([
|
const chatPrompt = ChatPromptTemplate.fromMessages([
|
||||||
SystemMessagePromptTemplate.fromTemplate(prompt ? `${prompt}\n${systemMessage}` : systemMessage),
|
SystemMessagePromptTemplate.fromTemplate(prompt ? prompt : systemMessage),
|
||||||
new MessagesPlaceholder(memory.memoryKey ?? 'chat_history'),
|
new MessagesPlaceholder(memory.memoryKey ?? 'chat_history'),
|
||||||
HumanMessagePromptTemplate.fromTemplate(`{${inputKey}}`)
|
HumanMessagePromptTemplate.fromTemplate(`{${inputKey}}`)
|
||||||
])
|
])
|
||||||
@@ -142,15 +156,31 @@ const prepareChain = (nodeData: INodeData, sessionId?: string, chatHistory: IMes
|
|||||||
const memory = nodeData.inputs?.memory as FlowiseMemory
|
const memory = nodeData.inputs?.memory as FlowiseMemory
|
||||||
const memoryKey = memory.memoryKey ?? 'chat_history'
|
const memoryKey = memory.memoryKey ?? 'chat_history'
|
||||||
|
|
||||||
|
const chatPrompt = prepareChatPrompt(nodeData)
|
||||||
|
let promptVariables = {}
|
||||||
|
const promptValuesRaw = (chatPrompt as any).promptValues
|
||||||
|
if (promptValuesRaw) {
|
||||||
|
const promptValues = handleEscapeCharacters(promptValuesRaw, true)
|
||||||
|
for (const val in promptValues) {
|
||||||
|
promptVariables = {
|
||||||
|
...promptVariables,
|
||||||
|
[val]: () => {
|
||||||
|
return promptValues[val]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const conversationChain = RunnableSequence.from([
|
const conversationChain = RunnableSequence.from([
|
||||||
{
|
{
|
||||||
[inputKey]: (input: { input: string }) => input.input,
|
[inputKey]: (input: { input: string }) => input.input,
|
||||||
[memoryKey]: async () => {
|
[memoryKey]: async () => {
|
||||||
const history = await memory.getChatMessages(sessionId, true, chatHistory)
|
const history = await memory.getChatMessages(sessionId, true, chatHistory)
|
||||||
return history
|
return history
|
||||||
}
|
},
|
||||||
|
...promptVariables
|
||||||
},
|
},
|
||||||
prepareChatPrompt(nodeData),
|
chatPrompt,
|
||||||
model,
|
model,
|
||||||
new StringOutputParser()
|
new StringOutputParser()
|
||||||
])
|
])
|
||||||
|
|||||||
+9
-2
@@ -13,6 +13,7 @@ import { applyPatch } from 'fast-json-patch'
|
|||||||
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
||||||
import { ConsoleCallbackHandler, additionalCallbacks } from '../../../src/handler'
|
import { ConsoleCallbackHandler, additionalCallbacks } from '../../../src/handler'
|
||||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, MemoryMethods } from '../../../src/Interface'
|
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, MemoryMethods } from '../../../src/Interface'
|
||||||
|
import { ConsoleCallbackHandler as LCConsoleCallbackHandler } from '@langchain/core/tracers/console'
|
||||||
|
|
||||||
type RetrievalChainInput = {
|
type RetrievalChainInput = {
|
||||||
chat_history: string
|
chat_history: string
|
||||||
@@ -176,11 +177,17 @@ class ConversationalRetrievalQAChain_Chains implements INode {
|
|||||||
const history = ((await memory.getChatMessages(this.sessionId, false, options.chatHistory)) as IMessage[]) ?? []
|
const history = ((await memory.getChatMessages(this.sessionId, false, options.chatHistory)) as IMessage[]) ?? []
|
||||||
|
|
||||||
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
||||||
const callbacks = await additionalCallbacks(nodeData, options)
|
const additionalCallback = await additionalCallbacks(nodeData, options)
|
||||||
|
|
||||||
|
let callbacks = [loggerHandler, ...additionalCallback]
|
||||||
|
|
||||||
|
if (process.env.DEBUG === 'true') {
|
||||||
|
callbacks.push(new LCConsoleCallbackHandler())
|
||||||
|
}
|
||||||
|
|
||||||
const stream = answerChain.streamLog(
|
const stream = answerChain.streamLog(
|
||||||
{ question: input, chat_history: history },
|
{ question: input, chat_history: history },
|
||||||
{ callbacks: [loggerHandler, ...callbacks] },
|
{ callbacks },
|
||||||
{
|
{
|
||||||
includeNames: [sourceRunnableName]
|
includeNames: [sourceRunnableName]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,15 @@
|
|||||||
"height": 376,
|
"height": 376,
|
||||||
"id": "bufferMemory_0",
|
"id": "bufferMemory_0",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 451.4449437285705,
|
"x": 240.5161028076149,
|
||||||
"y": 118.30026803362762
|
"y": 165.35849026339048
|
||||||
},
|
},
|
||||||
"type": "customNode",
|
"type": "customNode",
|
||||||
"data": {
|
"data": {
|
||||||
"id": "bufferMemory_0",
|
"id": "bufferMemory_0",
|
||||||
"label": "Buffer Memory",
|
"label": "Buffer Memory",
|
||||||
"name": "bufferMemory",
|
|
||||||
"version": 1,
|
"version": 1,
|
||||||
|
"name": "bufferMemory",
|
||||||
"type": "BufferMemory",
|
"type": "BufferMemory",
|
||||||
"baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"],
|
"baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"],
|
||||||
"category": "Memory",
|
"category": "Memory",
|
||||||
@@ -53,8 +53,8 @@
|
|||||||
},
|
},
|
||||||
"selected": false,
|
"selected": false,
|
||||||
"positionAbsolute": {
|
"positionAbsolute": {
|
||||||
"x": 451.4449437285705,
|
"x": 240.5161028076149,
|
||||||
"y": 118.30026803362762
|
"y": 165.35849026339048
|
||||||
},
|
},
|
||||||
"dragging": false
|
"dragging": false
|
||||||
},
|
},
|
||||||
@@ -63,17 +63,17 @@
|
|||||||
"height": 383,
|
"height": 383,
|
||||||
"id": "conversationChain_0",
|
"id": "conversationChain_0",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1176.1569322079652,
|
"x": 958.9887390513221,
|
||||||
"y": 303.56879146735974
|
"y": 318.8734467468765
|
||||||
},
|
},
|
||||||
"type": "customNode",
|
"type": "customNode",
|
||||||
"data": {
|
"data": {
|
||||||
"id": "conversationChain_0",
|
"id": "conversationChain_0",
|
||||||
"label": "Conversation Chain",
|
"label": "Conversation Chain",
|
||||||
|
"version": 2,
|
||||||
"name": "conversationChain",
|
"name": "conversationChain",
|
||||||
"version": 1,
|
|
||||||
"type": "ConversationChain",
|
"type": "ConversationChain",
|
||||||
"baseClasses": ["ConversationChain", "LLMChain", "BaseChain"],
|
"baseClasses": ["ConversationChain", "LLMChain", "BaseChain", "Runnable"],
|
||||||
"category": "Chains",
|
"category": "Chains",
|
||||||
"description": "Chat models specific conversational chain with memory",
|
"description": "Chat models specific conversational chain with memory",
|
||||||
"inputParams": [
|
"inputParams": [
|
||||||
@@ -82,9 +82,11 @@
|
|||||||
"name": "systemMessagePrompt",
|
"name": "systemMessagePrompt",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"rows": 4,
|
"rows": 4,
|
||||||
|
"description": "If Chat Prompt Template is provided, this will be ignored",
|
||||||
"additionalParams": true,
|
"additionalParams": true,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"placeholder": "You are a helpful assistant that write codes",
|
"default": "The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.",
|
||||||
|
"placeholder": "The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.",
|
||||||
"id": "conversationChain_0-input-systemMessagePrompt-string"
|
"id": "conversationChain_0-input-systemMessagePrompt-string"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -102,27 +104,26 @@
|
|||||||
"id": "conversationChain_0-input-memory-BaseMemory"
|
"id": "conversationChain_0-input-memory-BaseMemory"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Document",
|
"label": "Chat Prompt Template",
|
||||||
"name": "document",
|
"name": "chatPromptTemplate",
|
||||||
"type": "Document",
|
"type": "ChatPromptTemplate",
|
||||||
"description": "Include whole document into the context window",
|
"description": "Override existing prompt with Chat Prompt Template. Human Message must includes {input} variable",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"list": true,
|
"id": "conversationChain_0-input-chatPromptTemplate-ChatPromptTemplate"
|
||||||
"id": "conversationChain_0-input-document-Document"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"model": "{{chatAnthropic_0.data.instance}}",
|
"model": "{{chatAnthropic_0.data.instance}}",
|
||||||
"memory": "{{bufferMemory_0.data.instance}}",
|
"memory": "{{bufferMemory_0.data.instance}}",
|
||||||
"document": ["{{pdfFile_0.data.instance}}"],
|
"chatPromptTemplate": "{{chatPromptTemplate_0.data.instance}}",
|
||||||
"systemMessagePrompt": ""
|
"systemMessagePrompt": "The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know."
|
||||||
},
|
},
|
||||||
"outputAnchors": [
|
"outputAnchors": [
|
||||||
{
|
{
|
||||||
"id": "conversationChain_0-output-conversationChain-ConversationChain|LLMChain|BaseChain",
|
"id": "conversationChain_0-output-conversationChain-ConversationChain|LLMChain|BaseChain|Runnable",
|
||||||
"name": "conversationChain",
|
"name": "conversationChain",
|
||||||
"label": "ConversationChain",
|
"label": "ConversationChain",
|
||||||
"type": "ConversationChain | LLMChain | BaseChain"
|
"type": "ConversationChain | LLMChain | BaseChain | Runnable"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": {},
|
"outputs": {},
|
||||||
@@ -130,27 +131,27 @@
|
|||||||
},
|
},
|
||||||
"selected": false,
|
"selected": false,
|
||||||
"positionAbsolute": {
|
"positionAbsolute": {
|
||||||
"x": 1176.1569322079652,
|
"x": 958.9887390513221,
|
||||||
"y": 303.56879146735974
|
"y": 318.8734467468765
|
||||||
},
|
},
|
||||||
"dragging": false
|
"dragging": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"height": 523,
|
"height": 574,
|
||||||
"id": "chatAnthropic_0",
|
"id": "chatAnthropic_0",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 800.5525382783799,
|
"x": 585.3308245972187,
|
||||||
"y": -130.7988221837009
|
"y": -116.32789506560908
|
||||||
},
|
},
|
||||||
"type": "customNode",
|
"type": "customNode",
|
||||||
"data": {
|
"data": {
|
||||||
"id": "chatAnthropic_0",
|
"id": "chatAnthropic_0",
|
||||||
"label": "ChatAnthropic",
|
"label": "ChatAnthropic",
|
||||||
"name": "chatAnthropic",
|
|
||||||
"version": 3,
|
"version": 3,
|
||||||
|
"name": "chatAnthropic",
|
||||||
"type": "ChatAnthropic",
|
"type": "ChatAnthropic",
|
||||||
"baseClasses": ["ChatAnthropic", "BaseChatModel", "BaseLanguageModel"],
|
"baseClasses": ["ChatAnthropic", "BaseChatModel", "BaseLanguageModel", "Runnable"],
|
||||||
"category": "Chat Models",
|
"category": "Chat Models",
|
||||||
"description": "Wrapper around ChatAnthropic large language models that use the Chat endpoint",
|
"description": "Wrapper around ChatAnthropic large language models that use the Chat endpoint",
|
||||||
"inputParams": [
|
"inputParams": [
|
||||||
@@ -226,7 +227,7 @@
|
|||||||
"name": "claude-instant-v1.1-100k"
|
"name": "claude-instant-v1.1-100k"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"default": "claude-v1",
|
"default": "claude-2",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"id": "chatAnthropic_0-input-modelName-options"
|
"id": "chatAnthropic_0-input-modelName-options"
|
||||||
},
|
},
|
||||||
@@ -234,6 +235,7 @@
|
|||||||
"label": "Temperature",
|
"label": "Temperature",
|
||||||
"name": "temperature",
|
"name": "temperature",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
|
"step": 0.1,
|
||||||
"default": 0.9,
|
"default": 0.9,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"id": "chatAnthropic_0-input-temperature-number"
|
"id": "chatAnthropic_0-input-temperature-number"
|
||||||
@@ -242,6 +244,7 @@
|
|||||||
"label": "Max Tokens",
|
"label": "Max Tokens",
|
||||||
"name": "maxTokensToSample",
|
"name": "maxTokensToSample",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
|
"step": 1,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"additionalParams": true,
|
"additionalParams": true,
|
||||||
"id": "chatAnthropic_0-input-maxTokensToSample-number"
|
"id": "chatAnthropic_0-input-maxTokensToSample-number"
|
||||||
@@ -250,6 +253,7 @@
|
|||||||
"label": "Top P",
|
"label": "Top P",
|
||||||
"name": "topP",
|
"name": "topP",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
|
"step": 0.1,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"additionalParams": true,
|
"additionalParams": true,
|
||||||
"id": "chatAnthropic_0-input-topP-number"
|
"id": "chatAnthropic_0-input-topP-number"
|
||||||
@@ -258,6 +262,7 @@
|
|||||||
"label": "Top K",
|
"label": "Top K",
|
||||||
"name": "topK",
|
"name": "topK",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
|
"step": 0.1,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"additionalParams": true,
|
"additionalParams": true,
|
||||||
"id": "chatAnthropic_0-input-topK-number"
|
"id": "chatAnthropic_0-input-topK-number"
|
||||||
@@ -273,6 +278,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"cache": "",
|
||||||
"modelName": "claude-2.1",
|
"modelName": "claude-2.1",
|
||||||
"temperature": 0.9,
|
"temperature": 0.9,
|
||||||
"maxTokensToSample": "",
|
"maxTokensToSample": "",
|
||||||
@@ -281,10 +287,10 @@
|
|||||||
},
|
},
|
||||||
"outputAnchors": [
|
"outputAnchors": [
|
||||||
{
|
{
|
||||||
"id": "chatAnthropic_0-output-chatAnthropic-ChatAnthropic|BaseChatModel|BaseLanguageModel",
|
"id": "chatAnthropic_0-output-chatAnthropic-ChatAnthropic|BaseChatModel|BaseLanguageModel|Runnable",
|
||||||
"name": "chatAnthropic",
|
"name": "chatAnthropic",
|
||||||
"label": "ChatAnthropic",
|
"label": "ChatAnthropic",
|
||||||
"type": "ChatAnthropic | BaseChatModel | BaseLanguageModel"
|
"type": "ChatAnthropic | BaseChatModel | BaseLanguageModel | Runnable"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": {},
|
"outputs": {},
|
||||||
@@ -292,61 +298,106 @@
|
|||||||
},
|
},
|
||||||
"selected": false,
|
"selected": false,
|
||||||
"positionAbsolute": {
|
"positionAbsolute": {
|
||||||
"x": 800.5525382783799,
|
"x": 585.3308245972187,
|
||||||
"y": -130.7988221837009
|
"y": -116.32789506560908
|
||||||
},
|
},
|
||||||
"dragging": false
|
"dragging": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"height": 507,
|
"height": 688,
|
||||||
"id": "pdfFile_0",
|
"id": "chatPromptTemplate_0",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 94.16886576108482,
|
"x": -106.44189698270114,
|
||||||
"y": 37.12056504707391
|
"y": 20.133956087516538
|
||||||
},
|
},
|
||||||
"type": "customNode",
|
"type": "customNode",
|
||||||
"data": {
|
"data": {
|
||||||
"id": "pdfFile_0",
|
"id": "chatPromptTemplate_0",
|
||||||
"label": "Pdf File",
|
"label": "Chat Prompt Template",
|
||||||
"name": "pdfFile",
|
|
||||||
"version": 1,
|
"version": 1,
|
||||||
|
"name": "chatPromptTemplate",
|
||||||
|
"type": "ChatPromptTemplate",
|
||||||
|
"baseClasses": ["ChatPromptTemplate", "BaseChatPromptTemplate", "BasePromptTemplate", "Runnable"],
|
||||||
|
"category": "Prompts",
|
||||||
|
"description": "Schema to represent a chat prompt",
|
||||||
|
"inputParams": [
|
||||||
|
{
|
||||||
|
"label": "System Message",
|
||||||
|
"name": "systemMessagePrompt",
|
||||||
|
"type": "string",
|
||||||
|
"rows": 4,
|
||||||
|
"placeholder": "You are a helpful assistant that translates {input_language} to {output_language}.",
|
||||||
|
"id": "chatPromptTemplate_0-input-systemMessagePrompt-string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Human Message",
|
||||||
|
"name": "humanMessagePrompt",
|
||||||
|
"type": "string",
|
||||||
|
"rows": 4,
|
||||||
|
"placeholder": "{text}",
|
||||||
|
"id": "chatPromptTemplate_0-input-humanMessagePrompt-string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Format Prompt Values",
|
||||||
|
"name": "promptValues",
|
||||||
|
"type": "json",
|
||||||
|
"optional": true,
|
||||||
|
"acceptVariable": true,
|
||||||
|
"list": true,
|
||||||
|
"id": "chatPromptTemplate_0-input-promptValues-json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputAnchors": [],
|
||||||
|
"inputs": {
|
||||||
|
"systemMessagePrompt": "The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.\nThe AI has the following context:\n{context}",
|
||||||
|
"humanMessagePrompt": "{input}",
|
||||||
|
"promptValues": "{\"context\":\"{{plainText_0.data.instance}}\",\"input\":\"{{question}}\"}"
|
||||||
|
},
|
||||||
|
"outputAnchors": [
|
||||||
|
{
|
||||||
|
"id": "chatPromptTemplate_0-output-chatPromptTemplate-ChatPromptTemplate|BaseChatPromptTemplate|BasePromptTemplate|Runnable",
|
||||||
|
"name": "chatPromptTemplate",
|
||||||
|
"label": "ChatPromptTemplate",
|
||||||
|
"type": "ChatPromptTemplate | BaseChatPromptTemplate | BasePromptTemplate | Runnable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": {},
|
||||||
|
"selected": false
|
||||||
|
},
|
||||||
|
"selected": false,
|
||||||
|
"positionAbsolute": {
|
||||||
|
"x": -106.44189698270114,
|
||||||
|
"y": 20.133956087516538
|
||||||
|
},
|
||||||
|
"dragging": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"width": 300,
|
||||||
|
"height": 485,
|
||||||
|
"id": "plainText_0",
|
||||||
|
"position": {
|
||||||
|
"x": -487.7511991135089,
|
||||||
|
"y": 77.83838996645807
|
||||||
|
},
|
||||||
|
"type": "customNode",
|
||||||
|
"data": {
|
||||||
|
"id": "plainText_0",
|
||||||
|
"label": "Plain Text",
|
||||||
|
"version": 2,
|
||||||
|
"name": "plainText",
|
||||||
"type": "Document",
|
"type": "Document",
|
||||||
"baseClasses": ["Document"],
|
"baseClasses": ["Document"],
|
||||||
"category": "Document Loaders",
|
"category": "Document Loaders",
|
||||||
"description": "Load data from PDF files",
|
"description": "Load data from plain text",
|
||||||
"inputParams": [
|
"inputParams": [
|
||||||
{
|
{
|
||||||
"label": "Pdf File",
|
"label": "Text",
|
||||||
"name": "pdfFile",
|
"name": "text",
|
||||||
"type": "file",
|
"type": "string",
|
||||||
"fileType": ".pdf",
|
"rows": 4,
|
||||||
"id": "pdfFile_0-input-pdfFile-file"
|
"placeholder": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...",
|
||||||
},
|
"id": "plainText_0-input-text-string"
|
||||||
{
|
|
||||||
"label": "Usage",
|
|
||||||
"name": "usage",
|
|
||||||
"type": "options",
|
|
||||||
"options": [
|
|
||||||
{
|
|
||||||
"label": "One document per page",
|
|
||||||
"name": "perPage"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "One document per file",
|
|
||||||
"name": "perFile"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"default": "perPage",
|
|
||||||
"id": "pdfFile_0-input-usage-options"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Use Legacy Build",
|
|
||||||
"name": "legacyBuild",
|
|
||||||
"type": "boolean",
|
|
||||||
"optional": true,
|
|
||||||
"additionalParams": true,
|
|
||||||
"id": "pdfFile_0-input-legacyBuild-boolean"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Metadata",
|
"label": "Metadata",
|
||||||
@@ -354,7 +405,7 @@
|
|||||||
"type": "json",
|
"type": "json",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"additionalParams": true,
|
"additionalParams": true,
|
||||||
"id": "pdfFile_0-input-metadata-json"
|
"id": "plainText_0-input-metadata-json"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputAnchors": [
|
"inputAnchors": [
|
||||||
@@ -363,30 +414,45 @@
|
|||||||
"name": "textSplitter",
|
"name": "textSplitter",
|
||||||
"type": "TextSplitter",
|
"type": "TextSplitter",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"id": "pdfFile_0-input-textSplitter-TextSplitter"
|
"id": "plainText_0-input-textSplitter-TextSplitter"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"text": "Welcome to Skyworld Hotel, where your dreams take flight and your stay soars to new heights. Nestled amidst breathtaking cityscape views, our upscale establishment offers an unparalleled blend of luxury and comfort. Our rooms are elegantly appointed, featuring modern amenities and plush furnishings to ensure your relaxation.\n\nIndulge in culinary delights at our rooftop restaurant, offering a gastronomic journey with panoramic vistas. Skyworld Hotel boasts state-of-the-art conference facilities, perfect for business travelers, and an inviting spa for relaxation seekers. Our attentive staff is dedicated to ensuring your every need is met, making your stay memorable.\n\nCentrally located, we offer easy access to local attractions, making us an ideal choice for both leisure and business travelers. Experience the world of hospitality like never before at Skyworld Hotel.",
|
||||||
"textSplitter": "",
|
"textSplitter": "",
|
||||||
"usage": "perPage",
|
|
||||||
"legacyBuild": "",
|
|
||||||
"metadata": ""
|
"metadata": ""
|
||||||
},
|
},
|
||||||
"outputAnchors": [
|
"outputAnchors": [
|
||||||
{
|
{
|
||||||
"id": "pdfFile_0-output-pdfFile-Document",
|
"name": "output",
|
||||||
"name": "pdfFile",
|
"label": "Output",
|
||||||
"label": "Document",
|
"type": "options",
|
||||||
"type": "Document"
|
"options": [
|
||||||
|
{
|
||||||
|
"id": "plainText_0-output-document-Document",
|
||||||
|
"name": "document",
|
||||||
|
"label": "Document",
|
||||||
|
"type": "Document"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "plainText_0-output-text-string|json",
|
||||||
|
"name": "text",
|
||||||
|
"label": "Text",
|
||||||
|
"type": "string | json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default": "document"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": {},
|
"outputs": {
|
||||||
|
"output": "text"
|
||||||
|
},
|
||||||
"selected": false
|
"selected": false
|
||||||
},
|
},
|
||||||
"selected": false,
|
"selected": false,
|
||||||
"positionAbsolute": {
|
"positionAbsolute": {
|
||||||
"x": 94.16886576108482,
|
"x": -487.7511991135089,
|
||||||
"y": 37.12056504707391
|
"y": 77.83838996645807
|
||||||
},
|
},
|
||||||
"dragging": false
|
"dragging": false
|
||||||
}
|
}
|
||||||
@@ -398,32 +464,31 @@
|
|||||||
"target": "conversationChain_0",
|
"target": "conversationChain_0",
|
||||||
"targetHandle": "conversationChain_0-input-memory-BaseMemory",
|
"targetHandle": "conversationChain_0-input-memory-BaseMemory",
|
||||||
"type": "buttonedge",
|
"type": "buttonedge",
|
||||||
"id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-conversationChain_0-conversationChain_0-input-memory-BaseMemory",
|
"id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-conversationChain_0-conversationChain_0-input-memory-BaseMemory"
|
||||||
"data": {
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "chatAnthropic_0",
|
"source": "chatAnthropic_0",
|
||||||
"sourceHandle": "chatAnthropic_0-output-chatAnthropic-ChatAnthropic|BaseChatModel|BaseLanguageModel",
|
"sourceHandle": "chatAnthropic_0-output-chatAnthropic-ChatAnthropic|BaseChatModel|BaseLanguageModel|Runnable",
|
||||||
"target": "conversationChain_0",
|
"target": "conversationChain_0",
|
||||||
"targetHandle": "conversationChain_0-input-model-BaseChatModel",
|
"targetHandle": "conversationChain_0-input-model-BaseChatModel",
|
||||||
"type": "buttonedge",
|
"type": "buttonedge",
|
||||||
"id": "chatAnthropic_0-chatAnthropic_0-output-chatAnthropic-ChatAnthropic|BaseChatModel|BaseLanguageModel-conversationChain_0-conversationChain_0-input-model-BaseChatModel",
|
"id": "chatAnthropic_0-chatAnthropic_0-output-chatAnthropic-ChatAnthropic|BaseChatModel|BaseLanguageModel|Runnable-conversationChain_0-conversationChain_0-input-model-BaseChatModel"
|
||||||
"data": {
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "pdfFile_0",
|
"source": "plainText_0",
|
||||||
"sourceHandle": "pdfFile_0-output-pdfFile-Document",
|
"sourceHandle": "plainText_0-output-text-string|json",
|
||||||
"target": "conversationChain_0",
|
"target": "chatPromptTemplate_0",
|
||||||
"targetHandle": "conversationChain_0-input-document-Document",
|
"targetHandle": "chatPromptTemplate_0-input-promptValues-json",
|
||||||
"type": "buttonedge",
|
"type": "buttonedge",
|
||||||
"id": "pdfFile_0-pdfFile_0-output-pdfFile-Document-conversationChain_0-conversationChain_0-input-document-Document",
|
"id": "plainText_0-plainText_0-output-text-string|json-chatPromptTemplate_0-chatPromptTemplate_0-input-promptValues-json"
|
||||||
"data": {
|
},
|
||||||
"label": ""
|
{
|
||||||
}
|
"source": "chatPromptTemplate_0",
|
||||||
|
"sourceHandle": "chatPromptTemplate_0-output-chatPromptTemplate-ChatPromptTemplate|BaseChatPromptTemplate|BasePromptTemplate|Runnable",
|
||||||
|
"target": "conversationChain_0",
|
||||||
|
"targetHandle": "conversationChain_0-input-chatPromptTemplate-ChatPromptTemplate",
|
||||||
|
"type": "buttonedge",
|
||||||
|
"id": "chatPromptTemplate_0-chatPromptTemplate_0-output-chatPromptTemplate-ChatPromptTemplate|BaseChatPromptTemplate|BasePromptTemplate|Runnable-conversationChain_0-conversationChain_0-input-chatPromptTemplate-ChatPromptTemplate"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,20 +2,210 @@
|
|||||||
"description": "Basic example of Conversation Chain with built-in memory - works exactly like ChatGPT",
|
"description": "Basic example of Conversation Chain with built-in memory - works exactly like ChatGPT",
|
||||||
"badge": "POPULAR",
|
"badge": "POPULAR",
|
||||||
"nodes": [
|
"nodes": [
|
||||||
|
{
|
||||||
|
"width": 300,
|
||||||
|
"height": 574,
|
||||||
|
"id": "chatOpenAI_0",
|
||||||
|
"position": {
|
||||||
|
"x": 579.0877964395976,
|
||||||
|
"y": -138.68792413227874
|
||||||
|
},
|
||||||
|
"type": "customNode",
|
||||||
|
"data": {
|
||||||
|
"id": "chatOpenAI_0",
|
||||||
|
"label": "ChatOpenAI",
|
||||||
|
"version": 2,
|
||||||
|
"name": "chatOpenAI",
|
||||||
|
"type": "ChatOpenAI",
|
||||||
|
"baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"],
|
||||||
|
"category": "Chat Models",
|
||||||
|
"description": "Wrapper around OpenAI large language models that use the Chat endpoint",
|
||||||
|
"inputParams": [
|
||||||
|
{
|
||||||
|
"label": "Connect Credential",
|
||||||
|
"name": "credential",
|
||||||
|
"type": "credential",
|
||||||
|
"credentialNames": ["openAIApi"],
|
||||||
|
"id": "chatOpenAI_0-input-credential-credential"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Model Name",
|
||||||
|
"name": "modelName",
|
||||||
|
"type": "options",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "gpt-4",
|
||||||
|
"name": "gpt-4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-4-1106-preview",
|
||||||
|
"name": "gpt-4-1106-preview"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-4-vision-preview",
|
||||||
|
"name": "gpt-4-vision-preview"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-4-0613",
|
||||||
|
"name": "gpt-4-0613"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-4-32k",
|
||||||
|
"name": "gpt-4-32k"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-4-32k-0613",
|
||||||
|
"name": "gpt-4-32k-0613"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-3.5-turbo",
|
||||||
|
"name": "gpt-3.5-turbo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-3.5-turbo-1106",
|
||||||
|
"name": "gpt-3.5-turbo-1106"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-3.5-turbo-0613",
|
||||||
|
"name": "gpt-3.5-turbo-0613"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-3.5-turbo-16k",
|
||||||
|
"name": "gpt-3.5-turbo-16k"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "gpt-3.5-turbo-16k-0613",
|
||||||
|
"name": "gpt-3.5-turbo-16k-0613"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default": "gpt-3.5-turbo",
|
||||||
|
"optional": true,
|
||||||
|
"id": "chatOpenAI_0-input-modelName-options"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Temperature",
|
||||||
|
"name": "temperature",
|
||||||
|
"type": "number",
|
||||||
|
"step": 0.1,
|
||||||
|
"default": 0.9,
|
||||||
|
"optional": true,
|
||||||
|
"id": "chatOpenAI_0-input-temperature-number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Max Tokens",
|
||||||
|
"name": "maxTokens",
|
||||||
|
"type": "number",
|
||||||
|
"step": 1,
|
||||||
|
"optional": true,
|
||||||
|
"additionalParams": true,
|
||||||
|
"id": "chatOpenAI_0-input-maxTokens-number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Top Probability",
|
||||||
|
"name": "topP",
|
||||||
|
"type": "number",
|
||||||
|
"step": 0.1,
|
||||||
|
"optional": true,
|
||||||
|
"additionalParams": true,
|
||||||
|
"id": "chatOpenAI_0-input-topP-number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Frequency Penalty",
|
||||||
|
"name": "frequencyPenalty",
|
||||||
|
"type": "number",
|
||||||
|
"step": 0.1,
|
||||||
|
"optional": true,
|
||||||
|
"additionalParams": true,
|
||||||
|
"id": "chatOpenAI_0-input-frequencyPenalty-number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Presence Penalty",
|
||||||
|
"name": "presencePenalty",
|
||||||
|
"type": "number",
|
||||||
|
"step": 0.1,
|
||||||
|
"optional": true,
|
||||||
|
"additionalParams": true,
|
||||||
|
"id": "chatOpenAI_0-input-presencePenalty-number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Timeout",
|
||||||
|
"name": "timeout",
|
||||||
|
"type": "number",
|
||||||
|
"step": 1,
|
||||||
|
"optional": true,
|
||||||
|
"additionalParams": true,
|
||||||
|
"id": "chatOpenAI_0-input-timeout-number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "BasePath",
|
||||||
|
"name": "basepath",
|
||||||
|
"type": "string",
|
||||||
|
"optional": true,
|
||||||
|
"additionalParams": true,
|
||||||
|
"id": "chatOpenAI_0-input-basepath-string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "BaseOptions",
|
||||||
|
"name": "baseOptions",
|
||||||
|
"type": "json",
|
||||||
|
"optional": true,
|
||||||
|
"additionalParams": true,
|
||||||
|
"id": "chatOpenAI_0-input-baseOptions-json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputAnchors": [
|
||||||
|
{
|
||||||
|
"label": "Cache",
|
||||||
|
"name": "cache",
|
||||||
|
"type": "BaseCache",
|
||||||
|
"optional": true,
|
||||||
|
"id": "chatOpenAI_0-input-cache-BaseCache"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputs": {
|
||||||
|
"cache": "",
|
||||||
|
"modelName": "gpt-3.5-turbo-16k",
|
||||||
|
"temperature": 0.9,
|
||||||
|
"maxTokens": "",
|
||||||
|
"topP": "",
|
||||||
|
"frequencyPenalty": "",
|
||||||
|
"presencePenalty": "",
|
||||||
|
"timeout": "",
|
||||||
|
"basepath": "",
|
||||||
|
"baseOptions": ""
|
||||||
|
},
|
||||||
|
"outputAnchors": [
|
||||||
|
{
|
||||||
|
"id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable",
|
||||||
|
"name": "chatOpenAI",
|
||||||
|
"label": "ChatOpenAI",
|
||||||
|
"type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": {},
|
||||||
|
"selected": false
|
||||||
|
},
|
||||||
|
"selected": false,
|
||||||
|
"positionAbsolute": {
|
||||||
|
"x": 579.0877964395976,
|
||||||
|
"y": -138.68792413227874
|
||||||
|
},
|
||||||
|
"dragging": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"height": 376,
|
"height": 376,
|
||||||
"id": "bufferMemory_0",
|
"id": "bufferMemory_0",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 753.4300788823234,
|
"x": 220.30240896145915,
|
||||||
"y": 479.5336426526603
|
"y": 351.61324070296877
|
||||||
},
|
},
|
||||||
"type": "customNode",
|
"type": "customNode",
|
||||||
"data": {
|
"data": {
|
||||||
"id": "bufferMemory_0",
|
"id": "bufferMemory_0",
|
||||||
"label": "Buffer Memory",
|
"label": "Buffer Memory",
|
||||||
"name": "bufferMemory",
|
|
||||||
"version": 1,
|
"version": 1,
|
||||||
|
"name": "bufferMemory",
|
||||||
"type": "BufferMemory",
|
"type": "BufferMemory",
|
||||||
"baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"],
|
"baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"],
|
||||||
"category": "Memory",
|
"category": "Memory",
|
||||||
@@ -54,179 +244,8 @@
|
|||||||
},
|
},
|
||||||
"selected": false,
|
"selected": false,
|
||||||
"positionAbsolute": {
|
"positionAbsolute": {
|
||||||
"x": 753.4300788823234,
|
"x": 220.30240896145915,
|
||||||
"y": 479.5336426526603
|
"y": 351.61324070296877
|
||||||
},
|
|
||||||
"dragging": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 300,
|
|
||||||
"height": 523,
|
|
||||||
"id": "chatOpenAI_0",
|
|
||||||
"position": {
|
|
||||||
"x": 754.8942497823595,
|
|
||||||
"y": -140
|
|
||||||
},
|
|
||||||
"type": "customNode",
|
|
||||||
"data": {
|
|
||||||
"id": "chatOpenAI_0",
|
|
||||||
"label": "ChatOpenAI",
|
|
||||||
"name": "chatOpenAI",
|
|
||||||
"version": 2,
|
|
||||||
"type": "ChatOpenAI",
|
|
||||||
"baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel"],
|
|
||||||
"category": "Chat Models",
|
|
||||||
"description": "Wrapper around OpenAI large language models that use the Chat endpoint",
|
|
||||||
"inputParams": [
|
|
||||||
{
|
|
||||||
"label": "Connect Credential",
|
|
||||||
"name": "credential",
|
|
||||||
"type": "credential",
|
|
||||||
"credentialNames": ["openAIApi"],
|
|
||||||
"id": "chatOpenAI_0-input-credential-credential"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Model Name",
|
|
||||||
"name": "modelName",
|
|
||||||
"type": "options",
|
|
||||||
"options": [
|
|
||||||
{
|
|
||||||
"label": "gpt-4",
|
|
||||||
"name": "gpt-4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "gpt-4-0613",
|
|
||||||
"name": "gpt-4-0613"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "gpt-4-32k",
|
|
||||||
"name": "gpt-4-32k"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "gpt-4-32k-0613",
|
|
||||||
"name": "gpt-4-32k-0613"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "gpt-3.5-turbo",
|
|
||||||
"name": "gpt-3.5-turbo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "gpt-3.5-turbo-0613",
|
|
||||||
"name": "gpt-3.5-turbo-0613"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "gpt-3.5-turbo-16k",
|
|
||||||
"name": "gpt-3.5-turbo-16k"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "gpt-3.5-turbo-16k-0613",
|
|
||||||
"name": "gpt-3.5-turbo-16k-0613"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"default": "gpt-3.5-turbo",
|
|
||||||
"optional": true,
|
|
||||||
"id": "chatOpenAI_0-input-modelName-options"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Temperature",
|
|
||||||
"name": "temperature",
|
|
||||||
"type": "number",
|
|
||||||
"default": 0.9,
|
|
||||||
"optional": true,
|
|
||||||
"id": "chatOpenAI_0-input-temperature-number"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Max Tokens",
|
|
||||||
"name": "maxTokens",
|
|
||||||
"type": "number",
|
|
||||||
"optional": true,
|
|
||||||
"additionalParams": true,
|
|
||||||
"id": "chatOpenAI_0-input-maxTokens-number"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Top Probability",
|
|
||||||
"name": "topP",
|
|
||||||
"type": "number",
|
|
||||||
"optional": true,
|
|
||||||
"additionalParams": true,
|
|
||||||
"id": "chatOpenAI_0-input-topP-number"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Frequency Penalty",
|
|
||||||
"name": "frequencyPenalty",
|
|
||||||
"type": "number",
|
|
||||||
"optional": true,
|
|
||||||
"additionalParams": true,
|
|
||||||
"id": "chatOpenAI_0-input-frequencyPenalty-number"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Presence Penalty",
|
|
||||||
"name": "presencePenalty",
|
|
||||||
"type": "number",
|
|
||||||
"optional": true,
|
|
||||||
"additionalParams": true,
|
|
||||||
"id": "chatOpenAI_0-input-presencePenalty-number"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Timeout",
|
|
||||||
"name": "timeout",
|
|
||||||
"type": "number",
|
|
||||||
"optional": true,
|
|
||||||
"additionalParams": true,
|
|
||||||
"id": "chatOpenAI_0-input-timeout-number"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "BasePath",
|
|
||||||
"name": "basepath",
|
|
||||||
"type": "string",
|
|
||||||
"optional": true,
|
|
||||||
"additionalParams": true,
|
|
||||||
"id": "chatOpenAI_0-input-basepath-string"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "BaseOptions",
|
|
||||||
"name": "baseOptions",
|
|
||||||
"type": "json",
|
|
||||||
"optional": true,
|
|
||||||
"additionalParams": true,
|
|
||||||
"id": "chatOpenAI_0-input-baseOptions-json"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputAnchors": [
|
|
||||||
{
|
|
||||||
"label": "Cache",
|
|
||||||
"name": "cache",
|
|
||||||
"type": "BaseCache",
|
|
||||||
"optional": true,
|
|
||||||
"id": "chatOpenAI_0-input-cache-BaseCache"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputs": {
|
|
||||||
"modelName": "gpt-3.5-turbo",
|
|
||||||
"temperature": 0.9,
|
|
||||||
"maxTokens": "",
|
|
||||||
"topP": "",
|
|
||||||
"frequencyPenalty": "",
|
|
||||||
"presencePenalty": "",
|
|
||||||
"timeout": "",
|
|
||||||
"basepath": "",
|
|
||||||
"baseOptions": ""
|
|
||||||
},
|
|
||||||
"outputAnchors": [
|
|
||||||
{
|
|
||||||
"id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel",
|
|
||||||
"name": "chatOpenAI",
|
|
||||||
"label": "ChatOpenAI",
|
|
||||||
"type": "ChatOpenAI | BaseChatModel | BaseLanguageModel"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"outputs": {},
|
|
||||||
"selected": false
|
|
||||||
},
|
|
||||||
"selected": false,
|
|
||||||
"positionAbsolute": {
|
|
||||||
"x": 754.8942497823595,
|
|
||||||
"y": -140
|
|
||||||
},
|
},
|
||||||
"dragging": false
|
"dragging": false
|
||||||
},
|
},
|
||||||
@@ -235,17 +254,17 @@
|
|||||||
"height": 383,
|
"height": 383,
|
||||||
"id": "conversationChain_0",
|
"id": "conversationChain_0",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1174.6496397666272,
|
"x": 958.9887390513221,
|
||||||
"y": 311.1052536740497
|
"y": 318.8734467468765
|
||||||
},
|
},
|
||||||
"type": "customNode",
|
"type": "customNode",
|
||||||
"data": {
|
"data": {
|
||||||
"id": "conversationChain_0",
|
"id": "conversationChain_0",
|
||||||
"label": "Conversation Chain",
|
"label": "Conversation Chain",
|
||||||
|
"version": 2,
|
||||||
"name": "conversationChain",
|
"name": "conversationChain",
|
||||||
"version": 1,
|
|
||||||
"type": "ConversationChain",
|
"type": "ConversationChain",
|
||||||
"baseClasses": ["ConversationChain", "LLMChain", "BaseChain"],
|
"baseClasses": ["ConversationChain", "LLMChain", "BaseChain", "Runnable"],
|
||||||
"category": "Chains",
|
"category": "Chains",
|
||||||
"description": "Chat models specific conversational chain with memory",
|
"description": "Chat models specific conversational chain with memory",
|
||||||
"inputParams": [
|
"inputParams": [
|
||||||
@@ -254,9 +273,11 @@
|
|||||||
"name": "systemMessagePrompt",
|
"name": "systemMessagePrompt",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"rows": 4,
|
"rows": 4,
|
||||||
|
"description": "If Chat Prompt Template is provided, this will be ignored",
|
||||||
"additionalParams": true,
|
"additionalParams": true,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"placeholder": "You are a helpful assistant that write codes",
|
"default": "The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.",
|
||||||
|
"placeholder": "The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.",
|
||||||
"id": "conversationChain_0-input-systemMessagePrompt-string"
|
"id": "conversationChain_0-input-systemMessagePrompt-string"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -274,27 +295,26 @@
|
|||||||
"id": "conversationChain_0-input-memory-BaseMemory"
|
"id": "conversationChain_0-input-memory-BaseMemory"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Document",
|
"label": "Chat Prompt Template",
|
||||||
"name": "document",
|
"name": "chatPromptTemplate",
|
||||||
"type": "Document",
|
"type": "ChatPromptTemplate",
|
||||||
"description": "Include whole document into the context window",
|
"description": "Override existing prompt with Chat Prompt Template. Human Message must includes {input} variable",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"list": true,
|
"id": "conversationChain_0-input-chatPromptTemplate-ChatPromptTemplate"
|
||||||
"id": "conversationChain_0-input-document-Document"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"model": "{{chatOpenAI_0.data.instance}}",
|
"model": "{{chatOpenAI_0.data.instance}}",
|
||||||
"memory": "{{bufferMemory_0.data.instance}}",
|
"memory": "{{bufferMemory_0.data.instance}}",
|
||||||
"document": "",
|
"chatPromptTemplate": "",
|
||||||
"systemMessagePrompt": ""
|
"systemMessagePrompt": "The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know."
|
||||||
},
|
},
|
||||||
"outputAnchors": [
|
"outputAnchors": [
|
||||||
{
|
{
|
||||||
"id": "conversationChain_0-output-conversationChain-ConversationChain|LLMChain|BaseChain",
|
"id": "conversationChain_0-output-conversationChain-ConversationChain|LLMChain|BaseChain|Runnable",
|
||||||
"name": "conversationChain",
|
"name": "conversationChain",
|
||||||
"label": "ConversationChain",
|
"label": "ConversationChain",
|
||||||
"type": "ConversationChain | LLMChain | BaseChain"
|
"type": "ConversationChain | LLMChain | BaseChain | Runnable"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": {},
|
"outputs": {},
|
||||||
@@ -302,8 +322,8 @@
|
|||||||
},
|
},
|
||||||
"selected": false,
|
"selected": false,
|
||||||
"positionAbsolute": {
|
"positionAbsolute": {
|
||||||
"x": 1174.6496397666272,
|
"x": 958.9887390513221,
|
||||||
"y": 311.1052536740497
|
"y": 318.8734467468765
|
||||||
},
|
},
|
||||||
"dragging": false
|
"dragging": false
|
||||||
}
|
}
|
||||||
@@ -311,14 +331,11 @@
|
|||||||
"edges": [
|
"edges": [
|
||||||
{
|
{
|
||||||
"source": "chatOpenAI_0",
|
"source": "chatOpenAI_0",
|
||||||
"sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel",
|
"sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable",
|
||||||
"target": "conversationChain_0",
|
"target": "conversationChain_0",
|
||||||
"targetHandle": "conversationChain_0-input-model-BaseChatModel",
|
"targetHandle": "conversationChain_0-input-model-BaseChatModel",
|
||||||
"type": "buttonedge",
|
"type": "buttonedge",
|
||||||
"id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-conversationChain_0-conversationChain_0-input-model-BaseChatModel",
|
"id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationChain_0-conversationChain_0-input-model-BaseChatModel"
|
||||||
"data": {
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "bufferMemory_0",
|
"source": "bufferMemory_0",
|
||||||
@@ -326,10 +343,7 @@
|
|||||||
"target": "conversationChain_0",
|
"target": "conversationChain_0",
|
||||||
"targetHandle": "conversationChain_0-input-memory-BaseMemory",
|
"targetHandle": "conversationChain_0-input-memory-BaseMemory",
|
||||||
"type": "buttonedge",
|
"type": "buttonedge",
|
||||||
"id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-conversationChain_0-conversationChain_0-input-memory-BaseMemory",
|
"id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-conversationChain_0-conversationChain_0-input-memory-BaseMemory"
|
||||||
"data": {
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user