mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
Fix Agent Executor block name
This commit is contained in:
@@ -22,6 +22,7 @@ class AgentExecutorBlock(Block):
|
||||
user_id: str = SchemaField(description="User ID")
|
||||
graph_id: str = SchemaField(description="Graph ID")
|
||||
graph_version: int = SchemaField(description="Graph Version")
|
||||
block_name: str = SchemaField(description="Name to display in the Builder UI")
|
||||
|
||||
inputs: BlockInput = SchemaField(description="Input data for the graph")
|
||||
input_schema: dict = SchemaField(description="Input schema for the graph")
|
||||
|
||||
@@ -105,7 +105,6 @@ const FlowEditor: React.FC<{
|
||||
setAgentDescription,
|
||||
savedAgent,
|
||||
availableNodes,
|
||||
availableFlows,
|
||||
getOutputType,
|
||||
requestSave,
|
||||
requestSaveAndRun,
|
||||
|
||||
@@ -10,6 +10,7 @@ import BackendAPI, {
|
||||
GraphID,
|
||||
NodeExecutionResult,
|
||||
SpecialBlockID,
|
||||
Node,
|
||||
} from "@/lib/autogpt-server-api";
|
||||
import {
|
||||
deepEquals,
|
||||
@@ -177,6 +178,16 @@ export default function useAgentGraph(
|
||||
setAgentName(graph.name);
|
||||
setAgentDescription(graph.description);
|
||||
|
||||
const getGraphName = (node: Node) => {
|
||||
if (node.input_default.block_name) {
|
||||
return node.input_default.block_name;
|
||||
}
|
||||
return (
|
||||
availableFlows.find((flow) => flow.id === node.input_default.graph_id)
|
||||
?.name || null
|
||||
);
|
||||
};
|
||||
|
||||
setNodes((prevNodes) => {
|
||||
const _newNodes = graph.nodes.map((node) => {
|
||||
const block = availableNodes.find(
|
||||
@@ -184,12 +195,8 @@ export default function useAgentGraph(
|
||||
)!;
|
||||
if (!block) return null;
|
||||
const prevNode = prevNodes.find((n) => n.id === node.id);
|
||||
const flow =
|
||||
block.uiType == BlockUIType.AGENT
|
||||
? availableFlows.find(
|
||||
(flow) => flow.id === node.input_default.graph_id,
|
||||
)
|
||||
: null;
|
||||
const graphName =
|
||||
(block.uiType == BlockUIType.AGENT && getGraphName(node)) || null;
|
||||
const newNode: CustomNode = {
|
||||
id: node.id,
|
||||
type: "custom",
|
||||
@@ -201,7 +208,7 @@ export default function useAgentGraph(
|
||||
isOutputOpen: false,
|
||||
...prevNode?.data,
|
||||
block_id: block.id,
|
||||
blockType: flow?.name || block.name,
|
||||
blockType: graphName || block.name,
|
||||
blockCosts: block.costs,
|
||||
categories: block.categories,
|
||||
description: block.description,
|
||||
@@ -284,15 +291,17 @@ export default function useAgentGraph(
|
||||
|
||||
const getToolFuncName = (nodeId: string) => {
|
||||
const sinkNode = nodes.find((node) => node.id === nodeId);
|
||||
const sinkNodeName = sinkNode
|
||||
? sinkNode.data.block_id === SpecialBlockID.AGENT
|
||||
? sinkNode.data.hardcodedValues?.graph_id
|
||||
? availableFlows.find(
|
||||
(flow) => flow.id === sinkNode.data.hardcodedValues.graph_id,
|
||||
)?.name || "agentexecutorblock"
|
||||
: "agentexecutorblock"
|
||||
: sinkNode.data.title.split(" ")[0]
|
||||
: "";
|
||||
|
||||
if (!sinkNode) return "";
|
||||
|
||||
const sinkNodeName =
|
||||
sinkNode.data.block_id === SpecialBlockID.AGENT
|
||||
? sinkNode.data.hardcodedValues?.block_name ||
|
||||
availableFlows.find(
|
||||
(flow) => flow.id === sinkNode.data.hardcodedValues.graph_id,
|
||||
)?.name ||
|
||||
"agentexecutorblock"
|
||||
: sinkNode.data.title.split(" ")[0];
|
||||
|
||||
return sinkNodeName;
|
||||
};
|
||||
@@ -1116,7 +1125,6 @@ export default function useAgentGraph(
|
||||
setAgentDescription,
|
||||
savedAgent,
|
||||
availableNodes,
|
||||
availableFlows,
|
||||
getOutputType,
|
||||
requestSave,
|
||||
requestSaveAndRun,
|
||||
|
||||
@@ -236,12 +236,7 @@ export default class BackendAPI {
|
||||
|
||||
searchBlocks(options: {
|
||||
search_query?: string;
|
||||
filter?: (
|
||||
| "blocks"
|
||||
| "integrations"
|
||||
| "marketplace_agents"
|
||||
| "my_agents"
|
||||
)[];
|
||||
filter?: ("blocks" | "integrations" | "marketplace_agents" | "my_agents")[];
|
||||
by_creator?: string[];
|
||||
search_id?: string;
|
||||
page?: number;
|
||||
|
||||
@@ -74,10 +74,7 @@ export type ProviderResponse = {
|
||||
export type BlockSearchResponse = {
|
||||
items: (Block | LibraryAgent | StoreAgent)[];
|
||||
total_items: Record<
|
||||
| "blocks"
|
||||
| "integrations"
|
||||
| "marketplace_agents"
|
||||
| "my_agents",
|
||||
"blocks" | "integrations" | "marketplace_agents" | "my_agents",
|
||||
number
|
||||
>;
|
||||
page: number;
|
||||
|
||||
@@ -423,6 +423,7 @@ export const convertLibraryAgentIntoBlock = (agent: LibraryAgent) => {
|
||||
graph_version: agent.graph_version,
|
||||
input_schema: agent.input_schema,
|
||||
output_schema: agent.output_schema,
|
||||
block_name: agent.name,
|
||||
},
|
||||
} as Block;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user