Chore/update deprecating nodes (#2540)

* update deprecating nodes

* add filters use cases to marketplace

* update log level
This commit is contained in:
Henry Heng
2024-07-12 18:37:57 +01:00
committed by GitHub
parent 9ea439d135
commit 363d1bfc44
144 changed files with 6939 additions and 12160 deletions
@@ -3,6 +3,20 @@ import * as fs from 'fs'
import { StatusCodes } from 'http-status-codes'
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
import { getErrorMessage } from '../../errors/utils'
import { IReactFlowEdge, IReactFlowNode } from '../../Interface'
type ITemplate = {
badge: string
description: string
framework: string[]
usecases: string[]
nodes: IReactFlowNode[]
edges: IReactFlowEdge[]
}
const getCategories = (fileDataObj: ITemplate) => {
return Array.from(new Set(fileDataObj?.nodes?.map((node) => node.data.category).filter((category) => category)))
}
// Get all templates for marketplaces
const getAllTemplates = async () => {
@@ -13,14 +27,16 @@ const getAllTemplates = async () => {
jsonsInDir.forEach((file, index) => {
const filePath = path.join(__dirname, '..', '..', '..', 'marketplaces', 'chatflows', file)
const fileData = fs.readFileSync(filePath)
const fileDataObj = JSON.parse(fileData.toString())
const fileDataObj = JSON.parse(fileData.toString()) as ITemplate
const template = {
id: index,
templateName: file.split('.json')[0],
flowData: fileData.toString(),
badge: fileDataObj?.badge,
framework: fileDataObj?.framework,
categories: fileDataObj?.categories,
usecases: fileDataObj?.usecases,
categories: getCategories(fileDataObj),
type: 'Chatflow',
description: fileDataObj?.description || ''
}
@@ -39,7 +55,8 @@ const getAllTemplates = async () => {
type: 'Tool',
framework: fileDataObj?.framework,
badge: fileDataObj?.badge,
categories: '',
usecases: fileDataObj?.usecases,
categories: [],
templateName: file.split('.json')[0]
}
templates.push(template)
@@ -57,7 +74,8 @@ const getAllTemplates = async () => {
flowData: fileData.toString(),
badge: fileDataObj?.badge,
framework: fileDataObj?.framework,
categories: fileDataObj?.categories,
usecases: fileDataObj?.usecases,
categories: getCategories(fileDataObj),
type: 'Agentflow',
description: fileDataObj?.description || ''
}