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
@@ -496,18 +496,21 @@ class Agent_Agentflow implements INode {
}
}
const toolInstance = await newToolNodeInstance.init(newNodeData, '', options)
if (tool.agentSelectedToolRequiresHumanInput) {
toolInstance.requiresHumanInput = true
}
// toolInstance might returns a list of tools like MCP tools
if (Array.isArray(toolInstance)) {
for (const subTool of toolInstance) {
const subToolInstance = subTool as Tool
;(subToolInstance as any).agentSelectedTool = tool.agentSelectedTool
if (tool.agentSelectedToolRequiresHumanInput) {
;(subToolInstance as any).requiresHumanInput = true
}
toolsInstance.push(subToolInstance)
}
} else {
if (tool.agentSelectedToolRequiresHumanInput) {
toolInstance.requiresHumanInput = true
}
toolsInstance.push(toolInstance as Tool)
}
}
@@ -929,7 +932,14 @@ class Agent_Agentflow implements INode {
}
// Prepare final response and output object
const finalResponse = (response.content as string) ?? JSON.stringify(response, null, 2)
let finalResponse = ''
if (response.content && Array.isArray(response.content)) {
finalResponse = response.content.map((item: any) => item.text).join('\n')
} else if (response.content && typeof response.content === 'string') {
finalResponse = response.content
} else {
finalResponse = JSON.stringify(response, null, 2)
}
const output = this.prepareOutputObject(
response,
availableTools,
@@ -1374,6 +1384,7 @@ class Agent_Agentflow implements INode {
const usedTools: IUsedTool[] = []
let sourceDocuments: Array<any> = []
let artifacts: any[] = []
let isWaitingForHumanInput: boolean | undefined
// Process each tool call
for (let i = 0; i < response.tool_calls.length; i++) {
@@ -1536,7 +1547,8 @@ class Agent_Agentflow implements INode {
usedTools: recursiveUsedTools,
sourceDocuments: recursiveSourceDocuments,
artifacts: recursiveArtifacts,
totalTokens: recursiveTokens
totalTokens: recursiveTokens,
isWaitingForHumanInput: recursiveIsWaitingForHumanInput
} = await this.handleToolCalls({
response: newResponse,
messages,
@@ -1558,9 +1570,10 @@ class Agent_Agentflow implements INode {
sourceDocuments = [...sourceDocuments, ...recursiveSourceDocuments]
artifacts = [...artifacts, ...recursiveArtifacts]
totalTokens += recursiveTokens
isWaitingForHumanInput = recursiveIsWaitingForHumanInput
}
return { response: newResponse, usedTools, sourceDocuments, artifacts, totalTokens }
return { response: newResponse, usedTools, sourceDocuments, artifacts, totalTokens, isWaitingForHumanInput }
}
/**
@@ -1660,7 +1673,14 @@ class Agent_Agentflow implements INode {
if (humanInput.type === 'reject') {
messages.pop()
toolsInstance = toolsInstance.filter((tool) => tool.name !== toolCall.name)
const toBeRemovedTool = toolsInstance.find((tool) => tool.name === toolCall.name)
if (toBeRemovedTool) {
toolsInstance = toolsInstance.filter((tool) => tool.name !== toolCall.name)
// Remove other tools with the same agentSelectedTool such as MCP tools
toolsInstance = toolsInstance.filter(
(tool) => (tool as any).agentSelectedTool !== (toBeRemovedTool as any).agentSelectedTool
)
}
}
if (humanInput.type === 'proceed') {
let toolIds: ICommonObject | undefined
@@ -336,6 +336,9 @@ class HTTP_Agentflow implements INode {
} catch (error) {
console.error('HTTP Request Error:', error)
const errorMessage =
error.response?.data?.message || error.response?.data?.error || error.message || 'An error occurred during the HTTP request'
// Format error response
const errorResponse: any = {
id: nodeData.id,
@@ -353,7 +356,7 @@ class HTTP_Agentflow implements INode {
},
error: {
name: error.name || 'Error',
message: error.message || 'An error occurred during the HTTP request'
message: errorMessage
},
state
}
@@ -366,7 +369,7 @@ class HTTP_Agentflow implements INode {
errorResponse.error.headers = error.response.headers
}
throw new Error(error)
throw new Error(errorMessage)
}
}
}
+21 -3
View File
@@ -262,6 +262,7 @@ class LLM_Agentflow implements INode {
}`,
description: 'JSON schema for the structured output',
optional: true,
hideCodeExecute: true,
show: {
'llmStructuredOutput[$index].type': 'jsonArray'
}
@@ -486,8 +487,15 @@ class LLM_Agentflow implements INode {
}
// Prepare final response and output object
const finalResponse = (response.content as string) ?? JSON.stringify(response, null, 2)
const output = this.prepareOutputObject(response, finalResponse, startTime, endTime, timeDelta)
let finalResponse = ''
if (response.content && Array.isArray(response.content)) {
finalResponse = response.content.map((item: any) => item.text).join('\n')
} else if (response.content && typeof response.content === 'string') {
finalResponse = response.content
} else {
finalResponse = JSON.stringify(response, null, 2)
}
const output = this.prepareOutputObject(response, finalResponse, startTime, endTime, timeDelta, isStructuredOutput)
// End analytics tracking
if (analyticHandlers && llmIds) {
@@ -853,7 +861,8 @@ class LLM_Agentflow implements INode {
finalResponse: string,
startTime: number,
endTime: number,
timeDelta: number
timeDelta: number,
isStructuredOutput: boolean
): any {
const output: any = {
content: finalResponse,
@@ -872,6 +881,15 @@ class LLM_Agentflow implements INode {
output.usageMetadata = response.usage_metadata
}
if (isStructuredOutput && typeof response === 'object') {
const structuredOutput = response as Record<string, any>
for (const key in structuredOutput) {
if (structuredOutput[key]) {
output[key] = structuredOutput[key]
}
}
}
return output
}