From f64931bfccbfc667568f7141f5a7705c3411c9ae Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 1 Jun 2024 00:08:49 +0100 Subject: [PATCH 01/29] =?UTF-8?q?=F0=9F=A5=B3=20flowise-components@1.8.1?= =?UTF-8?q?=20minor=20bugfix=20release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/components/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/package.json b/packages/components/package.json index 289783eb37e..92cb3da8bda 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "flowise-components", - "version": "1.8.0", + "version": "1.8.1", "description": "Flowiseai Components", "main": "dist/src/index", "types": "dist/src/index.d.ts", From c42ef95a154f63f3785b91695225676a2dbfef53 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 1 Jun 2024 00:09:10 +0100 Subject: [PATCH 02/29] =?UTF-8?q?=F0=9F=A5=B3=20flowise-ui@1.8.1=20minor?= =?UTF-8?q?=20bugfix=20release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/package.json b/packages/ui/package.json index 4d02991e2a5..27daf337e53 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "flowise-ui", - "version": "1.8.0", + "version": "1.8.1", "license": "SEE LICENSE IN LICENSE.md", "homepage": "https://flowiseai.com", "author": { From 1d9927027d5e98f926f226d8fba0bc6c746d8b68 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 1 Jun 2024 00:09:38 +0100 Subject: [PATCH 03/29] =?UTF-8?q?=F0=9F=A5=B3=20flowise@1.8.1=20minor=20bu?= =?UTF-8?q?gfix=20release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- packages/server/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 060dd5d22e0..c0a24f04ed7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flowise", - "version": "1.8.0", + "version": "1.8.1", "private": true, "homepage": "https://flowiseai.com", "workspaces": [ diff --git a/packages/server/package.json b/packages/server/package.json index 01e432f6025..65662878965 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "flowise", - "version": "1.8.0", + "version": "1.8.1", "description": "Flowiseai Server", "main": "dist/index", "types": "dist/index.d.ts", From e5f0ca2dd31af96a9723bc4fd3e184599e3c66ab Mon Sep 17 00:00:00 2001 From: Daniel D'Abate Date: Sat, 1 Jun 2024 13:36:39 +0200 Subject: [PATCH 04/29] Fix OpenSearch vector store upsert (#2545) --- packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts index 662e5130180..df721c49031 100644 --- a/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts +++ b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts @@ -80,7 +80,7 @@ class OpenSearch_VectorStores implements INode { //@ts-ignore vectorStoreMethods = { - async upsert(nodeData: INodeData, _: string, options: ICommonObject): Promise> { + async upsert(nodeData: INodeData, options: ICommonObject): Promise> { const docs = nodeData.inputs?.document as Document[] const embeddings = nodeData.inputs?.embeddings as Embeddings const indexName = nodeData.inputs?.indexName as string From e15e6fafdc0213d9f483f80b77b007ffe893e56c Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Sat, 1 Jun 2024 12:37:00 +0100 Subject: [PATCH 05/29] Bugfix/Disable output prediction from llmchain streaming (#2543) disable output prediction from llmchain streaming --- packages/components/nodes/chains/LLMChain/LLMChain.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/components/nodes/chains/LLMChain/LLMChain.ts b/packages/components/nodes/chains/LLMChain/LLMChain.ts index 0bb1e122058..5a7d04569a6 100644 --- a/packages/components/nodes/chains/LLMChain/LLMChain.ts +++ b/packages/components/nodes/chains/LLMChain/LLMChain.ts @@ -110,7 +110,9 @@ class LLMChain_Chains implements INode { }) const inputVariables = chain.prompt.inputVariables as string[] // ["product"] promptValues = injectOutputParser(this.outputParser, chain, promptValues) - const res = await runPrediction(inputVariables, chain, input, promptValues, options, nodeData) + // Disable streaming because its not final chain + const disableStreaming = true + const res = await runPrediction(inputVariables, chain, input, promptValues, options, nodeData, disableStreaming) // eslint-disable-next-line no-console console.log('\x1b[92m\x1b[1m\n*****OUTPUT PREDICTION*****\n\x1b[0m\x1b[0m') // eslint-disable-next-line no-console @@ -154,12 +156,13 @@ const runPrediction = async ( input: string, promptValuesRaw: ICommonObject | undefined, options: ICommonObject, - nodeData: INodeData + nodeData: INodeData, + disableStreaming?: boolean ) => { const loggerHandler = new ConsoleCallbackHandler(options.logger) const callbacks = await additionalCallbacks(nodeData, options) - const isStreaming = options.socketIO && options.socketIOClientId + const isStreaming = !disableStreaming && options.socketIO && options.socketIOClientId const socketIO = isStreaming ? options.socketIO : undefined const socketIOClientId = isStreaming ? options.socketIOClientId : '' const moderations = nodeData.inputs?.inputModeration as Moderation[] From 8c66d2c7352d90281585c9345dafb9f242ca6a5d Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Sun, 2 Jun 2024 02:33:40 +0100 Subject: [PATCH 06/29] Bugfix/Avoid passing runnable assign when worker agent has no input variables (#2550) avoid passing runnable assign when worker agent has no input variables --- .../nodes/multiagents/Worker/Worker.ts | 56 +++++++++++++------ 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/packages/components/nodes/multiagents/Worker/Worker.ts b/packages/components/nodes/multiagents/Worker/Worker.ts index ffa4569553f..96910c94108 100644 --- a/packages/components/nodes/multiagents/Worker/Worker.ts +++ b/packages/components/nodes/multiagents/Worker/Worker.ts @@ -199,19 +199,33 @@ async function createAgent( } const modelWithTools = llm.bindTools(tools) - const agent = RunnableSequence.from([ - RunnablePassthrough.assign({ - //@ts-ignore - agent_scratchpad: (input: { steps: ToolsAgentStep[] }) => formatToOpenAIToolMessages(input.steps) - }), - RunnablePassthrough.assign(transformObjectPropertyToFunction(workerInputVariablesValues)), - prompt, - modelWithTools, - new ToolCallingAgentOutputParser() - ]) + let agent + + if (!workerInputVariablesValues || !Object.keys(workerInputVariablesValues).length) { + agent = RunnableSequence.from([ + RunnablePassthrough.assign({ + //@ts-ignore + agent_scratchpad: (input: { steps: ToolsAgentStep[] }) => formatToOpenAIToolMessages(input.steps) + }), + prompt, + modelWithTools, + new ToolCallingAgentOutputParser() + ]) + } else { + agent = RunnableSequence.from([ + RunnablePassthrough.assign({ + //@ts-ignore + agent_scratchpad: (input: { steps: ToolsAgentStep[] }) => formatToOpenAIToolMessages(input.steps) + }), + RunnablePassthrough.assign(transformObjectPropertyToFunction(workerInputVariablesValues)), + prompt, + modelWithTools, + new ToolCallingAgentOutputParser() + ]) + } const executor = AgentExecutor.fromAgentAndTools({ - agent: agent, + agent, tools, sessionId: flowObj?.sessionId, chatId: flowObj?.chatId, @@ -233,12 +247,19 @@ async function createAgent( const msg = HumanMessagePromptTemplate.fromTemplate([...multiModalMessageContent]) prompt.promptMessages.splice(1, 0, msg) } - const conversationChain = RunnableSequence.from([ - RunnablePassthrough.assign(transformObjectPropertyToFunction(workerInputVariablesValues)), - prompt, - llm, - new StringOutputParser() - ]) + + let conversationChain + + if (!workerInputVariablesValues || !Object.keys(workerInputVariablesValues).length) { + conversationChain = RunnableSequence.from([prompt, llm, new StringOutputParser()]) + } else { + conversationChain = RunnableSequence.from([ + RunnablePassthrough.assign(transformObjectPropertyToFunction(workerInputVariablesValues)), + prompt, + llm, + new StringOutputParser() + ]) + } return conversationChain } } @@ -256,6 +277,7 @@ async function agentNode( if (abortControllerSignal.signal.aborted) { throw new Error('Aborted!') } + const result = await agent.invoke({ ...state, signal: abortControllerSignal.signal }, config) const additional_kwargs: ICommonObject = {} if (result.usedTools) { From f2a0ffe5425fb20de8539fc24c3d83ec734577f4 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Sun, 2 Jun 2024 02:41:48 +0100 Subject: [PATCH 07/29] Bugfix/Check for proper thread id and avoid throwing error (#2551) check for proper thread id and avoid throwing error --- .../nodes/agents/OpenAIAssistant/OpenAIAssistant.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts b/packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts index cbc0da722eb..b5fea18e9ad 100644 --- a/packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts +++ b/packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts @@ -138,10 +138,14 @@ class OpenAIAssistant_Agents implements INode { const openai = new OpenAI({ apiKey: openAIApiKey }) options.logger.info(`Clearing OpenAI Thread ${sessionId}`) try { - if (sessionId) await openai.beta.threads.del(sessionId) - options.logger.info(`Successfully cleared OpenAI Thread ${sessionId}`) + if (sessionId && sessionId.startsWith('thread_')) { + await openai.beta.threads.del(sessionId) + options.logger.info(`Successfully cleared OpenAI Thread ${sessionId}`) + } else { + options.logger.error(`Error clearing OpenAI Thread ${sessionId}`) + } } catch (e) { - throw new Error(e) + options.logger.error(`Error clearing OpenAI Thread ${sessionId}`) } } From 272fd914bd1dc826ad6abeb32df37407db3cb659 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Mon, 3 Jun 2024 13:09:59 +0100 Subject: [PATCH 08/29] Bugfix/supabase upsert ids (#2561) * fix upserting same id with supabase * remove dedicated addvectors logic for ids * Update pnpm-lock.yaml * add fix for null id column --- .../nodes/vectorstores/Supabase/Supabase.ts | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/packages/components/nodes/vectorstores/Supabase/Supabase.ts b/packages/components/nodes/vectorstores/Supabase/Supabase.ts index f0ba0773c53..dca321efbaa 100644 --- a/packages/components/nodes/vectorstores/Supabase/Supabase.ts +++ b/packages/components/nodes/vectorstores/Supabase/Supabase.ts @@ -1,4 +1,5 @@ import { flatten } from 'lodash' +import { v4 as uuidv4 } from 'uuid' import { createClient } from '@supabase/supabase-js' import { Document } from '@langchain/core/documents' import { Embeddings } from '@langchain/core/embeddings' @@ -213,7 +214,7 @@ class Supabase_VectorStores implements INode { } class SupabaseUpsertVectorStore extends SupabaseVectorStore { - async addVectors(vectors: number[][], documents: Document[]): Promise { + async addVectors(vectors: number[][], documents: Document[], options?: { ids?: string[] | number[] }): Promise { if (vectors.length === 0) { return [] } @@ -223,23 +224,36 @@ class SupabaseUpsertVectorStore extends SupabaseVectorStore { metadata: documents[idx].metadata })) - let idx = 0 - const { count } = await this.client.from(this.tableName).select('*', { count: 'exact', head: true }) - if (count) { - idx = count - } - let returnedIds: string[] = [] for (let i = 0; i < rows.length; i += this.upsertBatchSize) { - const chunk = rows.slice(i, i + this.upsertBatchSize).map((row) => { - idx = idx += 1 - return { id: idx, ...row } + const chunk = rows.slice(i, i + this.upsertBatchSize).map((row, j) => { + if (options?.ids) { + return { id: options.ids[i + j], ...row } + } + return row }) - const res = await this.client.from(this.tableName).upsert(chunk).select() + let res = await this.client.from(this.tableName).upsert(chunk).select() + if (res.error) { - throw new Error(`Error inserting: ${res.error.message} ${res.status} ${res.statusText}`) + // If the error is due to null value in column "id", we will generate a new id for the row + if (res.error.message.includes(`null value in column "id"`)) { + const chunk = rows.slice(i, i + this.upsertBatchSize).map((row, y) => { + if (options?.ids) { + return { id: options.ids[i + y], ...row } + } + return { id: uuidv4(), ...row } + }) + res = await this.client.from(this.tableName).upsert(chunk).select() + + if (res.error) { + throw new Error(`Error inserting: ${res.error.message} ${res.status} ${res.statusText}`) + } + } else { + throw new Error(`Error inserting: ${res.error.message} ${res.status} ${res.statusText}`) + } } + if (res.data) { returnedIds = returnedIds.concat(res.data.map((row) => row.id)) } From 76abd20e8595df8db47a9a01c18031b5a42f6721 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 3 Jun 2024 13:34:21 +0100 Subject: [PATCH 09/29] =?UTF-8?q?=F0=9F=A5=B3=20flowise-components@1.8.2?= =?UTF-8?q?=20minor=20bugfix=20release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/components/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/package.json b/packages/components/package.json index 92cb3da8bda..746311bbd1a 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "flowise-components", - "version": "1.8.1", + "version": "1.8.2", "description": "Flowiseai Components", "main": "dist/src/index", "types": "dist/src/index.d.ts", From a799ac80875128e77ccde0160f3933efc679c5ea Mon Sep 17 00:00:00 2001 From: Daniel D'Abate Date: Tue, 4 Jun 2024 03:31:36 +0200 Subject: [PATCH 10/29] Improve OpenSearchURL credential storing user and password in separate fields from the URL (#2549) OpenSearch - Improve OpenSearchURL credential storing user and password in separate fields from the URL --- .../credentials/OpenSearchUrl.credential.ts | 16 +++++++++- .../vectorstores/OpenSearch/OpenSearch.ts | 29 ++++++++++++++----- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/packages/components/credentials/OpenSearchUrl.credential.ts b/packages/components/credentials/OpenSearchUrl.credential.ts index d5c54bfa80b..c941e61f32d 100644 --- a/packages/components/credentials/OpenSearchUrl.credential.ts +++ b/packages/components/credentials/OpenSearchUrl.credential.ts @@ -10,12 +10,26 @@ class OpenSearchUrl implements INodeCredential { constructor() { this.label = 'OpenSearch' this.name = 'openSearchUrl' - this.version = 1.0 + this.version = 2.0 this.inputs = [ { label: 'OpenSearch Url', name: 'openSearchUrl', type: 'string' + }, + { + label: 'User', + name: 'user', + type: 'string', + placeholder: '', + optional: true + }, + { + label: 'Password', + name: 'password', + type: 'password', + placeholder: '', + optional: true } ] } diff --git a/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts index df721c49031..5399ebc3a0c 100644 --- a/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts +++ b/packages/components/nodes/vectorstores/OpenSearch/OpenSearch.ts @@ -23,7 +23,7 @@ class OpenSearch_VectorStores implements INode { constructor() { this.label = 'OpenSearch' this.name = 'openSearch' - this.version = 2.0 + this.version = 3.0 this.type = 'OpenSearch' this.icon = 'opensearch.svg' this.category = 'Vector Stores' @@ -87,6 +87,10 @@ class OpenSearch_VectorStores implements INode { const credentialData = await getCredentialData(nodeData.credential ?? '', options) const opensearchURL = getCredentialParam('openSearchUrl', credentialData, nodeData) + const user = getCredentialParam('user', credentialData, nodeData) + const password = getCredentialParam('password', credentialData, nodeData) + + const client = getOpenSearchClient(opensearchURL, user, password) const flattenDocs = docs && docs.length ? flatten(docs) : [] const finalDocs = [] @@ -96,10 +100,6 @@ class OpenSearch_VectorStores implements INode { } } - const client = new Client({ - nodes: [opensearchURL] - }) - try { await OpenSearchVectorStore.fromDocuments(finalDocs, embeddings, { client, @@ -121,10 +121,10 @@ class OpenSearch_VectorStores implements INode { const credentialData = await getCredentialData(nodeData.credential ?? '', options) const opensearchURL = getCredentialParam('openSearchUrl', credentialData, nodeData) + const user = getCredentialParam('user', credentialData, nodeData) + const password = getCredentialParam('password', credentialData, nodeData) - const client = new Client({ - nodes: [opensearchURL] - }) + const client = getOpenSearchClient(opensearchURL, user, password) const vectorStore = new OpenSearchVectorStore(embeddings, { client, @@ -142,4 +142,17 @@ class OpenSearch_VectorStores implements INode { } } +const getOpenSearchClient = (url: string, user?: string, password?: string): Client => { + if (user && password) { + const urlObj = new URL(url) + urlObj.username = user + urlObj.password = password + url = urlObj.toString() + } + + return new Client({ + nodes: [url] + }) +} + module.exports = { nodeClass: OpenSearch_VectorStores } From 7eb9341fdc5039f06f1ad09e3c9a4a780455c9a4 Mon Sep 17 00:00:00 2001 From: Jared McQueen Date: Mon, 3 Jun 2024 21:50:43 -0400 Subject: [PATCH 11/29] adding url to source for all web scrapers (#2537) --- packages/server/src/Interface.DocumentStore.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/server/src/Interface.DocumentStore.ts b/packages/server/src/Interface.DocumentStore.ts index 9682341ef11..837b2f4d31f 100644 --- a/packages/server/src/Interface.DocumentStore.ts +++ b/packages/server/src/Interface.DocumentStore.ts @@ -124,6 +124,12 @@ export class DocumentStoreDTO { case 'cheerioWebScraper': loader.source = loader.loaderConfig.url break + case 'playwrightWebScraper': + loader.source = loader.loaderConfig.url + break + case 'puppeteerWebScraper': + loader.source = loader.loaderConfig.url + break case 'jsonFile': loader.source = loader.loaderConfig.jsonFile.replace('FILE-STORAGE::', '') break From 55f52c4d50250cbc95f903711012872d40644fb8 Mon Sep 17 00:00:00 2001 From: Saurav Maheshkar Date: Tue, 4 Jun 2024 02:57:07 +0100 Subject: [PATCH 12/29] feat(ci): enable `pnpm` caching in CI (#2530) --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 485f5c2eb6c..e693be6389a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,6 +27,7 @@ jobs: with: node-version: ${{ matrix.node-version }} check-latest: false + cache: 'pnpm' - run: npm i -g pnpm - run: pnpm install - run: ./node_modules/.bin/cypress install From bdbb6f850af6f8b27f95b66509560c64bd46cbe1 Mon Sep 17 00:00:00 2001 From: Jared McQueen Date: Mon, 3 Jun 2024 21:57:30 -0400 Subject: [PATCH 13/29] adding a document loader returns the correct id (#2538) --- packages/server/src/services/documentstore/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/services/documentstore/index.ts b/packages/server/src/services/documentstore/index.ts index 20031b532b8..3492602fa11 100644 --- a/packages/server/src/services/documentstore/index.ts +++ b/packages/server/src/services/documentstore/index.ts @@ -180,7 +180,7 @@ const getDocumentStoreFileChunks = async (storeId: string, fileId: string, pageN }) if (found) { found.totalChars = totalChars - found.id = entity.id + found.id = fileId found.status = entity.status } const PAGE_SIZE = 50 From 5ba9493b30db5dd891b85bc3592fea0abb124ffb Mon Sep 17 00:00:00 2001 From: Daniel D'Abate Date: Tue, 4 Jun 2024 11:11:57 +0200 Subject: [PATCH 14/29] Feature - Env variable to disable ChatFlow reuse (#2559) --- CONTRIBUTING-ZH.md | 1 + CONTRIBUTING.md | 1 + docker/.env.example | 2 ++ packages/server/.env.example | 2 ++ packages/server/src/commands/start.ts | 2 ++ packages/server/src/utils/buildChatflow.ts | 2 ++ 6 files changed, 10 insertions(+) diff --git a/CONTRIBUTING-ZH.md b/CONTRIBUTING-ZH.md index 742eb2f7989..77b65d29b13 100644 --- a/CONTRIBUTING-ZH.md +++ b/CONTRIBUTING-ZH.md @@ -124,6 +124,7 @@ Flowise 支持不同的环境变量来配置您的实例。您可以在 `package | FLOWISE_USERNAME | 登录用户名 | 字符串 | | | FLOWISE_PASSWORD | 登录密码 | 字符串 | | | FLOWISE_FILE_SIZE_LIMIT | 上传文件大小限制 | 字符串 | 50mb | +| DISABLE_CHATFLOW_REUSE | 强制为每次调用创建一个新的ChatFlow,而不是重用缓存中的现有ChatFlow | 布尔值 | | | DEBUG | 打印组件的日志 | 布尔值 | | | LOG_PATH | 存储日志文件的位置 | 字符串 | `your-path/Flowise/logs` | | LOG_LEVEL | 日志的不同级别 | 枚举字符串: `error`, `info`, `verbose`, `debug` | `info` | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 389e2f2d1bc..700e2290f8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -128,6 +128,7 @@ Flowise support different environment variables to configure your instance. You | FLOWISE_USERNAME | Username to login | String | | | FLOWISE_PASSWORD | Password to login | String | | | FLOWISE_FILE_SIZE_LIMIT | Upload File Size Limit | String | 50mb | +| DISABLE_CHATFLOW_REUSE | Forces the creation of a new ChatFlow for each call instead of reusing existing ones from cache | Boolean | | | DEBUG | Print logs from components | Boolean | | | LOG_PATH | Location where log files are stored | String | `your-path/Flowise/logs` | | LOG_LEVEL | Different levels of logs | Enum String: `error`, `info`, `verbose`, `debug` | `info` | diff --git a/docker/.env.example b/docker/.env.example index 8b1e3206546..86abbe55452 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -23,6 +23,8 @@ BLOB_STORAGE_PATH=/root/.flowise/storage # FLOWISE_SECRETKEY_OVERWRITE=myencryptionkey # FLOWISE_FILE_SIZE_LIMIT=50mb +# DISABLE_CHATFLOW_REUSE=true + # DEBUG=true # LOG_LEVEL=debug (error | warn | info | verbose | debug) # TOOL_FUNCTION_BUILTIN_DEP=crypto,fs diff --git a/packages/server/.env.example b/packages/server/.env.example index 3079209bfbc..ce50f00bf4b 100644 --- a/packages/server/.env.example +++ b/packages/server/.env.example @@ -22,6 +22,8 @@ PORT=3000 # FLOWISE_SECRETKEY_OVERWRITE=myencryptionkey # FLOWISE_FILE_SIZE_LIMIT=50mb +# DISABLE_CHATFLOW_REUSE=true + # DEBUG=true # LOG_PATH=/your_log_path/.flowise/logs # LOG_LEVEL=debug (error | warn | info | verbose | debug) diff --git a/packages/server/src/commands/start.ts b/packages/server/src/commands/start.ts index 6a58f9223bd..06529294627 100644 --- a/packages/server/src/commands/start.ts +++ b/packages/server/src/commands/start.ts @@ -32,6 +32,7 @@ export default class Start extends Command { TOOL_FUNCTION_BUILTIN_DEP: Flags.string(), TOOL_FUNCTION_EXTERNAL_DEP: Flags.string(), NUMBER_OF_PROXIES: Flags.string(), + DISABLE_CHATFLOW_REUSE: Flags.string(), DATABASE_TYPE: Flags.string(), DATABASE_PATH: Flags.string(), DATABASE_PORT: Flags.string(), @@ -93,6 +94,7 @@ export default class Start extends Command { if (flags.IFRAME_ORIGINS) process.env.IFRAME_ORIGINS = flags.IFRAME_ORIGINS if (flags.DEBUG) process.env.DEBUG = flags.DEBUG if (flags.NUMBER_OF_PROXIES) process.env.NUMBER_OF_PROXIES = flags.NUMBER_OF_PROXIES + if (flags.DISABLE_CHATFLOW_REUSE) process.env.DISABLE_CHATFLOW_REUSE = flags.DISABLE_CHATFLOW_REUSE // Authorization if (flags.FLOWISE_USERNAME) process.env.FLOWISE_USERNAME = flags.FLOWISE_USERNAME diff --git a/packages/server/src/utils/buildChatflow.ts b/packages/server/src/utils/buildChatflow.ts index 3fcf03fac2f..749faea7d8e 100644 --- a/packages/server/src/utils/buildChatflow.ts +++ b/packages/server/src/utils/buildChatflow.ts @@ -187,6 +187,7 @@ export const utilBuildChatflow = async (req: Request, socketIO?: Server, isInter const prependMessages = incomingInput.history /* Reuse the flow without having to rebuild (to avoid duplicated upsert, recomputation, reinitialization of memory) when all these conditions met: + * - Reuse of flows is not disabled * - Node Data already exists in pool * - Still in sync (i.e the flow has not been modified since) * - Existing overrideConfig and new overrideConfig are the same @@ -194,6 +195,7 @@ export const utilBuildChatflow = async (req: Request, socketIO?: Server, isInter ***/ const isFlowReusable = () => { return ( + process.env.DISABLE_CHATFLOW_REUSE !== 'true' && Object.prototype.hasOwnProperty.call(appServer.chatflowPool.activeChatflows, chatflowid) && appServer.chatflowPool.activeChatflows[chatflowid].inSync && appServer.chatflowPool.activeChatflows[chatflowid].endingNodeData && From 4ec8376efa87d93745a6dbecabdf9ab3f8a5ff27 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Tue, 4 Jun 2024 15:44:27 +0100 Subject: [PATCH 15/29] Bugfix/get rid of double quotes when replacing variable value (#2577) get rid of double quotes when replacing variable value --- packages/server/src/utils/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts index c9ea2682637..0fd7f290108 100644 --- a/packages/server/src/utils/index.ts +++ b/packages/server/src/utils/index.ts @@ -782,7 +782,13 @@ export const getVariableValue = ( const variableValue = variableDict[path] // Replace all occurrence if (typeof variableValue === 'object') { - returnVal = returnVal.split(path).join(JSON.stringify(JSON.stringify(variableValue))) + const stringifiedValue = JSON.stringify(JSON.stringify(variableValue)) + if (stringifiedValue.startsWith('"') && stringifiedValue.endsWith('"')) { + // get rid of the double quotes + returnVal = returnVal.split(path).join(stringifiedValue.substring(1, stringifiedValue.length - 1)) + } else { + returnVal = returnVal.split(path).join(JSON.stringify(variableValue).replace(/"/g, '\\"')) + } } else { returnVal = returnVal.split(path).join(variableValue) } From 5a73eaa58822fb4f3fd224631d3a3c7715b03d82 Mon Sep 17 00:00:00 2001 From: Erasmo Pinheiro <85361327+erasmo-pinheiro@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:23:30 -0300 Subject: [PATCH 16/29] fix: Change the CMD flowise command in Dockerfile to be the same as in the document (#2563) * fix: Change the CMD flowise command to be the same as in the documentation. * Remove unnecessary npx command from dockerfile * Command was changed by the entrypoint in Docker Composer --------- Co-authored-by: Erasmo De Souza Pinheiro --- docker/Dockerfile | 2 +- docker/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 261ecdaf00c..6fb59404cda 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -18,4 +18,4 @@ RUN npm install -g flowise WORKDIR /data -CMD "flowise" +ENTRYPOINT ["flowise", "start"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index c23931d5794..55f890e69ba 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -33,4 +33,4 @@ services: - '${PORT}:${PORT}' volumes: - ~/.flowise:/root/.flowise - command: /bin/sh -c "sleep 3; flowise start" + entrypoint: /bin/sh -c "sleep 3; flowise start" From 582dcc85083eec441ca91ce10d140dc0398c58dd Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Tue, 4 Jun 2024 18:45:45 +0100 Subject: [PATCH 17/29] Feature/add status check ping (#2579) add status check ping --- packages/server/src/controllers/ping/index.ts | 13 +++++++++++++ packages/server/src/index.ts | 3 ++- packages/server/src/routes/index.ts | 2 ++ packages/server/src/routes/ping/index.ts | 8 ++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 packages/server/src/controllers/ping/index.ts create mode 100644 packages/server/src/routes/ping/index.ts diff --git a/packages/server/src/controllers/ping/index.ts b/packages/server/src/controllers/ping/index.ts new file mode 100644 index 00000000000..97f9af4dcec --- /dev/null +++ b/packages/server/src/controllers/ping/index.ts @@ -0,0 +1,13 @@ +import { Request, Response, NextFunction } from 'express' + +const getPing = async (req: Request, res: Response, next: NextFunction) => { + try { + return res.status(200).send('pong') + } catch (error) { + next(error) + } +} + +export default { + getPing +} diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 7cbe5968674..5e33c63c529 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -137,7 +137,8 @@ export class App { '/api/v1/feedback', '/api/v1/leads', '/api/v1/get-upload-file', - '/api/v1/ip' + '/api/v1/ip', + '/api/v1/ping' ] this.app.use((req, res, next) => { if (/\/api\/v1\//i.test(req.url)) { diff --git a/packages/server/src/routes/index.ts b/packages/server/src/routes/index.ts index b4ae9d885d4..9c6e6508725 100644 --- a/packages/server/src/routes/index.ts +++ b/packages/server/src/routes/index.ts @@ -38,9 +38,11 @@ import vectorRouter from './vectors' import verifyRouter from './verify' import versionRouter from './versions' import upsertHistoryRouter from './upsert-history' +import pingRouter from './ping' const router = express.Router() +router.use('/ping', pingRouter) router.use('/apikey', apikeyRouter) router.use('/assistants', assistantsRouter) router.use('/chatflows', chatflowsRouter) diff --git a/packages/server/src/routes/ping/index.ts b/packages/server/src/routes/ping/index.ts new file mode 100644 index 00000000000..b026710e86c --- /dev/null +++ b/packages/server/src/routes/ping/index.ts @@ -0,0 +1,8 @@ +import express from 'express' +import pingController from '../../controllers/ping' +const router = express.Router() + +// GET +router.get('/', pingController.getPing) + +export default router From e0a03ad46d237b0b93c146185ee28f961d7b6696 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 6 Jun 2024 02:25:27 +0530 Subject: [PATCH 18/29] HTML Embed Chat popup configuration updated (#2583) * HTML Embed Chat popup configuration updated * HTML Embed Chat popup configuration * Update EmbedChat.jsx update spacing to be consistent --------- Co-authored-by: Henry Heng --- packages/ui/src/views/chatflows/EmbedChat.jsx | 56 +++++++++++++++---- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/packages/ui/src/views/chatflows/EmbedChat.jsx b/packages/ui/src/views/chatflows/EmbedChat.jsx index 25212a0225f..d2c4f8ae7b9 100644 --- a/packages/ui/src/views/chatflows/EmbedChat.jsx +++ b/packages/ui/src/views/chatflows/EmbedChat.jsx @@ -88,7 +88,8 @@ const buttonConfig = (isReact = false) => { backgroundColor: "#3B81F6", right: 20, bottom: 20, - size: "medium", + size: 48, // small | medium | large | number + dragAndDrop: true, iconColor: "white", customIconSrc: "https://raw.githubusercontent.com/walkxcode/dashboard-icons/main/svg/google-messages.svg", }` @@ -96,7 +97,8 @@ const buttonConfig = (isReact = false) => { backgroundColor: "#3B81F6", right: 20, bottom: 20, - size: "medium", + size: 48, // small | medium | large | number + dragAndDrop: true, iconColor: "white", customIconSrc: "https://raw.githubusercontent.com/walkxcode/dashboard-icons/main/svg/google-messages.svg", }` @@ -105,7 +107,11 @@ const buttonConfig = (isReact = false) => { const chatwindowConfig = (isReact = false) => { return isReact ? `chatWindow: { - welcomeMessage: "Hello! This is custom welcome message", + showTitle: true, + title: 'Flowise Bot', + titleAvatarSrc: 'https://raw.githubusercontent.com/walkxcode/dashboard-icons/main/svg/google-messages.svg', + welcomeMessage: 'Hello! This is custom welcome message', + errorMessage: 'This is a custom error message', backgroundColor: "#ffffff", height: 700, width: 400, @@ -124,14 +130,29 @@ const chatwindowConfig = (isReact = false) => { avatarSrc: "https://raw.githubusercontent.com/zahidkhawaja/langchain-chat-nextjs/main/public/usericon.png", }, textInput: { - placeholder: "Type your question", - backgroundColor: "#ffffff", - textColor: "#303235", - sendButtonColor: "#3B81F6", + placeholder: 'Type your question', + backgroundColor: '#ffffff', + textColor: '#303235', + sendButtonColor: '#3B81F6', + maxChars: 50, + maxCharsWarningMessage: 'You exceeded the characters limit. Please input less than 50 characters.', + }, + feedback: { + color: '#303235', + }, + footer: { + textColor: '#303235', + text: 'Powered by', + company: 'Flowise', + companyLink: 'https://flowiseai.com', } }` : `chatWindow: { - welcomeMessage: "Hello! This is custom welcome message", + showTitle: true, + title: 'Flowise Bot', + titleAvatarSrc: 'https://raw.githubusercontent.com/walkxcode/dashboard-icons/main/svg/google-messages.svg', + welcomeMessage: 'Hello! This is custom welcome message', + errorMessage: 'This is a custom error message', backgroundColor: "#ffffff", height: 700, width: 400, @@ -150,10 +171,21 @@ const chatwindowConfig = (isReact = false) => { avatarSrc: "https://raw.githubusercontent.com/zahidkhawaja/langchain-chat-nextjs/main/public/usericon.png", }, textInput: { - placeholder: "Type your question", - backgroundColor: "#ffffff", - textColor: "#303235", - sendButtonColor: "#3B81F6", + placeholder: 'Type your question', + backgroundColor: '#ffffff', + textColor: '#303235', + sendButtonColor: '#3B81F6', + maxChars: 50, + maxCharsWarningMessage: 'You exceeded the characters limit. Please input less than 50 characters.', + }, + feedback: { + color: '#303235', + }, + footer: { + textColor: '#303235', + text: 'Powered by', + company: 'Flowise', + companyLink: 'https://flowiseai.com', } }` } From 5899e50c5426e350ae772ac0f07fed6f4c08d881 Mon Sep 17 00:00:00 2001 From: toi500 <138339291+toi500@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:55:45 +0200 Subject: [PATCH 19/29] Adding Agentflow Template (#2586) adding agentflow template Co-authored-by: toi500 --- .../agentflows/Prompt Engineering Team.json | 557 ++++++++++++++++++ 1 file changed, 557 insertions(+) create mode 100644 packages/server/marketplaces/agentflows/Prompt Engineering Team.json diff --git a/packages/server/marketplaces/agentflows/Prompt Engineering Team.json b/packages/server/marketplaces/agentflows/Prompt Engineering Team.json new file mode 100644 index 00000000000..43b98918676 --- /dev/null +++ b/packages/server/marketplaces/agentflows/Prompt Engineering Team.json @@ -0,0 +1,557 @@ +{ + "description": "Prompt engineering team working together to craft Worker Prompts for your AgentFlow.", + "nodes": [ + { + "id": "supervisor_0", + "position": { + "x": 485.1357844985962, + "y": 324.1719351589139 + }, + "type": "customNode", + "data": { + "id": "supervisor_0", + "label": "Supervisor", + "version": 1, + "name": "supervisor", + "type": "Supervisor", + "baseClasses": ["Supervisor"], + "category": "Multi Agents", + "inputParams": [ + { + "label": "Supervisor Name", + "name": "supervisorName", + "type": "string", + "placeholder": "Supervisor", + "default": "Supervisor", + "id": "supervisor_0-input-supervisorName-string" + }, + { + "label": "Supervisor Prompt", + "name": "supervisorPrompt", + "type": "string", + "description": "Prompt must contains {team_members}", + "rows": 4, + "default": "You are a supervisor tasked with managing a conversation between the following workers: {team_members}.\nGiven the following user request, respond with the worker to act next.\nEach worker will perform a task and respond with their results and status.\nWhen finished, respond with FINISH.\nSelect strategically to minimize the number of steps taken.", + "additionalParams": true, + "id": "supervisor_0-input-supervisorPrompt-string" + }, + { + "label": "Recursion Limit", + "name": "recursionLimit", + "type": "number", + "description": "Maximum number of times a call can recurse. If not provided, defaults to 100.", + "default": 100, + "additionalParams": true, + "id": "supervisor_0-input-recursionLimit-number" + } + ], + "inputAnchors": [ + { + "label": "Tool Calling Chat Model", + "name": "model", + "type": "BaseChatModel", + "description": "Only compatible with models that are capable of function calling: ChatOpenAI, ChatMistral, ChatAnthropic, ChatGoogleGenerativeAI, GroqChat. Best result with GPT-4 model", + "id": "supervisor_0-input-model-BaseChatModel" + }, + { + "label": "Input Moderation", + "description": "Detect text that could generate harmful output and prevent it from being sent to the language model", + "name": "inputModeration", + "type": "Moderation", + "optional": true, + "list": true, + "id": "supervisor_0-input-inputModeration-Moderation" + } + ], + "inputs": { + "supervisorName": "Supervisor", + "supervisorPrompt": "You are a supervisor tasked with managing a conversation between the following workers: {team_members}.\nGiven the following user request, respond with the worker to act next.\nEach worker will perform a task and respond with their results and status.\nWhen finished, respond with FINISH.\nSelect strategically to minimize the number of steps taken.", + "model": "{{chatOpenAI_0.data.instance}}", + "recursionLimit": 100, + "inputModeration": "" + }, + "outputAnchors": [ + { + "id": "supervisor_0-output-supervisor-Supervisor", + "name": "supervisor", + "label": "Supervisor", + "description": "", + "type": "Supervisor" + } + ], + "outputs": {}, + "selected": false + }, + "width": 300, + "height": 430, + "selected": false, + "positionAbsolute": { + "x": 485.1357844985962, + "y": 324.1719351589139 + }, + "dragging": false + }, + { + "id": "worker_0", + "position": { + "x": 807.6882204663332, + "y": 326.15881845953294 + }, + "type": "customNode", + "data": { + "id": "worker_0", + "label": "Worker", + "version": 1, + "name": "worker", + "type": "Worker", + "baseClasses": ["Worker"], + "category": "Multi Agents", + "inputParams": [ + { + "label": "Worker Name", + "name": "workerName", + "type": "string", + "placeholder": "Worker", + "id": "worker_0-input-workerName-string" + }, + { + "label": "Worker Prompt", + "name": "workerPrompt", + "type": "string", + "rows": 4, + "default": "You are a research assistant who can search for up-to-date info using search engine.", + "id": "worker_0-input-workerPrompt-string" + }, + { + "label": "Format Prompt Values", + "name": "promptValues", + "type": "json", + "optional": true, + "acceptVariable": true, + "list": true, + "id": "worker_0-input-promptValues-json" + }, + { + "label": "Max Iterations", + "name": "maxIterations", + "type": "number", + "optional": true, + "id": "worker_0-input-maxIterations-number" + } + ], + "inputAnchors": [ + { + "label": "Tools", + "name": "tools", + "type": "Tool", + "list": true, + "optional": true, + "id": "worker_0-input-tools-Tool" + }, + { + "label": "Supervisor", + "name": "supervisor", + "type": "Supervisor", + "id": "worker_0-input-supervisor-Supervisor" + }, + { + "label": "Tool Calling Chat Model", + "name": "model", + "type": "BaseChatModel", + "optional": true, + "description": "Only compatible with models that are capable of function calling: ChatOpenAI, ChatMistral, ChatAnthropic, ChatGoogleGenerativeAI, ChatVertexAI, GroqChat. If not specified, supervisor's model will be used", + "id": "worker_0-input-model-BaseChatModel" + } + ], + "inputs": { + "workerName": " Prompt Creator", + "workerPrompt": "You are a Prompt Engineer. Your job is to craft system prompts for AI Agents based on user requests.\n\nHere is an example:\n\n1. User asks you to craft two AI Agent prompt messages for \"researching leads and creating personalized email drafts for the sales team\".\n\n2. You generate the following:\n\nAGENT 1\n\nName: \nLead Research\n\nSytyem Prompt: \nAs a member of the sales team at company, your mission is to explore the digital landscape for potential leads. Equipped with advanced tools and a strategic approach, you analyze data, trends, and interactions to discover opportunities that others might miss. Your efforts are vital in creating pathways for meaningful engagements and driving the company's growth.\nYour goal is to identify high-value leads that align with our ideal customer profile.\nPerform a thorough analysis of lead_company, a company that has recently shown interest in our solutions. Use all available data sources to create a detailed profile, concentrating on key decision-makers, recent business developments, and potential needs that match our offerings. This task is essential for effectively customizing our engagement strategy.\nAvoid making assumptions and only use information you are certain about.\nYou should produce a comprehensive report on lead_person, including company background, key personnel, recent milestones, and identified needs. Emphasize potential areas where our solutions can add value and suggest tailored engagement strategies. Pass the info to Lead Sales Representative.\n\nAGENT 2\n\nName: \nLead Sales Representative\n\nSystem Prompt: \nYou play a crucial role within company as the link between potential clients and the solutions they need. By crafting engaging, personalized messages, you not only inform leads about our company offerings but also make them feel valued and understood. Your role is essential in transforming interest into action, guiding leads from initial curiosity to committed engagement.\nYour goal is to nurture leads with tailored, compelling communications.\nLeveraging the insights from the lead profiling report on lead_company, create a personalized outreach campaign targeting lead_person, the position of lead_company. he campaign should highlight their recent lead_activity and demonstrate how our solutions can support their objectives. Your communication should align with lead_company's company culture and values, showcasing a thorough understanding of their business and needs. Avoid making assumptions and use only verified information.\nThe output should be a series of personalized email drafts customized for lead_company, specifically addressing lead_person. Each draft should present a compelling narrative that connects our solutions to their recent accomplishments and future goals. Ensure the tone is engaging, professional, and consistent with lead_company's corporate identity. Keep in natural, don't use strange and fancy words.\n\n3. IMPORTANT: Notice how the prompts in this example work together and are connected by \"Pass the info to Lead Sales Representative.\" The first prompt focuses on researching leads, while the second leverages that information to create personalized email drafts. This creates a cohesive workflow for the AI Agents.\n\n4. If the AI agent needs to use a tool to perform its task, it will indicate this on the system prompt, but you will not write any code for them (they already have the code for the tools they use).", + "tools": "", + "supervisor": "{{supervisor_0.data.instance}}", + "model": "", + "promptValues": "", + "maxIterations": "" + }, + "outputAnchors": [ + { + "id": "worker_0-output-worker-Worker", + "name": "worker", + "label": "Worker", + "description": "", + "type": "Worker" + } + ], + "outputs": {}, + "selected": false + }, + "width": 300, + "height": 807, + "selected": false, + "positionAbsolute": { + "x": 807.6882204663332, + "y": 326.15881845953294 + }, + "dragging": false + }, + { + "id": "worker_1", + "position": { + "x": 1149.1084792409956, + "y": 324.68074278187794 + }, + "type": "customNode", + "data": { + "id": "worker_1", + "label": "Worker", + "version": 1, + "name": "worker", + "type": "Worker", + "baseClasses": ["Worker"], + "category": "Multi Agents", + "inputParams": [ + { + "label": "Worker Name", + "name": "workerName", + "type": "string", + "placeholder": "Worker", + "id": "worker_1-input-workerName-string" + }, + { + "label": "Worker Prompt", + "name": "workerPrompt", + "type": "string", + "rows": 4, + "default": "You are a research assistant who can search for up-to-date info using search engine.", + "id": "worker_1-input-workerPrompt-string" + }, + { + "label": "Format Prompt Values", + "name": "promptValues", + "type": "json", + "optional": true, + "acceptVariable": true, + "list": true, + "id": "worker_1-input-promptValues-json" + }, + { + "label": "Max Iterations", + "name": "maxIterations", + "type": "number", + "optional": true, + "id": "worker_1-input-maxIterations-number" + } + ], + "inputAnchors": [ + { + "label": "Tools", + "name": "tools", + "type": "Tool", + "list": true, + "optional": true, + "id": "worker_1-input-tools-Tool" + }, + { + "label": "Supervisor", + "name": "supervisor", + "type": "Supervisor", + "id": "worker_1-input-supervisor-Supervisor" + }, + { + "label": "Tool Calling Chat Model", + "name": "model", + "type": "BaseChatModel", + "optional": true, + "description": "Only compatible with models that are capable of function calling: ChatOpenAI, ChatMistral, ChatAnthropic, ChatGoogleGenerativeAI, ChatVertexAI, GroqChat. If not specified, supervisor's model will be used", + "id": "worker_1-input-model-BaseChatModel" + } + ], + "inputs": { + "workerName": "Prompt Reviewer", + "workerPrompt": "You are a meticulous and insightful AI specializing in reviewing and enhancing custom prompts created for other AI agents. Your role is crucial in ensuring that the prompts are not only accurate and clear but also optimized for the best performance of the AI agents. You pay close attention to detail and strive for perfection in prompt design. Your goal is to review and improve the custom prompts created by the prompt_creator AI. Examine the provided system prompt thoroughly, identifying any areas that can be improved for clarity, specificity, or effectiveness. Suggest modifications that enhance the prompt's structure, language, and overall quality. Ensure that the final prompt is free from ambiguity and provides precise, actionable instructions for the AI agent. The output should be an improved version of the system prompt, with clear annotations or explanations of the changes made to enhance its quality and effectiveness.\n", + "tools": "", + "supervisor": "{{supervisor_0.data.instance}}", + "model": "", + "promptValues": "", + "maxIterations": "" + }, + "outputAnchors": [ + { + "id": "worker_1-output-worker-Worker", + "name": "worker", + "label": "Worker", + "description": "", + "type": "Worker" + } + ], + "outputs": {}, + "selected": false + }, + "width": 300, + "height": 807, + "selected": false, + "positionAbsolute": { + "x": 1149.1084792409956, + "y": 324.68074278187794 + }, + "dragging": false + }, + { + "id": "chatOpenAI_0", + "position": { + "x": 134.3531319624069, + "y": 318.3354688270578 + }, + "type": "customNode", + "data": { + "id": "chatOpenAI_0", + "label": "ChatOpenAI", + "version": 6, + "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": "asyncOptions", + "loadMethod": "listModels", + "default": "gpt-3.5-turbo", + "id": "chatOpenAI_0-input-modelName-asyncOptions" + }, + { + "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" + }, + { + "label": "Allow Image Uploads", + "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, and Conversational Agent", + "default": false, + "optional": true, + "id": "chatOpenAI_0-input-allowImageUploads-boolean" + }, + { + "label": "Image Resolution", + "description": "This parameter controls the resolution in which the model views the image.", + "name": "imageResolution", + "type": "options", + "options": [ + { + "label": "Low", + "name": "low" + }, + { + "label": "High", + "name": "high" + }, + { + "label": "Auto", + "name": "auto" + } + ], + "default": "low", + "optional": false, + "additionalParams": true, + "id": "chatOpenAI_0-input-imageResolution-options" + } + ], + "inputAnchors": [ + { + "label": "Cache", + "name": "cache", + "type": "BaseCache", + "optional": true, + "id": "chatOpenAI_0-input-cache-BaseCache" + } + ], + "inputs": { + "cache": "", + "modelName": "gpt-4o", + "temperature": "0.4", + "maxTokens": "", + "topP": "", + "frequencyPenalty": "", + "presencePenalty": "", + "timeout": "", + "basepath": "", + "baseOptions": "", + "allowImageUploads": "", + "imageResolution": "low" + }, + "outputAnchors": [ + { + "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "name": "chatOpenAI", + "label": "ChatOpenAI", + "description": "Wrapper around OpenAI large language models that use the Chat endpoint", + "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "width": 300, + "height": 668, + "selected": false, + "positionAbsolute": { + "x": 134.3531319624069, + "y": 318.3354688270578 + }, + "dragging": false + }, + { + "id": "stickyNote_0", + "position": { + "x": -204.73108806492982, + "y": 321.243965769327 + }, + "type": "stickyNote", + "data": { + "id": "stickyNote_0", + "label": "Sticky Note", + "version": 1, + "name": "stickyNote", + "type": "StickyNote", + "baseClasses": ["StickyNote"], + "category": "Utilities", + "description": "Add a sticky note", + "inputParams": [ + { + "label": "", + "name": "note", + "type": "string", + "rows": 1, + "placeholder": "Type something here", + "optional": true, + "id": "stickyNote_0-input-note-string" + } + ], + "inputAnchors": [], + "inputs": { + "note": "How it works?\nSimply explain the app you want to create, and it will generate the system prompt for each Worker.\n\nExample:\nI want to create an AI app with two AI agents. One agent would perform a Google search using the SerpApi tool on any topic provided by the user. The other agent would then send the information to my email,\ntest@test.test, using a custom tool at its disposal." + }, + "outputAnchors": [ + { + "id": "stickyNote_0-output-stickyNote-StickyNote", + "name": "stickyNote", + "label": "StickyNote", + "description": "Add a sticky note", + "type": "StickyNote" + } + ], + "outputs": {}, + "selected": false + }, + "width": 300, + "height": 283, + "selected": false, + "positionAbsolute": { + "x": -204.73108806492982, + "y": 321.243965769327 + }, + "dragging": false + } + ], + "edges": [ + { + "source": "supervisor_0", + "sourceHandle": "supervisor_0-output-supervisor-Supervisor", + "target": "worker_0", + "targetHandle": "worker_0-input-supervisor-Supervisor", + "type": "buttonedge", + "id": "supervisor_0-supervisor_0-output-supervisor-Supervisor-worker_0-worker_0-input-supervisor-Supervisor" + }, + { + "source": "supervisor_0", + "sourceHandle": "supervisor_0-output-supervisor-Supervisor", + "target": "worker_1", + "targetHandle": "worker_1-input-supervisor-Supervisor", + "type": "buttonedge", + "id": "supervisor_0-supervisor_0-output-supervisor-Supervisor-worker_1-worker_1-input-supervisor-Supervisor" + }, + { + "source": "chatOpenAI_0", + "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", + "target": "supervisor_0", + "targetHandle": "supervisor_0-input-model-BaseChatModel", + "type": "buttonedge", + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-supervisor_0-supervisor_0-input-model-BaseChatModel" + } + ] +} From cb93d9d557042df2b9fa0b7edba2c827a0e759d8 Mon Sep 17 00:00:00 2001 From: Daniel D'Abate Date: Thu, 6 Jun 2024 15:17:35 +0200 Subject: [PATCH 20/29] Bugfix - JS function "execute" from node crashing the frontend and response is hidden (#2589) * Bugfix - Fix crash when executing JS function from node and fix hidden response * add toString() to code executed result * Change height of CodeEditor to make it bigger, but still make the result visible below. --------- Co-authored-by: Henry Heng --- packages/ui/src/ui-component/dialog/ExpandTextDialog.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/ui-component/dialog/ExpandTextDialog.jsx b/packages/ui/src/ui-component/dialog/ExpandTextDialog.jsx index c93655fe176..068f26c100b 100644 --- a/packages/ui/src/ui-component/dialog/ExpandTextDialog.jsx +++ b/packages/ui/src/ui-component/dialog/ExpandTextDialog.jsx @@ -78,7 +78,7 @@ const ExpandTextDialog = ({ show, dialogProps, onCancel, onConfirm }) => { useEffect(() => { if (executeCustomFunctionNodeApi.error) { if (typeof executeCustomFunctionNodeApi.error === 'object' && executeCustomFunctionNodeApi.error?.response?.data) { - setCodeExecutedResult(executeCustomFunctionNodeApi.error?.response?.data) + setCodeExecutedResult(JSON.stringify(executeCustomFunctionNodeApi.error?.response?.data, null, 2)) } else if (typeof executeCustomFunctionNodeApi.error === 'string') { setCodeExecutedResult(executeCustomFunctionNodeApi.error) } @@ -100,7 +100,7 @@ const ExpandTextDialog = ({ show, dialogProps, onCancel, onConfirm }) => { borderColor: theme.palette.grey['500'], borderRadius: '12px', height: '100%', - maxHeight: languageType === 'js' ? 'calc(100vh - 250px)' : 'calc(100vh - 220px)', + maxHeight: languageType === 'js' ? 'calc(100vh - 330px)' : 'calc(100vh - 220px)', overflowX: 'hidden', backgroundColor: 'white' }} @@ -108,7 +108,7 @@ const ExpandTextDialog = ({ show, dialogProps, onCancel, onConfirm }) => { {
Date: Fri, 7 Jun 2024 13:04:25 +0200 Subject: [PATCH 21/29] Bugfix - Add x-forwarded-proto as source for http protocol for base url and add base url field to ChatflowTool (#2592) --- .../nodes/tools/ChatflowTool/ChatflowTool.ts | 14 ++++++++++++-- packages/server/src/utils/buildChatflow.ts | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts b/packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts index e9a0811ebe8..df5e50fe1c7 100644 --- a/packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts +++ b/packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts @@ -22,7 +22,7 @@ class ChatflowTool_Tools implements INode { constructor() { this.label = 'Chatflow Tool' this.name = 'ChatflowTool' - this.version = 1.0 + this.version = 2.0 this.type = 'ChatflowTool' this.icon = 'chatflowTool.svg' this.category = 'Tools' @@ -56,6 +56,16 @@ class ChatflowTool_Tools implements INode { placeholder: 'State of the Union QA - useful for when you need to ask questions about the most recent state of the union address.' }, + { + label: 'Base URL', + name: 'baseURL', + type: 'string', + description: + 'Base URL to Flowise. By default, it is the URL of the incoming request. Useful when you need to execute the Chatflow through an alternative route.', + placeholder: 'http://localhost:3000', + optional: true, + additionalParams: true + }, { label: 'Use Question from Chat', name: 'useQuestionFromChat', @@ -107,7 +117,7 @@ class ChatflowTool_Tools implements INode { const useQuestionFromChat = nodeData.inputs?.useQuestionFromChat as boolean const customInput = nodeData.inputs?.customInput as string - const baseURL = options.baseURL as string + const baseURL = (nodeData.inputs?.baseURL as string) || (options.baseURL as string) const credentialData = await getCredentialData(nodeData.credential ?? '', options) const chatflowApiKey = getCredentialParam('chatflowApiKey', credentialData, nodeData) diff --git a/packages/server/src/utils/buildChatflow.ts b/packages/server/src/utils/buildChatflow.ts index 749faea7d8e..85d4472bcad 100644 --- a/packages/server/src/utils/buildChatflow.ts +++ b/packages/server/src/utils/buildChatflow.ts @@ -54,7 +54,9 @@ export const utilBuildChatflow = async (req: Request, socketIO?: Server, isInter try { const appServer = getRunningExpressApp() const chatflowid = req.params.id - const baseURL = `${req.protocol}://${req.get('host')}` + + const httpProtocol = req.get('x-forwarded-proto') || req.protocol + const baseURL = `${httpProtocol}://${req.get('host')}` let incomingInput: IncomingInput = req.body let nodeToExecuteData: INodeData From c8939dc2a6f82900d6fb58c3fe9628c61d0c22fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E7=9F=A5=E7=81=AB=20Shiranui?= Date: Fri, 7 Jun 2024 19:14:06 +0800 Subject: [PATCH 22/29] Add data source adapter of MariaDB (#2595) fix(datasource.ts): add mariadb --- packages/server/src/DataSource.ts | 17 +++++ .../migrations/mariadb/1693840429259-Init.ts | 64 +++++++++++++++++++ .../mariadb/1693997791471-ModifyChatFlow.ts | 11 ++++ .../1693999022236-ModifyChatMessage.ts | 11 ++++ .../mariadb/1693999261583-ModifyCredential.ts | 11 ++++ .../mariadb/1694001465232-ModifyTool.ts | 11 ++++ .../mariadb/1694099200729-AddApiConfig.ts | 12 ++++ .../mariadb/1694432361423-AddAnalytic.ts | 12 ++++ .../mariadb/1694658767766-AddChatHistory.ts | 41 ++++++++++++ .../1699325775451-AddAssistantEntity.ts | 21 ++++++ ...1699481607341-AddUsedToolsToChatMessage.ts | 12 ++++ .../1699900910291-AddCategoryToChatFlow.ts | 12 ++++ ...1021237-AddFileAnnotationsToChatMessage.ts | 12 ++++ ...01788586491-AddFileUploadsToChatMessage.ts | 12 ++++ .../1702200925471-AddVariableEntity.ts | 21 ++++++ .../mariadb/1706364937060-AddSpeechToText.ts | 12 ++++ .../mariadb/1707213626553-AddFeedback.ts | 22 +++++++ .../1709814301358-AddUpsertHistoryEntity.ts | 21 ++++++ .../mariadb/1710832127079-AddLead.ts | 22 +++++++ .../1711538023578-AddLeadToChatMessage.ts | 12 ++++ .../mariadb/1711637331047-AddDocumentStore.ts | 37 +++++++++++ ...79514451-AddAgentReasoningToChatMessage.ts | 12 ++++ .../1766759476232-AddTypeToChatFlow.ts | 12 ++++ .../src/database/migrations/mariadb/index.ts | 47 ++++++++++++++ 24 files changed, 477 insertions(+) create mode 100644 packages/server/src/database/migrations/mariadb/1693840429259-Init.ts create mode 100644 packages/server/src/database/migrations/mariadb/1693997791471-ModifyChatFlow.ts create mode 100644 packages/server/src/database/migrations/mariadb/1693999022236-ModifyChatMessage.ts create mode 100644 packages/server/src/database/migrations/mariadb/1693999261583-ModifyCredential.ts create mode 100644 packages/server/src/database/migrations/mariadb/1694001465232-ModifyTool.ts create mode 100644 packages/server/src/database/migrations/mariadb/1694099200729-AddApiConfig.ts create mode 100644 packages/server/src/database/migrations/mariadb/1694432361423-AddAnalytic.ts create mode 100644 packages/server/src/database/migrations/mariadb/1694658767766-AddChatHistory.ts create mode 100644 packages/server/src/database/migrations/mariadb/1699325775451-AddAssistantEntity.ts create mode 100644 packages/server/src/database/migrations/mariadb/1699481607341-AddUsedToolsToChatMessage.ts create mode 100644 packages/server/src/database/migrations/mariadb/1699900910291-AddCategoryToChatFlow.ts create mode 100644 packages/server/src/database/migrations/mariadb/1700271021237-AddFileAnnotationsToChatMessage.ts create mode 100644 packages/server/src/database/migrations/mariadb/1701788586491-AddFileUploadsToChatMessage.ts create mode 100644 packages/server/src/database/migrations/mariadb/1702200925471-AddVariableEntity.ts create mode 100644 packages/server/src/database/migrations/mariadb/1706364937060-AddSpeechToText.ts create mode 100644 packages/server/src/database/migrations/mariadb/1707213626553-AddFeedback.ts create mode 100644 packages/server/src/database/migrations/mariadb/1709814301358-AddUpsertHistoryEntity.ts create mode 100644 packages/server/src/database/migrations/mariadb/1710832127079-AddLead.ts create mode 100644 packages/server/src/database/migrations/mariadb/1711538023578-AddLeadToChatMessage.ts create mode 100644 packages/server/src/database/migrations/mariadb/1711637331047-AddDocumentStore.ts create mode 100644 packages/server/src/database/migrations/mariadb/1714679514451-AddAgentReasoningToChatMessage.ts create mode 100644 packages/server/src/database/migrations/mariadb/1766759476232-AddTypeToChatFlow.ts create mode 100644 packages/server/src/database/migrations/mariadb/index.ts diff --git a/packages/server/src/DataSource.ts b/packages/server/src/DataSource.ts index 483c070eeb0..811f62b6aa5 100644 --- a/packages/server/src/DataSource.ts +++ b/packages/server/src/DataSource.ts @@ -6,6 +6,7 @@ import { getUserHome } from './utils' import { entities } from './database/entities' import { sqliteMigrations } from './database/migrations/sqlite' import { mysqlMigrations } from './database/migrations/mysql' +import { mariadbMigrations } from './database/migrations/mariadb' import { postgresMigrations } from './database/migrations/postgres' let appDataSource: DataSource @@ -44,6 +45,22 @@ export const init = async (): Promise => { ssl: getDatabaseSSLFromEnv() }) break + case 'mariadb': + appDataSource = new DataSource({ + type: 'mariadb', + host: process.env.DATABASE_HOST, + port: parseInt(process.env.DATABASE_PORT || '3306'), + username: process.env.DATABASE_USER, + password: process.env.DATABASE_PASSWORD, + database: process.env.DATABASE_NAME, + charset: 'utf8mb4', + synchronize: false, + migrationsRun: false, + entities: Object.values(entities), + migrations: mariadbMigrations, + ssl: getDatabaseSSLFromEnv() + }) + break case 'postgres': appDataSource = new DataSource({ type: 'postgres', diff --git a/packages/server/src/database/migrations/mariadb/1693840429259-Init.ts b/packages/server/src/database/migrations/mariadb/1693840429259-Init.ts new file mode 100644 index 00000000000..00abdf9b5dc --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1693840429259-Init.ts @@ -0,0 +1,64 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class Init1693840429259 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`chat_flow\` ( + \`id\` varchar(36) NOT NULL, + \`name\` varchar(255) NOT NULL, + \`flowData\` text NOT NULL, + \`deployed\` tinyint DEFAULT NULL, + \`isPublic\` tinyint DEFAULT NULL, + \`apikeyid\` varchar(255) DEFAULT NULL, + \`chatbotConfig\` varchar(255) DEFAULT NULL, + \`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + \`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`chat_message\` ( + \`id\` varchar(36) NOT NULL, + \`role\` varchar(255) NOT NULL, + \`chatflowid\` varchar(255) NOT NULL, + \`content\` text NOT NULL, + \`sourceDocuments\` varchar(255) DEFAULT NULL, + \`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`), + KEY \`IDX_e574527322272fd838f4f0f3d3\` (\`chatflowid\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`credential\` ( + \`id\` varchar(36) NOT NULL, + \`name\` varchar(255) NOT NULL, + \`credentialName\` varchar(255) NOT NULL, + \`encryptedData\` varchar(255) NOT NULL, + \`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + \`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`tool\` ( + \`id\` varchar(36) NOT NULL, + \`name\` varchar(255) NOT NULL, + \`description\` text NOT NULL, + \`color\` varchar(255) NOT NULL, + \`iconSrc\` varchar(255) DEFAULT NULL, + \`schema\` varchar(255) DEFAULT NULL, + \`func\` varchar(255) DEFAULT NULL, + \`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + \`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE chat_flow`) + await queryRunner.query(`DROP TABLE chat_message`) + await queryRunner.query(`DROP TABLE credential`) + await queryRunner.query(`DROP TABLE tool`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1693997791471-ModifyChatFlow.ts b/packages/server/src/database/migrations/mariadb/1693997791471-ModifyChatFlow.ts new file mode 100644 index 00000000000..d0023b67935 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1693997791471-ModifyChatFlow.ts @@ -0,0 +1,11 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class ModifyChatFlow1693997791471 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_flow\` MODIFY \`chatbotConfig\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_flow\` MODIFY \`chatbotConfig\` VARCHAR;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1693999022236-ModifyChatMessage.ts b/packages/server/src/database/migrations/mariadb/1693999022236-ModifyChatMessage.ts new file mode 100644 index 00000000000..3f6eaa4ecd3 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1693999022236-ModifyChatMessage.ts @@ -0,0 +1,11 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class ModifyChatMessage1693999022236 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_message\` MODIFY \`sourceDocuments\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_message\` MODIFY \`sourceDocuments\` VARCHAR;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1693999261583-ModifyCredential.ts b/packages/server/src/database/migrations/mariadb/1693999261583-ModifyCredential.ts new file mode 100644 index 00000000000..54c33af1a83 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1693999261583-ModifyCredential.ts @@ -0,0 +1,11 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class ModifyCredential1693999261583 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`credential\` MODIFY \`encryptedData\` TEXT NOT NULL;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`credential\` MODIFY \`encryptedData\` VARCHAR NOT NULL;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1694001465232-ModifyTool.ts b/packages/server/src/database/migrations/mariadb/1694001465232-ModifyTool.ts new file mode 100644 index 00000000000..934506cb609 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1694001465232-ModifyTool.ts @@ -0,0 +1,11 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class ModifyTool1694001465232 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`tool\` MODIFY \`schema\` TEXT, MODIFY \`func\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`tool\` MODIFY \`schema\` VARCHAR, MODIFY \`func\` VARCHAR;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1694099200729-AddApiConfig.ts b/packages/server/src/database/migrations/mariadb/1694099200729-AddApiConfig.ts new file mode 100644 index 00000000000..4509c5bbf84 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1694099200729-AddApiConfig.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddApiConfig1694099200729 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_flow', 'apiConfig') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`apiConfig\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`apiConfig\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1694432361423-AddAnalytic.ts b/packages/server/src/database/migrations/mariadb/1694432361423-AddAnalytic.ts new file mode 100644 index 00000000000..5fed5753be2 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1694432361423-AddAnalytic.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddAnalytic1694432361423 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_flow', 'analytic') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`analytic\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`analytic\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1694658767766-AddChatHistory.ts b/packages/server/src/database/migrations/mariadb/1694658767766-AddChatHistory.ts new file mode 100644 index 00000000000..317d618882a --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1694658767766-AddChatHistory.ts @@ -0,0 +1,41 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddChatHistory1694658767766 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const chatTypeColumnExists = await queryRunner.hasColumn('chat_message', 'chatType') + if (!chatTypeColumnExists) + await queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`chatType\` VARCHAR(255) NOT NULL DEFAULT 'INTERNAL';`) + + const chatIdColumnExists = await queryRunner.hasColumn('chat_message', 'chatId') + if (!chatIdColumnExists) await queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`chatId\` VARCHAR(255);`) + const results: { id: string; chatflowid: string }[] = await queryRunner.query(`WITH RankedMessages AS ( + SELECT + \`chatflowid\`, + \`id\`, + \`createdDate\`, + ROW_NUMBER() OVER (PARTITION BY \`chatflowid\` ORDER BY \`createdDate\`) AS row_num + FROM \`chat_message\` + ) + SELECT \`chatflowid\`, \`id\` + FROM RankedMessages + WHERE row_num = 1;`) + for (const chatMessage of results) { + await queryRunner.query( + `UPDATE \`chat_message\` SET \`chatId\` = '${chatMessage.id}' WHERE \`chatflowid\` = '${chatMessage.chatflowid}'` + ) + } + await queryRunner.query(`ALTER TABLE \`chat_message\` MODIFY \`chatId\` VARCHAR(255) NOT NULL;`) + + const memoryTypeColumnExists = await queryRunner.hasColumn('chat_message', 'memoryType') + if (!memoryTypeColumnExists) await queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`memoryType\` VARCHAR(255);`) + + const sessionIdColumnExists = await queryRunner.hasColumn('chat_message', 'sessionId') + if (!sessionIdColumnExists) await queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`sessionId\` VARCHAR(255);`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`chat_message\` DROP COLUMN \`chatType\`, DROP COLUMN \`chatId\`, DROP COLUMN \`memoryType\`, DROP COLUMN \`sessionId\`;` + ) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1699325775451-AddAssistantEntity.ts b/packages/server/src/database/migrations/mariadb/1699325775451-AddAssistantEntity.ts new file mode 100644 index 00000000000..0e840232c73 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1699325775451-AddAssistantEntity.ts @@ -0,0 +1,21 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddAssistantEntity1699325775451 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`assistant\` ( + \`id\` varchar(36) NOT NULL, + \`credential\` varchar(255) NOT NULL, + \`details\` text NOT NULL, + \`iconSrc\` varchar(255) DEFAULT NULL, + \`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + \`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE assistant`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1699481607341-AddUsedToolsToChatMessage.ts b/packages/server/src/database/migrations/mariadb/1699481607341-AddUsedToolsToChatMessage.ts new file mode 100644 index 00000000000..3ca170dc530 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1699481607341-AddUsedToolsToChatMessage.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddUsedToolsToChatMessage1699481607341 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_message', 'usedTools') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`usedTools\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`usedTools\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1699900910291-AddCategoryToChatFlow.ts b/packages/server/src/database/migrations/mariadb/1699900910291-AddCategoryToChatFlow.ts new file mode 100644 index 00000000000..424f3b0e0b3 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1699900910291-AddCategoryToChatFlow.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddCategoryToChatFlow1699900910291 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_flow', 'category') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`category\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`category\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1700271021237-AddFileAnnotationsToChatMessage.ts b/packages/server/src/database/migrations/mariadb/1700271021237-AddFileAnnotationsToChatMessage.ts new file mode 100644 index 00000000000..a352cde8c64 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1700271021237-AddFileAnnotationsToChatMessage.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddFileAnnotationsToChatMessage1700271021237 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_message', 'fileAnnotations') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`fileAnnotations\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`fileAnnotations\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1701788586491-AddFileUploadsToChatMessage.ts b/packages/server/src/database/migrations/mariadb/1701788586491-AddFileUploadsToChatMessage.ts new file mode 100644 index 00000000000..d896066b164 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1701788586491-AddFileUploadsToChatMessage.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddFileUploadsToChatMessage1701788586491 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_message', 'fileUploads') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`fileUploads\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`fileUploads\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1702200925471-AddVariableEntity.ts b/packages/server/src/database/migrations/mariadb/1702200925471-AddVariableEntity.ts new file mode 100644 index 00000000000..b93eebcc7f3 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1702200925471-AddVariableEntity.ts @@ -0,0 +1,21 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddVariableEntity1699325775451 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`variable\` ( + \`id\` varchar(36) NOT NULL, + \`name\` varchar(255) NOT NULL, + \`value\` text NOT NULL, + \`type\` varchar(255) DEFAULT NULL, + \`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + \`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE variable`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1706364937060-AddSpeechToText.ts b/packages/server/src/database/migrations/mariadb/1706364937060-AddSpeechToText.ts new file mode 100644 index 00000000000..ac11be89c5b --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1706364937060-AddSpeechToText.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddSpeechToText1706364937060 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_flow', 'speechToText') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`speechToText\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`speechToText\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1707213626553-AddFeedback.ts b/packages/server/src/database/migrations/mariadb/1707213626553-AddFeedback.ts new file mode 100644 index 00000000000..30434306b10 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1707213626553-AddFeedback.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddFeedback1707213626553 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`chat_message_feedback\` ( + \`id\` varchar(36) NOT NULL, + \`chatflowid\` varchar(255) NOT NULL, + \`content\` text, + \`chatId\` varchar(255) NOT NULL, + \`messageId\` varchar(255) NOT NULL, + \`rating\` varchar(255) NOT NULL, + \`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE chat_message_feedback`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1709814301358-AddUpsertHistoryEntity.ts b/packages/server/src/database/migrations/mariadb/1709814301358-AddUpsertHistoryEntity.ts new file mode 100644 index 00000000000..ebb1daff3a7 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1709814301358-AddUpsertHistoryEntity.ts @@ -0,0 +1,21 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddUpsertHistoryEntity1709814301358 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`upsert_history\` ( + \`id\` varchar(36) NOT NULL, + \`chatflowid\` varchar(255) NOT NULL, + \`result\` text NOT NULL, + \`flowData\` text NOT NULL, + \`date\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`), + KEY \`IDX_a0b59fd66f6e48d2b198123cb6\` (\`chatflowid\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE upsert_history`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1710832127079-AddLead.ts b/packages/server/src/database/migrations/mariadb/1710832127079-AddLead.ts new file mode 100644 index 00000000000..48eb0792ae7 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1710832127079-AddLead.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddLead1710832127079 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`lead\` ( + \`id\` varchar(36) NOT NULL, + \`chatflowid\` varchar(255) NOT NULL, + \`chatId\` varchar(255) NOT NULL, + \`name\` text, + \`email\` text, + \`phone\` text, + \`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE lead`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1711538023578-AddLeadToChatMessage.ts b/packages/server/src/database/migrations/mariadb/1711538023578-AddLeadToChatMessage.ts new file mode 100644 index 00000000000..e1fff8fc6de --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1711538023578-AddLeadToChatMessage.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddLeadToChatMessage1711538023578 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_message', 'leadEmail') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`leadEmail\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`leadEmail\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1711637331047-AddDocumentStore.ts b/packages/server/src/database/migrations/mariadb/1711637331047-AddDocumentStore.ts new file mode 100644 index 00000000000..b564fbe9261 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1711637331047-AddDocumentStore.ts @@ -0,0 +1,37 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddDocumentStore1711637331047 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`document_store\` ( + \`id\` varchar(36) NOT NULL, + \`name\` varchar(255) NOT NULL, + \`description\` varchar(255), + \`loaders\` text, + \`whereUsed\` text, + \`status\` varchar(20) NOT NULL, + \`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + \`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), + PRIMARY KEY (\`id\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS \`document_store_file_chunk\` ( + \`id\` varchar(36) NOT NULL, + \`docId\` varchar(36) NOT NULL, + \`storeId\` varchar(36) NOT NULL, + \`chunkNo\` INT NOT NULL, + \`pageContent\` text, + \`metadata\` text, + PRIMARY KEY (\`id\`), + KEY \`IDX_e76bae1780b77e56aab1h2asd4\` (\`docId\`), + KEY \`IDX_e213b811b01405a42309a6a410\` (\`storeId\`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;` + ) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE document_store`) + await queryRunner.query(`DROP TABLE document_store_file_chunk`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1714679514451-AddAgentReasoningToChatMessage.ts b/packages/server/src/database/migrations/mariadb/1714679514451-AddAgentReasoningToChatMessage.ts new file mode 100644 index 00000000000..c19872567c0 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1714679514451-AddAgentReasoningToChatMessage.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddAgentReasoningToChatMessage1714679514451 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_message', 'agentReasoning') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`agentReasoning\` LONGTEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`agentReasoning\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/1766759476232-AddTypeToChatFlow.ts b/packages/server/src/database/migrations/mariadb/1766759476232-AddTypeToChatFlow.ts new file mode 100644 index 00000000000..f19e4ad5664 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/1766759476232-AddTypeToChatFlow.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm' + +export class AddTypeToChatFlow1766759476232 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const columnExists = await queryRunner.hasColumn('chat_flow', 'type') + if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`type\` TEXT;`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`type\`;`) + } +} diff --git a/packages/server/src/database/migrations/mariadb/index.ts b/packages/server/src/database/migrations/mariadb/index.ts new file mode 100644 index 00000000000..39ba696d080 --- /dev/null +++ b/packages/server/src/database/migrations/mariadb/index.ts @@ -0,0 +1,47 @@ +import { Init1693840429259 } from './1693840429259-Init' +import { ModifyChatFlow1693997791471 } from './1693997791471-ModifyChatFlow' +import { ModifyChatMessage1693999022236 } from './1693999022236-ModifyChatMessage' +import { ModifyCredential1693999261583 } from './1693999261583-ModifyCredential' +import { ModifyTool1694001465232 } from './1694001465232-ModifyTool' +import { AddApiConfig1694099200729 } from './1694099200729-AddApiConfig' +import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic' +import { AddChatHistory1694658767766 } from './1694658767766-AddChatHistory' +import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity' +import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage' +import { AddCategoryToChatFlow1699900910291 } from './1699900910291-AddCategoryToChatFlow' +import { AddFileAnnotationsToChatMessage1700271021237 } from './1700271021237-AddFileAnnotationsToChatMessage' +import { AddFileUploadsToChatMessage1701788586491 } from './1701788586491-AddFileUploadsToChatMessage' +import { AddVariableEntity1699325775451 } from './1702200925471-AddVariableEntity' +import { AddSpeechToText1706364937060 } from './1706364937060-AddSpeechToText' +import { AddUpsertHistoryEntity1709814301358 } from './1709814301358-AddUpsertHistoryEntity' +import { AddFeedback1707213626553 } from './1707213626553-AddFeedback' +import { AddDocumentStore1711637331047 } from './1711637331047-AddDocumentStore' +import { AddLead1710832127079 } from './1710832127079-AddLead' +import { AddLeadToChatMessage1711538023578 } from './1711538023578-AddLeadToChatMessage' +import { AddAgentReasoningToChatMessage1714679514451 } from './1714679514451-AddAgentReasoningToChatMessage' +import { AddTypeToChatFlow1766759476232 } from './1766759476232-AddTypeToChatFlow' + +export const mariadbMigrations = [ + Init1693840429259, + ModifyChatFlow1693997791471, + ModifyChatMessage1693999022236, + ModifyCredential1693999261583, + ModifyTool1694001465232, + AddApiConfig1694099200729, + AddAnalytic1694432361423, + AddChatHistory1694658767766, + AddAssistantEntity1699325775451, + AddUsedToolsToChatMessage1699481607341, + AddCategoryToChatFlow1699900910291, + AddFileAnnotationsToChatMessage1700271021237, + AddVariableEntity1699325775451, + AddFileUploadsToChatMessage1701788586491, + AddSpeechToText1706364937060, + AddUpsertHistoryEntity1709814301358, + AddFeedback1707213626553, + AddDocumentStore1711637331047, + AddLead1710832127079, + AddLeadToChatMessage1711538023578, + AddAgentReasoningToChatMessage1714679514451, + AddTypeToChatFlow1766759476232 +] From be3a887e68dc726453cc694484080b13ad859c2e Mon Sep 17 00:00:00 2001 From: Daniel D'Abate Date: Fri, 7 Jun 2024 16:35:57 +0200 Subject: [PATCH 23/29] Improvement - Reduce size of final docker image with multistage build (#2598) * Reduce size of final docker image with multistage build * Dockerfile - Move PUPPETEER_SKIP_DOWNLOAD flag to build stage --- docker/Dockerfile | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 6fb59404cda..64d426b4e27 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,21 +1,25 @@ -FROM node:20-alpine +# Stage 1: Build stage +FROM node:20-alpine as build USER root -RUN apk add --no-cache git -RUN apk add --no-cache python3 py3-pip make g++ -# needed for pdfjs-dist -RUN apk add --no-cache build-base cairo-dev pango-dev - -# Install Chromium -RUN apk add --no-cache chromium - +# Skip downloading Chrome for Puppeteer (saves build time) ENV PUPPETEER_SKIP_DOWNLOAD=true -ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser -# You can install a specific version like: flowise@1.0.0 +# Install latest Flowise globally (specific version can be set: flowise@1.0.0) RUN npm install -g flowise -WORKDIR /data +# Stage 2: Runtime stage +FROM node:20-alpine + +# Install runtime dependencies +RUN apk add --no-cache chromium git python3 py3-pip make g++ build-base cairo-dev pango-dev + +# Set the environment variable for Puppeteer to find Chromium +ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser + +# Copy Flowise from the build stage +COPY --from=build /usr/local/lib/node_modules /usr/local/lib/node_modules +COPY --from=build /usr/local/bin /usr/local/bin ENTRYPOINT ["flowise", "start"] From f1e78d870e28cb1f4038a0eed537b1be7523ac2c Mon Sep 17 00:00:00 2001 From: Saurav Maheshkar Date: Fri, 7 Jun 2024 15:49:24 +0100 Subject: [PATCH 24/29] gh: refactor community files (#2572) * gh: refactor community files * fix: links to other files * docs: move to i18n --- CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 2 +- README.md | 2 +- CODE_OF_CONDUCT-ZH.md => i18n/CODE_OF_CONDUCT-ZH.md | 2 +- CONTRIBUTING-ZH.md => i18n/CONTRIBUTING-ZH.md | 2 +- README-JA.md => i18n/README-JA.md | 2 +- README-KR.md => i18n/README-KR.md | 2 +- README-ZH.md => i18n/README-ZH.md | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename CODE_OF_CONDUCT-ZH.md => i18n/CODE_OF_CONDUCT-ZH.md (98%) rename CONTRIBUTING-ZH.md => i18n/CONTRIBUTING-ZH.md (99%) rename README-JA.md => i18n/README-JA.md (98%) rename README-KR.md => i18n/README-KR.md (98%) rename README-ZH.md => i18n/README-ZH.md (98%) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 43f82993ec9..bb787f37c1c 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,6 +1,6 @@ # Contributor Covenant Code of Conduct -English | [中文](<./CODE_OF_CONDUCT-ZH.md>) +English | [中文](<./i18n/CODE_OF_CONDUCT-ZH.md>) ## Our Pledge diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 700e2290f8e..a5213ecedbd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ # Contributing to Flowise -English | [中文](./CONTRIBUTING-ZH.md) +English | [中文](./i18n/CONTRIBUTING-ZH.md) We appreciate any form of contributions. diff --git a/README.md b/README.md index 64383088266..e31ba364a1c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![GitHub star chart](https://img.shields.io/github/stars/FlowiseAI/Flowise?style=social)](https://star-history.com/#FlowiseAI/Flowise) [![GitHub fork](https://img.shields.io/github/forks/FlowiseAI/Flowise?style=social)](https://github.com/FlowiseAI/Flowise/fork) -English | [中文](./README-ZH.md) | [日本語](./README-JA.md) | [한국어](./README-KR.md) +English | [中文](./i18n/README-ZH.md) | [日本語](./i18n/README-JA.md) | [한국어](./i18n/README-KR.md)

Drag & drop UI to build your customized LLM flow

diff --git a/CODE_OF_CONDUCT-ZH.md b/i18n/CODE_OF_CONDUCT-ZH.md similarity index 98% rename from CODE_OF_CONDUCT-ZH.md rename to i18n/CODE_OF_CONDUCT-ZH.md index e0537da6154..36adc6a6532 100644 --- a/CODE_OF_CONDUCT-ZH.md +++ b/i18n/CODE_OF_CONDUCT-ZH.md @@ -2,7 +2,7 @@ # 贡献者公约行为准则 -[English](<./CODE_OF_CONDUCT.md>) | 中文 +[English](<../CODE_OF_CONDUCT.md>) | 中文 ## 我们的承诺 diff --git a/CONTRIBUTING-ZH.md b/i18n/CONTRIBUTING-ZH.md similarity index 99% rename from CONTRIBUTING-ZH.md rename to i18n/CONTRIBUTING-ZH.md index 77b65d29b13..f4a3d362efe 100644 --- a/CONTRIBUTING-ZH.md +++ b/i18n/CONTRIBUTING-ZH.md @@ -2,7 +2,7 @@ # 贡献给 Flowise -[English](./CONTRIBUTING.md) | 中文 +[English](../CONTRIBUTING.md) | 中文 我们欢迎任何形式的贡献。 diff --git a/README-JA.md b/i18n/README-JA.md similarity index 98% rename from README-JA.md rename to i18n/README-JA.md index 10ecfa10357..d40c39c9f05 100644 --- a/README-JA.md +++ b/i18n/README-JA.md @@ -10,7 +10,7 @@ [![GitHub star chart](https://img.shields.io/github/stars/FlowiseAI/Flowise?style=social)](https://star-history.com/#FlowiseAI/Flowise) [![GitHub fork](https://img.shields.io/github/forks/FlowiseAI/Flowise?style=social)](https://github.com/FlowiseAI/Flowise/fork) -[English](./README.md) | [中文](./README-ZH.md) | 日本語 | [한국어](./README-KR.md) +[English](../README.md) | [中文](./README-ZH.md) | 日本語 | [한국어](./README-KR.md)

ドラッグ&ドロップでカスタマイズした LLM フローを構築できる UI

diff --git a/README-KR.md b/i18n/README-KR.md similarity index 98% rename from README-KR.md rename to i18n/README-KR.md index c6452ece44b..7013feb0c04 100644 --- a/README-KR.md +++ b/i18n/README-KR.md @@ -10,7 +10,7 @@ [![GitHub star chart](https://img.shields.io/github/stars/FlowiseAI/Flowise?style=social)](https://star-history.com/#FlowiseAI/Flowise) [![GitHub fork](https://img.shields.io/github/forks/FlowiseAI/Flowise?style=social)](https://github.com/FlowiseAI/Flowise/fork) -English | [中文](./README-ZH.md) | [日本語](./README-JA.md) | 한국어 +[English](../README.md) | [中文](./README-ZH.md) | [日本語](./README-JA.md) | 한국어

드래그 앤 드롭 UI로 맞춤형 LLM 플로우 구축하기

diff --git a/README-ZH.md b/i18n/README-ZH.md similarity index 98% rename from README-ZH.md rename to i18n/README-ZH.md index af841cbb5f5..a06fd4fce6c 100644 --- a/README-ZH.md +++ b/i18n/README-ZH.md @@ -10,7 +10,7 @@ [![GitHub星图](https://img.shields.io/github/stars/FlowiseAI/Flowise?style=social)](https://star-history.com/#FlowiseAI/Flowise) [![GitHub分支](https://img.shields.io/github/forks/FlowiseAI/Flowise?style=social)](https://github.com/FlowiseAI/Flowise/fork) -[English](./README.md) | 中文 | [日本語](./README-JA.md) | [한국어](./README-KR.md) +[English](../README.md) | 中文 | [日本語](./README-JA.md) | [한국어](./README-KR.md)

拖放界面构建定制化的LLM流程

From 66e1296a06f5061b23908a1164e1d07fffe1f794 Mon Sep 17 00:00:00 2001 From: Torsten Raudssus Date: Tue, 11 Jun 2024 17:29:07 +0200 Subject: [PATCH 25/29] Searxng Tool implementation (#2599) * Searxng Tool implementation, first commit with most functionality * Fixed complains of pnpm lint * Picky linter --- .../nodes/tools/Searxng/SearXNG.svg | 19 +++ .../components/nodes/tools/Searxng/Searxng.ts | 119 ++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 packages/components/nodes/tools/Searxng/SearXNG.svg create mode 100644 packages/components/nodes/tools/Searxng/Searxng.ts diff --git a/packages/components/nodes/tools/Searxng/SearXNG.svg b/packages/components/nodes/tools/Searxng/SearXNG.svg new file mode 100644 index 00000000000..915d2783b4c --- /dev/null +++ b/packages/components/nodes/tools/Searxng/SearXNG.svg @@ -0,0 +1,19 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/components/nodes/tools/Searxng/Searxng.ts b/packages/components/nodes/tools/Searxng/Searxng.ts new file mode 100644 index 00000000000..b3f647371ec --- /dev/null +++ b/packages/components/nodes/tools/Searxng/Searxng.ts @@ -0,0 +1,119 @@ +import { SearxngSearch } from '@langchain/community/tools/searxng_search' +import { INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses } from '../../../src/utils' + +class Searxng_Tools implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + baseClasses: string[] + inputs: INodeParams[] + + constructor() { + this.label = 'SearXNG' + this.name = 'searXNG' + this.version = 1.0 + this.type = 'SearXNG' + this.icon = 'SearXNG.svg' + this.category = 'Tools' + this.description = 'Wrapper around SearXNG - a free internet metasearch engine' + this.inputs = [ + { + label: 'Base URL', + name: 'apiBase', + type: 'string', + default: 'http://searxng:8080' + }, + { + label: 'Categories', + name: 'categories', + description: + 'Comma separated list, specifies the active search categories. (see Configured Engines)', + optional: true, + additionalParams: true, + type: 'string' + }, + { + label: 'Engines', + name: 'engines', + description: + 'Comma separated list, specifies the active search engines. (see Configured Engines)', + optional: true, + additionalParams: true, + type: 'string' + }, + { + label: 'Language', + name: 'language', + description: 'Code of the language.', + optional: true, + additionalParams: true, + type: 'string' + }, + { + label: 'Page No.', + name: 'pageno', + description: 'Search page number.', + optional: true, + additionalParams: true, + type: 'number' + }, + { + label: 'Time Range', + name: 'time_range', + description: + 'Time range of search for engines which support it. See if an engine supports time range search in the preferences page of an instance.', + optional: true, + additionalParams: true, + type: 'string' + }, + { + label: 'Safe Search', + name: 'safesearch', + description: + 'Filter search results of engines which support safe search. See if an engine supports safe search in the preferences page of an instance.', + optional: true, + additionalParams: true, + type: 'number' + } + ] + this.baseClasses = [this.type, ...getBaseClasses(SearxngSearch)] + } + + async init(nodeData: INodeData, _: string): Promise { + const apiBase = nodeData.inputs?.apiBase as string + const categories = nodeData.inputs?.categories as string + const engines = nodeData.inputs?.engines as string + const language = nodeData.inputs?.language as string + const pageno = nodeData.inputs?.pageno as number + const time_range = nodeData.inputs?.time_range as string + const safesearch = nodeData.inputs?.safesearch as 0 | 1 | 2 | undefined + const format = 'json' as 'json' + + const params = { + format, + categories, + engines, + language, + pageno, + time_range, + safesearch + } + + const headers = {} + + const tool = new SearxngSearch({ + apiBase, + params, + headers + }) + + return tool + } +} + +module.exports = { nodeClass: Searxng_Tools } From 9f9aff34f8f0994722f0305430167b22ed0092c9 Mon Sep 17 00:00:00 2001 From: Torsten Raudssus Date: Tue, 11 Jun 2024 17:29:28 +0200 Subject: [PATCH 26/29] Adding pnpm-store to gitignore (#2600) --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 99c9f3cdafd..2f17096b63f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ **/logs **/*.log +## pnpm +.pnpm-store/ + ## build **/dist **/build From 88ee9b09a7b18a1fa92f42b2244f1579d4442391 Mon Sep 17 00:00:00 2001 From: Mingxin Hou <136245460+mingxin0607@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:56:22 -0700 Subject: [PATCH 27/29] Fireworks ai chat model (#2596) * fireworks chat model * add chatFireworks to streamAvaliableLLMs * add model parameter input * Update ChatFireworks.ts * fix linting --------- Co-authored-by: Henry Heng --- .../credentials/FireworksApi.credential.ts | 23 +++++ .../chatmodels/ChatFireworks/ChatFireworks.ts | 79 ++++++++++++++++++ .../chatmodels/ChatFireworks/Fireworks.png | Bin 0 -> 6809 bytes packages/server/src/utils/index.ts | 3 +- 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 packages/components/credentials/FireworksApi.credential.ts create mode 100644 packages/components/nodes/chatmodels/ChatFireworks/ChatFireworks.ts create mode 100644 packages/components/nodes/chatmodels/ChatFireworks/Fireworks.png diff --git a/packages/components/credentials/FireworksApi.credential.ts b/packages/components/credentials/FireworksApi.credential.ts new file mode 100644 index 00000000000..11e0a245798 --- /dev/null +++ b/packages/components/credentials/FireworksApi.credential.ts @@ -0,0 +1,23 @@ +import { INodeParams, INodeCredential } from '../src/Interface' + +class FireworksApi implements INodeCredential { + label: string + name: string + version: number + inputs: INodeParams[] + + constructor() { + this.label = 'Fireworks API' + this.name = 'fireworksApi' + this.version = 1.0 + this.inputs = [ + { + label: 'Fireworks Api Key', + name: 'fireworksApiKey', + type: 'password' + } + ] + } +} + +module.exports = { credClass: FireworksApi } diff --git a/packages/components/nodes/chatmodels/ChatFireworks/ChatFireworks.ts b/packages/components/nodes/chatmodels/ChatFireworks/ChatFireworks.ts new file mode 100644 index 00000000000..91b19b229ad --- /dev/null +++ b/packages/components/nodes/chatmodels/ChatFireworks/ChatFireworks.ts @@ -0,0 +1,79 @@ +import { BaseCache } from '@langchain/core/caches' +import { ChatFireworks } from '@langchain/community/chat_models/fireworks' +import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class ChatFireworks_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 = 'ChatFireworks' + this.name = 'chatFireworks' + this.version = 1.0 + this.type = 'ChatFireworks' + this.icon = 'Fireworks.png' + this.category = 'Chat Models' + this.description = 'Wrapper around Fireworks Chat Endpoints' + this.baseClasses = [this.type, ...getBaseClasses(ChatFireworks)] + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['fireworksApi'] + } + this.inputs = [ + { + label: 'Cache', + name: 'cache', + type: 'BaseCache', + optional: true + }, + { + label: 'Model', + name: 'modelName', + type: 'string', + default: 'accounts/fireworks/models/llama-v2-13b-chat', + placeholder: 'accounts/fireworks/models/llama-v2-13b-chat' + }, + { + label: 'Temperature', + name: 'temperature', + type: 'number', + step: 0.1, + default: 0.9, + optional: true + } + ] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const cache = nodeData.inputs?.cache as BaseCache + const temperature = nodeData.inputs?.temperature as string + const modelName = nodeData.inputs?.modelName as string + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const fireworksApiKey = getCredentialParam('fireworksApiKey', credentialData, nodeData) + + const obj: Partial = { + fireworksApiKey, + model: modelName, + modelName, + temperature: temperature ? parseFloat(temperature) : undefined + } + if (cache) obj.cache = cache + + const model = new ChatFireworks(obj) + return model + } +} + +module.exports = { nodeClass: ChatFireworks_ChatModels } diff --git a/packages/components/nodes/chatmodels/ChatFireworks/Fireworks.png b/packages/components/nodes/chatmodels/ChatFireworks/Fireworks.png new file mode 100644 index 0000000000000000000000000000000000000000..aecb2a27b6e97b719ca700e0eac5f1513139a8ec GIT binary patch literal 6809 zcmd^E_ct8g)3yk!cUJF2?_HGDqFXIW^xj!DdRcu%Cw!EMPIPwl7M&nbLez~CMDH!~ zdjF2^4|nFAInT_QIrq-J=gyO;r=v!IOM{DshDMDxBmYEVm-@OU$KOr6~I?t z4UASlO}CGRMq{9^tY{cyd1Mh1`qrrJX)#Y-1Mibw7P+%XrZIzx9x?H@kqSSPVYvyh zM$=__o@f>l{mpFTTXIDbjsNmm$;r>4!+4+2b2nZn#wJ@H8tHLAo3p+zs!f(&rcX_o zO8l|c&q!0B&d(F^g*M;xwOp^eh5eBUxwboM!>IsaqQlT$j8WPpDWb*A#$iT*`-!FX zjzvd6U|K>!uTI>ic%m8 z{-#`1K(OToxpcv?H-MB=~7=pA`$P_<{7n27ikMqC*?%!g4zD)@z9FwFA-pgqgxsCTSIf1 zzu!{V;VO5Sg5iXluW_CtNhs>U|Q6VnQ zC~GJq#&4HS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0!*xhICB;)T0DaUm&I?!j3&r3eo5+Yj9cN>o$cAZLSlm!3!k;`Ahs zcd*18rCcC|70ZrNj$-LsQCc!Jh(Tg?ao*QsnVT*B^d_=A_^QCA#fGoFcf2k50!KH} zev#|7a|ThI(0p>0{+lNbJS4!6^07%RqFUfx4m(%b_9t)Jli6|DvIkcN=8lm-3ZzK) z)r$WyuGE{#Ck1$5%9Oa?Tp?S9AYleYPCPz)8mBaF9F5;^V;rHlDPEpcTGu!Qr5-(= zxq*S^=H6OGqK4mHzR|^HK(8+&Qsacd^F*%0ETNu(*ZS&8dWXhkj8iX*31Q3Qhhc)cNmL!W$JcwY3Dg8bYnH)9~dXU&?(>0WU;2smy3gUw~?u3FB|g5}^i&7k1o;;YYDomiEbm%@b z;RMM}I$N$Qaupve>DE1B4QHc)~X^~v>*{?5~eH6EuP@5E%FCk6>vWt8yEGL6Fx zRKK@LhN=)g)aO7und#<|-ArJW_&kzs3LtFZ+XP~5H{E?Na=ys+ug~ttqg=dDG`+-R zfdDDh!;7I5Ba$HrXyhIeblmrA*@YG)rIYCPXQ#XGiNzaCQX+!WhhMvyOKtBg?_XUl z{YM?556TF4pV2!@*7@fpv Date: Tue, 11 Jun 2024 13:56:34 -0700 Subject: [PATCH 28/29] add Fireworks LLM (#2597) * add Fireworks LLM * support multiple models * Update Fireworks.ts * fix linting --------- Co-authored-by: Henry Heng --- .../nodes/llms/Fireworks/Fireworks.ts | 68 ++++++++++++++++++ .../nodes/llms/Fireworks/fireworks.png | Bin 0 -> 4411 bytes 2 files changed, 68 insertions(+) create mode 100644 packages/components/nodes/llms/Fireworks/Fireworks.ts create mode 100644 packages/components/nodes/llms/Fireworks/fireworks.png diff --git a/packages/components/nodes/llms/Fireworks/Fireworks.ts b/packages/components/nodes/llms/Fireworks/Fireworks.ts new file mode 100644 index 00000000000..9d1c1791a44 --- /dev/null +++ b/packages/components/nodes/llms/Fireworks/Fireworks.ts @@ -0,0 +1,68 @@ +import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src' +import { Fireworks } from '@langchain/community/llms/fireworks' +import { BaseCache } from '@langchain/core/caches' + +class Fireworks_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 = 'Fireworks' + this.name = 'fireworks' + this.version = 1.0 + this.type = 'Fireworks' + this.icon = 'fireworks.png' + this.category = 'LLMs' + this.description = 'Wrapper around Fireworks API for large language models' + this.baseClasses = [this.type, ...getBaseClasses(Fireworks)] + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['fireworksApi'] + } + this.inputs = [ + { + label: 'Cache', + name: 'cache', + type: 'BaseCache', + optional: true + }, + { + label: 'Model Name', + name: 'modelName', + type: 'string', + default: 'accounts/fireworks/models/llama-v3-70b-instruct-hf', + description: 'For more details see https://fireworks.ai/models', + optional: true + } + ] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const cache = nodeData.inputs?.cache as BaseCache + const modelName = nodeData.inputs?.modelName as string + + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const fireworksKey = getCredentialParam('fireworksApiKey', credentialData, nodeData) + + const obj: any = { + fireworksApiKey: fireworksKey, + modelName: modelName + } + if (cache) obj.cache = cache + + const fireworks = new Fireworks(obj) + return fireworks + } +} + +module.exports = { nodeClass: Fireworks_LLMs } diff --git a/packages/components/nodes/llms/Fireworks/fireworks.png b/packages/components/nodes/llms/Fireworks/fireworks.png new file mode 100644 index 0000000000000000000000000000000000000000..7b8d6cfd07cc8c8f124e52955f9dad54b34397ee GIT binary patch literal 4411 zcmb_g`8yPh6BoIYBlJ3wEBAerdy)ITwY!cAS;wxMoEt^T6`MtJU%9jPqL6YV=UO&) z9l1iXz2t~RU+@3$o#&aEpJqPu%rl>Po|$J3cIF&xf^2kjbR3ozCQj!b{hzWhom>4; zCN(-bZhA`-BbSF>+a;`TgK*u1L@nUtf z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7yxK(2Ev4E{1R%)$HvnOM}di&0^N|ij|VpW}D(m~B1#R!_CkXa_jpWC!z z^iIFNWD;gxQ8scvLXJ&<*@f`!y^^-<-9m%fGUrDlxLpQa+?sWwLd%5o=DLf9)T}I> zzPwTuu_-qNrTMvfoG@n%@~S1pYO3jqW=QhGX|6fr3mN75egO!)R+83Em7y_xGMW? zVp)o$})!KfwBb>-y=c6N7l&d?i+z{KM1nO_#e0QuU^ax8#VZ(@x62~rDl@E zc~Dtx8h=jcEugg3+@ltmc{6BXbc5T5e*ysaN+BDvWtRxI;xb$%+!SZEUquE!9dW5B z3Xb{Oq@iXKUz@*Lc4bl0(2OZ5)=yQA-tzW`@cve~B$k?MzyX@230@Q_Oje literal 0 HcmV?d00001 From 5e4d640ed7b1d61b82e65004bc18af593f96f8ba Mon Sep 17 00:00:00 2001 From: Jared McQueen Date: Tue, 11 Jun 2024 17:05:04 -0400 Subject: [PATCH 29/29] fix totalChars accumulator for undefined pageContent (#2619) --- packages/server/src/services/documentstore/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/src/services/documentstore/index.ts b/packages/server/src/services/documentstore/index.ts index 3492602fa11..ff758642086 100644 --- a/packages/server/src/services/documentstore/index.ts +++ b/packages/server/src/services/documentstore/index.ts @@ -600,7 +600,12 @@ const _saveChunksToStorage = async (data: IDocumentStoreLoaderForPreview, entity await appServer.AppDataSource.getRepository(DocumentStoreFileChunk).delete({ docId: newLoaderId }) if (response.chunks) { //step 8: now save the new chunks - const totalChars = response.chunks.reduce((acc: number, chunk) => acc + chunk.pageContent.length, 0) + const totalChars = response.chunks.reduce((acc, chunk) => { + if (chunk.pageContent) { + return acc + chunk.pageContent.length + } + return acc + }, 0) response.chunks.map(async (chunk: IDocument, index: number) => { const docChunk: DocumentStoreFileChunk = { docId: newLoaderId,