Chore/Update issue templates and add new tools (#4687)

* Enhancement: Update issue templates and add new tools

- Updated bug report template to include a default label of 'bug'.
- Updated feature request template to include a default label of 'enhancement'.
- Added new credential class for Agentflow API.
- Enhanced Agent and HTTP nodes to improve tool management and error handling.
- Added deprecation badges to several agent and chain classes.
- Introduced new tools for handling requests (GET, POST, DELETE, PUT) with improved error handling.
- Added new chatflows and agentflows for various use cases, including document QnA and translation.
- Updated UI components for better handling of agent flows and marketplace interactions.
- Refactored utility functions for improved functionality and clarity.

* Refactor: Remove beta badge and streamline template title assignment

- Removed the 'BETA' badge from the ExtractMetadataRetriever class.
- Simplified the title assignment in the agentflowv2 generator by using a variable instead of inline string manipulation.
This commit is contained in:
Henry Heng
2025-06-19 18:11:24 +01:00
committed by GitHub
parent 15dd28356b
commit a107aa7a77
86 changed files with 9942 additions and 12634 deletions
@@ -0,0 +1,141 @@
import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, stripHTMLFromToolInput } from '../../../src/utils'
import { desc, RequestParameters, RequestsDeleteTool } from './core'
const codeExample = `{
"id": {
"type": "string",
"required": true,
"in": "path",
"description": "ID of the item to delete. /:id"
},
"force": {
"type": "string",
"in": "query",
"description": "Force delete the item. ?force=true"
}
}`
class RequestsDelete_Tools implements INode {
label: string
name: string
version: number
description: string
type: string
icon: string
category: string
baseClasses: string[]
inputs: INodeParams[]
constructor() {
this.label = 'Requests Delete'
this.name = 'requestsDelete'
this.version = 1.0
this.type = 'RequestsDelete'
this.icon = 'del.png'
this.category = 'Tools'
this.description = 'Execute HTTP DELETE requests'
this.baseClasses = [this.type, ...getBaseClasses(RequestsDeleteTool)]
this.inputs = [
{
label: 'URL',
name: 'requestsDeleteUrl',
type: 'string',
acceptVariable: true
},
{
label: 'Name',
name: 'requestsDeleteName',
type: 'string',
default: 'requests_delete',
description: 'Name of the tool',
additionalParams: true,
optional: true
},
{
label: 'Description',
name: 'requestsDeleteDescription',
type: 'string',
rows: 4,
default: desc,
description: 'Describe to LLM when it should use this tool',
additionalParams: true,
optional: true
},
{
label: 'Headers',
name: 'requestsDeleteHeaders',
type: 'string',
rows: 4,
acceptVariable: true,
additionalParams: true,
optional: true,
placeholder: `{
"Authorization": "Bearer <token>"
}`
},
{
label: 'Query Params Schema',
name: 'requestsDeleteQueryParamsSchema',
type: 'code',
description: 'Description of the available query params to enable LLM to figure out which query params to use',
placeholder: `{
"id": {
"type": "string",
"required": true,
"in": "path",
"description": "ID of the item to delete. /:id"
},
"force": {
"type": "string",
"in": "query",
"description": "Force delete the item. ?force=true"
}
}`,
optional: true,
hideCodeExecute: true,
additionalParams: true,
codeExample: codeExample
},
{
label: 'Max Output Length',
name: 'requestsDeleteMaxOutputLength',
type: 'number',
description: 'Max length of the output. Remove this if you want to return the entire response',
default: '2000',
step: 1,
optional: true,
additionalParams: true
}
]
}
async init(nodeData: INodeData): Promise<any> {
const headers = (nodeData.inputs?.headers as string) || (nodeData.inputs?.requestsDeleteHeaders as string)
const url = (nodeData.inputs?.url as string) || (nodeData.inputs?.requestsDeleteUrl as string)
const description = (nodeData.inputs?.description as string) || (nodeData.inputs?.requestsDeleteDescription as string)
const name = (nodeData.inputs?.name as string) || (nodeData.inputs?.requestsDeleteName as string)
const queryParamsSchema =
(nodeData.inputs?.queryParamsSchema as string) || (nodeData.inputs?.requestsDeleteQueryParamsSchema as string)
const maxOutputLength = nodeData.inputs?.requestsDeleteMaxOutputLength as string
const obj: RequestParameters = {}
if (url) obj.url = stripHTMLFromToolInput(url)
if (description) obj.description = description
if (name)
obj.name = name
.toLowerCase()
.replace(/ /g, '_')
.replace(/[^a-z0-9_-]/g, '')
if (queryParamsSchema) obj.queryParamsSchema = queryParamsSchema
if (maxOutputLength) obj.maxOutputLength = parseInt(maxOutputLength, 10)
if (headers) {
const parsedHeaders = typeof headers === 'object' ? headers : JSON.parse(stripHTMLFromToolInput(headers))
obj.headers = parsedHeaders
}
return new RequestsDeleteTool(obj)
}
}
module.exports = { nodeClass: RequestsDelete_Tools }
@@ -0,0 +1,184 @@
import { z } from 'zod'
import fetch from 'node-fetch'
import { DynamicStructuredTool } from '../OpenAPIToolkit/core'
export const desc = `Use this when you need to execute a DELETE request to remove data from a website.`
export interface Headers {
[key: string]: string
}
export interface RequestParameters {
headers?: Headers
url?: string
name?: string
queryParamsSchema?: string
description?: string
maxOutputLength?: number
}
// Base schema for DELETE request
const createRequestsDeleteSchema = (queryParamsSchema?: string) => {
// If queryParamsSchema is provided, parse it and add dynamic query params
if (queryParamsSchema) {
try {
const parsedSchema = JSON.parse(queryParamsSchema)
const queryParamsObject: Record<string, z.ZodTypeAny> = {}
Object.entries(parsedSchema).forEach(([key, config]: [string, any]) => {
let zodType: z.ZodTypeAny = z.string()
// Handle different types
if (config.type === 'number') {
zodType = z.string().transform((val) => Number(val))
} else if (config.type === 'boolean') {
zodType = z.string().transform((val) => val === 'true')
}
// Add description
if (config.description) {
zodType = zodType.describe(config.description)
}
// Make optional if not required
if (!config.required) {
zodType = zodType.optional()
}
queryParamsObject[key] = zodType
})
if (Object.keys(queryParamsObject).length > 0) {
return z.object({
queryParams: z.object(queryParamsObject).optional().describe('Query parameters for the request')
})
}
} catch (error) {
console.warn('Failed to parse queryParamsSchema:', error)
}
}
// Fallback to generic query params
return z.object({
queryParams: z.record(z.string()).optional().describe('Optional query parameters to include in the request')
})
}
export class RequestsDeleteTool extends DynamicStructuredTool {
url = ''
maxOutputLength = Infinity
headers = {}
queryParamsSchema?: string
constructor(args?: RequestParameters) {
const schema = createRequestsDeleteSchema(args?.queryParamsSchema)
const toolInput = {
name: args?.name || 'requests_delete',
description: args?.description || desc,
schema: schema,
baseUrl: '',
method: 'DELETE',
headers: args?.headers || {}
}
super(toolInput)
this.url = args?.url ?? this.url
this.headers = args?.headers ?? this.headers
this.maxOutputLength = args?.maxOutputLength ?? this.maxOutputLength
this.queryParamsSchema = args?.queryParamsSchema
}
/** @ignore */
async _call(arg: any): Promise<string> {
const params = { ...arg }
const inputUrl = this.url
if (!inputUrl) {
throw new Error('URL is required for DELETE request')
}
const requestHeaders = {
...(params.headers || {}),
...this.headers
}
// Process URL and query parameters based on schema
let finalUrl = inputUrl
const queryParams: Record<string, string> = {}
if (this.queryParamsSchema && params.queryParams && Object.keys(params.queryParams).length > 0) {
try {
const parsedSchema = JSON.parse(this.queryParamsSchema)
const pathParams: Array<{ key: string; value: string }> = []
Object.entries(params.queryParams).forEach(([key, value]) => {
const paramConfig = parsedSchema[key]
if (paramConfig && value !== undefined && value !== null) {
if (paramConfig.in === 'path') {
// Check if URL contains path parameter placeholder
const pathPattern = new RegExp(`:${key}\\b`, 'g')
if (finalUrl.includes(`:${key}`)) {
// Replace path parameters in URL (e.g., /:id -> /123)
finalUrl = finalUrl.replace(pathPattern, encodeURIComponent(String(value)))
} else {
// Collect path parameters to append to URL
pathParams.push({ key, value: String(value) })
}
} else if (paramConfig.in === 'query') {
// Add to query parameters
queryParams[key] = String(value)
}
}
})
// Append path parameters to URL if any exist
if (pathParams.length > 0) {
let urlPath = finalUrl
// Remove trailing slash if present
if (urlPath.endsWith('/')) {
urlPath = urlPath.slice(0, -1)
}
// Append each path parameter
pathParams.forEach(({ value }) => {
urlPath += `/${encodeURIComponent(value)}`
})
finalUrl = urlPath
}
// Add query parameters to URL if any exist
if (Object.keys(queryParams).length > 0) {
const url = new URL(finalUrl)
Object.entries(queryParams).forEach(([key, value]) => {
url.searchParams.append(key, value)
})
finalUrl = url.toString()
}
} catch (error) {
console.warn('Failed to process queryParamsSchema:', error)
}
} else if (params.queryParams && Object.keys(params.queryParams).length > 0) {
// Fallback: treat all parameters as query parameters if no schema is defined
const url = new URL(finalUrl)
Object.entries(params.queryParams).forEach(([key, value]) => {
url.searchParams.append(key, String(value))
})
finalUrl = url.toString()
}
try {
const res = await fetch(finalUrl, {
method: 'DELETE',
headers: requestHeaders
})
if (!res.ok) {
throw new Error(`HTTP Error ${res.status}: ${res.statusText}`)
}
const text = await res.text()
return text.slice(0, this.maxOutputLength)
} catch (error) {
throw new Error(`Failed to make DELETE request: ${error instanceof Error ? error.message : 'Unknown error'}`)
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB