Chore/refractor (#4454)

* markdown files and env examples cleanup

* components update

* update jsonlines description

* server refractor

* update telemetry

* add execute custom node

* add ui refractor

* add username and password authenticate

* correctly retrieve past images in agentflowv2

* disable e2e temporarily

* add existing username and password authenticate

* update migration to default workspace

* update todo

* blob storage migrating

* throw error on agent tool call error

* add missing execution import

* add referral

* chore: add error message when importData is undefined

* migrate api keys to db

* fix: data too long for column executionData

* migrate api keys from json to db at init

* add info on account setup

* update docstore missing fields

---------

Co-authored-by: chungyau97 <chungyau97@gmail.com>
This commit is contained in:
Henry Heng
2025-05-27 14:29:42 +08:00
committed by GitHub
parent e35a126b46
commit 5a37227d14
560 changed files with 62127 additions and 4100 deletions
@@ -14,17 +14,41 @@ export class ChainTool extends DynamicTool {
super({
...rest,
func: async (input, runManager) => {
const childManagers = runManager?.getChild()
const handlers = childManagers?.handlers?.filter((handler) => !(handler instanceof CustomChainHandler)) || []
if (childManagers) childManagers.handlers = handlers
// prevent sending SSE events of the sub-chain
const sseStreamer = runManager?.handlers.find((handler) => handler instanceof CustomChainHandler)?.sseStreamer
if (runManager) {
const callbacks = runManager.handlers
for (let i = 0; i < callbacks.length; i += 1) {
if (callbacks[i] instanceof CustomChainHandler) {
;(callbacks[i] as any).sseStreamer = undefined
}
}
}
if ((chain as any).prompt && (chain as any).prompt.promptValues) {
const promptValues = handleEscapeCharacters((chain as any).prompt.promptValues, true)
const values = await chain.call(promptValues, childManagers)
const values = await chain.call(promptValues, runManager?.getChild())
if (runManager && sseStreamer) {
const callbacks = runManager.handlers
for (let i = 0; i < callbacks.length; i += 1) {
if (callbacks[i] instanceof CustomChainHandler) {
;(callbacks[i] as any).sseStreamer = sseStreamer
}
}
}
return values?.text
}
const values = chain.run(input, childManagers)
const values = chain.run(input, runManager?.getChild())
if (runManager && sseStreamer) {
const callbacks = runManager.handlers
for (let i = 0; i < callbacks.length; i += 1) {
if (callbacks[i] instanceof CustomChainHandler) {
;(callbacks[i] as any).sseStreamer = sseStreamer
}
}
}
return values
}
})
@@ -122,7 +122,8 @@ class ChatflowTool_Tools implements INode {
return returnData
}
const chatflows = await appDataSource.getRepository(databaseEntities['ChatFlow']).find()
const searchOptions = options.searchOptions || {}
const chatflows = await appDataSource.getRepository(databaseEntities['ChatFlow']).findBy(searchOptions)
for (let i = 0; i < chatflows.length; i += 1) {
const data = {
@@ -80,7 +80,8 @@ class Code_Interpreter_Tools implements INode {
schema: z.object({
input: z.string().describe('Python code to be executed in the sandbox environment')
}),
chatflowid: options.chatflowid
chatflowid: options.chatflowid,
orgId: options.orgId
})
}
}
@@ -92,6 +93,7 @@ type E2BToolInput = {
apiKey: string
schema: any
chatflowid: string
orgId: string
templateCodeInterpreterE2B?: string
domainCodeInterpreterE2B?: string
}
@@ -113,6 +115,8 @@ export class E2BTool extends StructuredTool {
chatflowid: string
orgId: string
flowObj: ICommonObject
templateCodeInterpreterE2B?: string
@@ -125,6 +129,7 @@ export class E2BTool extends StructuredTool {
this.apiKey = options.apiKey
this.schema = options.schema
this.chatflowid = options.chatflowid
this.orgId = options.orgId
this.templateCodeInterpreterE2B = options.templateCodeInterpreterE2B
this.domainCodeInterpreterE2B = options.domainCodeInterpreterE2B
}
@@ -136,6 +141,7 @@ export class E2BTool extends StructuredTool {
apiKey: options.apiKey,
schema: options.schema,
chatflowid: options.chatflowid,
orgId: options.orgId,
templateCodeInterpreterE2B: options.templateCodeInterpreterE2B,
domainCodeInterpreterE2B: options.domainCodeInterpreterE2B
})
@@ -212,28 +218,33 @@ export class E2BTool extends StructuredTool {
const filename = `artifact_${Date.now()}.png`
const res = await addSingleFileToStorage(
// Don't check storage usage because this is incoming file, and if we throw error, agent will keep on retrying
const { path } = await addSingleFileToStorage(
'image/png',
pngData,
filename,
this.orgId,
this.chatflowid,
flowConfig!.chatId as string
)
artifacts.push({ type: 'png', data: res })
artifacts.push({ type: 'png', data: path })
} else if (key === 'jpeg') {
//@ts-ignore
const jpegData = Buffer.from(result.jpeg, 'base64')
const filename = `artifact_${Date.now()}.jpg`
const res = await addSingleFileToStorage(
const { path } = await addSingleFileToStorage(
'image/jpg',
jpegData,
filename,
this.orgId,
this.chatflowid,
flowConfig!.chatId as string
)
artifacts.push({ type: 'jpeg', data: res })
artifacts.push({ type: 'jpeg', data: path })
} else if (key === 'html' || key === 'markdown' || key === 'latex' || key === 'json' || key === 'javascript') {
artifacts.push({ type: key, data: (result as any)[key] })
} //TODO: support for pdf
@@ -77,7 +77,8 @@ class CustomTool_Tools implements INode {
return returnData
}
const tools = await appDataSource.getRepository(databaseEntities['Tool']).find()
const searchOptions = options.searchOptions || {}
const tools = await appDataSource.getRepository(databaseEntities['Tool']).findBy(searchOptions)
for (let i = 0; i < tools.length; i += 1) {
const data = {
@@ -122,7 +123,7 @@ class CustomTool_Tools implements INode {
obj.schema = zodSchemaFunction(z)
}
const variables = await getVars(appDataSource, databaseEntities, nodeData)
const variables = await getVars(appDataSource, databaseEntities, nodeData, options)
const flow = { chatflowId: options.chatflowid }
@@ -85,8 +85,9 @@ class OpenAPIToolkit_Tools implements INode {
let data
if (yamlFileBase64.startsWith('FILE-STORAGE::')) {
const file = yamlFileBase64.replace('FILE-STORAGE::', '')
const orgId = options.orgId
const chatflowid = options.chatflowid
const fileData = await getFileFromStorage(file, chatflowid)
const fileData = await getFileFromStorage(file, orgId, chatflowid)
const utf8String = fileData.toString('utf-8')
data = load(utf8String)
@@ -110,7 +111,7 @@ class OpenAPIToolkit_Tools implements INode {
const appDataSource = options.appDataSource as DataSource
const databaseEntities = options.databaseEntities as IDatabaseEntity
const variables = await getVars(appDataSource, databaseEntities, nodeData)
const variables = await getVars(appDataSource, databaseEntities, nodeData, options)
const flow = { chatflowId: options.chatflowid }