Skip to content

Commit 7f8e884

Browse files
committed
Merge remote-tracking branch 'flowise/main' into main
# Conflicts: # packages/server/marketplaces/chatflows/Flowise Docs QnA.json
2 parents 25fa262 + 436b3aa commit 7f8e884

File tree

68 files changed

+1915
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1915
-231
lines changed

CONTRIBUTING.md

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ Flowise support different environment variables to configure your instance. You
123123
| Variable | Description | Type | Default |
124124
| --------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------ | ----------------------------------- |
125125
| PORT | The HTTP port Flowise runs on | Number | 3000 |
126+
| CORS_ORIGINS | The allowed origins for all cross-origin HTTP calls | String | |
127+
| IFRAME_ORIGINS | The allowed origins for iframe src embedding | String | |
126128
| FLOWISE_USERNAME | Username to login | String | |
127129
| FLOWISE_PASSWORD | Password to login | String | |
128130
| DEBUG | Print logs from components | Boolean | |
@@ -138,6 +140,7 @@ Flowise support different environment variables to configure your instance. You
138140
| DATABASE_USER | Database username (When DATABASE_TYPE is not sqlite) | String | |
139141
| DATABASE_PASSWORD | Database password (When DATABASE_TYPE is not sqlite) | String | |
140142
| DATABASE_NAME | Database name (When DATABASE_TYPE is not sqlite) | String | |
143+
| DATABASE_SSL_KEY_BASE64 | Database SSL client cert in base64 (takes priority over DATABASE_SSL) | Boolean | false |
141144
| DATABASE_SSL | Database connection overssl (When DATABASE_TYPE is postgre) | Boolean | false |
142145
| SECRETKEY_PATH | Location where encryption key (used to encrypt/decrypt credentials) is saved | String | `your-path/Flowise/packages/server` |
143146
| FLOWISE_SECRETKEY_OVERWRITE | Encryption key to be used instead of the key stored in SECRETKEY_PATH | String |

docker/.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ APIKEY_PATH=/root/.flowise
44
SECRETKEY_PATH=/root/.flowise
55
LOG_PATH=/root/.flowise/logs
66

7+
# CORS_ORIGINS="*"
8+
# IFRAME_ORIGINS="*"
9+
710
# NUMBER_OF_PROXIES= 1
811

912
# DATABASE_TYPE=postgres
@@ -13,6 +16,7 @@ LOG_PATH=/root/.flowise/logs
1316
# DATABASE_USER=""
1417
# DATABASE_PASSWORD=""
1518
# DATABASE_SSL=true
19+
# DATABASE_SSL_KEY_BASE64=<Self signed certificate in BASE64>
1620

1721
# FLOWISE_USERNAME=user
1822
# FLOWISE_PASSWORD=1234

docker/docker-compose.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ services:
66
restart: always
77
environment:
88
- PORT=${PORT}
9+
- CORS_ORIGINS=${CORS_ORIGINS}
10+
- IFRAME_ORIGINS=${IFRAME_ORIGINS}
911
- FLOWISE_USERNAME=${FLOWISE_USERNAME}
1012
- FLOWISE_PASSWORD=${FLOWISE_PASSWORD}
1113
- DEBUG=${DEBUG}
@@ -17,6 +19,7 @@ services:
1719
- DATABASE_USER=${DATABASE_USER}
1820
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
1921
- DATABASE_SSL=${DATABASE_SSL}
22+
- DATABASE_SSL_KEY_BASE64=${DATABASE_SSL_KEY_BASE64}
2023
- APIKEY_PATH=${APIKEY_PATH}
2124
- SECRETKEY_PATH=${SECRETKEY_PATH}
2225
- FLOWISE_SECRETKEY_OVERWRITE=${FLOWISE_SECRETKEY_OVERWRITE}

packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,28 @@ class OpenAIFunctionAgent_Agents implements INode {
6464
return prepareAgent(nodeData, { sessionId: this.sessionId, chatId: options.chatId, input }, options.chatHistory)
6565
}
6666

67-
async run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string> {
67+
async run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string | ICommonObject> {
6868
const memory = nodeData.inputs?.memory as FlowiseMemory
6969
const executor = prepareAgent(nodeData, { sessionId: this.sessionId, chatId: options.chatId, input }, options.chatHistory)
7070

7171
const loggerHandler = new ConsoleCallbackHandler(options.logger)
7272
const callbacks = await additionalCallbacks(nodeData, options)
7373

7474
let res: ChainValues = {}
75+
let sourceDocuments: ICommonObject[] = []
7576

7677
if (options.socketIO && options.socketIOClientId) {
7778
const handler = new CustomChainHandler(options.socketIO, options.socketIOClientId)
7879
res = await executor.invoke({ input }, { callbacks: [loggerHandler, handler, ...callbacks] })
80+
if (res.sourceDocuments) {
81+
options.socketIO.to(options.socketIOClientId).emit('sourceDocuments', flatten(res.sourceDocuments))
82+
sourceDocuments = res.sourceDocuments
83+
}
7984
} else {
8085
res = await executor.invoke({ input }, { callbacks: [loggerHandler, ...callbacks] })
86+
if (res.sourceDocuments) {
87+
sourceDocuments = res.sourceDocuments
88+
}
8189
}
8290

8391
await memory.addChatMessages(
@@ -94,7 +102,7 @@ class OpenAIFunctionAgent_Agents implements INode {
94102
this.sessionId
95103
)
96104

97-
return res?.output
105+
return sourceDocuments.length ? { text: res?.output, sourceDocuments: flatten(sourceDocuments) } : res?.output
98106
}
99107
}
100108

packages/components/nodes/cache/RedisCache/RedisCache.ts

+41-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
11
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
22
import { RedisCache as LangchainRedisCache } from 'langchain/cache/ioredis'
3-
import { Redis } from 'ioredis'
3+
import { Redis, RedisOptions } from 'ioredis'
4+
import { isEqual } from 'lodash'
45
import { Generation, ChatGeneration, StoredGeneration, mapStoredMessageToChatMessage } from 'langchain/schema'
56
import hash from 'object-hash'
67

8+
let redisClientSingleton: Redis
9+
let redisClientOption: RedisOptions
10+
let redisClientUrl: string
11+
12+
const getRedisClientbyOption = (option: RedisOptions) => {
13+
if (!redisClientSingleton) {
14+
// if client doesn't exists
15+
redisClientSingleton = new Redis(option)
16+
redisClientOption = option
17+
return redisClientSingleton
18+
} else if (redisClientSingleton && !isEqual(option, redisClientOption)) {
19+
// if client exists but option changed
20+
redisClientSingleton.quit()
21+
redisClientSingleton = new Redis(option)
22+
redisClientOption = option
23+
return redisClientSingleton
24+
}
25+
return redisClientSingleton
26+
}
27+
28+
const getRedisClientbyUrl = (url: string) => {
29+
if (!redisClientSingleton) {
30+
// if client doesn't exists
31+
redisClientSingleton = new Redis(url)
32+
redisClientUrl = url
33+
return redisClientSingleton
34+
} else if (redisClientSingleton && url !== redisClientUrl) {
35+
// if client exists but option changed
36+
redisClientSingleton.quit()
37+
redisClientSingleton = new Redis(url)
38+
redisClientUrl = url
39+
return redisClientSingleton
40+
}
41+
return redisClientSingleton
42+
}
43+
744
class RedisCache implements INode {
845
label: string
946
name: string
@@ -60,15 +97,15 @@ class RedisCache implements INode {
6097

6198
const tlsOptions = sslEnabled === true ? { tls: { rejectUnauthorized: false } } : {}
6299

63-
client = new Redis({
100+
client = getRedisClientbyOption({
64101
port: portStr ? parseInt(portStr) : 6379,
65102
host,
66103
username,
67104
password,
68105
...tlsOptions
69106
})
70107
} else {
71-
client = new Redis(redisUrl)
108+
client = getRedisClientbyUrl(redisUrl)
72109
}
73110

74111
const redisClient = new LangchainRedisCache(client)
@@ -94,7 +131,7 @@ class RedisCache implements INode {
94131
for (let i = 0; i < value.length; i += 1) {
95132
const key = getCacheKey(prompt, llmKey, String(i))
96133
if (ttl) {
97-
await client.set(key, JSON.stringify(serializeGeneration(value[i])), 'EX', parseInt(ttl, 10))
134+
await client.set(key, JSON.stringify(serializeGeneration(value[i])), 'PX', parseInt(ttl, 10))
98135
} else {
99136
await client.set(key, JSON.stringify(serializeGeneration(value[i])))
100137
}

packages/components/nodes/cache/RedisCache/RedisEmbeddingsCache.ts

+40-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
11
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
2-
import { Redis } from 'ioredis'
2+
import { Redis, RedisOptions } from 'ioredis'
3+
import { isEqual } from 'lodash'
34
import { CacheBackedEmbeddings } from 'langchain/embeddings/cache_backed'
45
import { RedisByteStore } from 'langchain/storage/ioredis'
56
import { Embeddings } from 'langchain/embeddings/base'
67

8+
let redisClientSingleton: Redis
9+
let redisClientOption: RedisOptions
10+
let redisClientUrl: string
11+
12+
const getRedisClientbyOption = (option: RedisOptions) => {
13+
if (!redisClientSingleton) {
14+
// if client doesn't exists
15+
redisClientSingleton = new Redis(option)
16+
redisClientOption = option
17+
return redisClientSingleton
18+
} else if (redisClientSingleton && !isEqual(option, redisClientOption)) {
19+
// if client exists but option changed
20+
redisClientSingleton.quit()
21+
redisClientSingleton = new Redis(option)
22+
redisClientOption = option
23+
return redisClientSingleton
24+
}
25+
return redisClientSingleton
26+
}
27+
28+
const getRedisClientbyUrl = (url: string) => {
29+
if (!redisClientSingleton) {
30+
// if client doesn't exists
31+
redisClientSingleton = new Redis(url)
32+
redisClientUrl = url
33+
return redisClientSingleton
34+
} else if (redisClientSingleton && url !== redisClientUrl) {
35+
// if client exists but option changed
36+
redisClientSingleton.quit()
37+
redisClientSingleton = new Redis(url)
38+
redisClientUrl = url
39+
return redisClientSingleton
40+
}
41+
return redisClientSingleton
42+
}
43+
744
class RedisEmbeddingsCache implements INode {
845
label: string
946
name: string
@@ -75,15 +112,15 @@ class RedisEmbeddingsCache implements INode {
75112

76113
const tlsOptions = sslEnabled === true ? { tls: { rejectUnauthorized: false } } : {}
77114

78-
client = new Redis({
115+
client = getRedisClientbyOption({
79116
port: portStr ? parseInt(portStr) : 6379,
80117
host,
81118
username,
82119
password,
83120
...tlsOptions
84121
})
85122
} else {
86-
client = new Redis(redisUrl)
123+
client = getRedisClientbyUrl(redisUrl)
87124
}
88125

89126
ttl ??= '3600'

packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ChatOpenAI_ChatModels implements INode {
1919
constructor() {
2020
this.label = 'ChatOpenAI'
2121
this.name = 'chatOpenAI'
22-
this.version = 2.0
22+
this.version = 3.0
2323
this.type = 'ChatOpenAI'
2424
this.icon = 'openai.svg'
2525
this.category = 'Chat Models'
@@ -47,6 +47,14 @@ class ChatOpenAI_ChatModels implements INode {
4747
label: 'gpt-4',
4848
name: 'gpt-4'
4949
},
50+
{
51+
label: 'gpt-4-turbo-preview',
52+
name: 'gpt-4-turbo-preview'
53+
},
54+
{
55+
label: 'gpt-4-0125-preview',
56+
name: 'gpt-4-0125-preview'
57+
},
5058
{
5159
label: 'gpt-4-1106-preview',
5260
name: 'gpt-4-1106-preview'

0 commit comments

Comments
 (0)