AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
refactor(server, builder): Remove unused/duplicate WebSocket endpoints (#7740)
Reinier van der Leer5a68be541928
diff --git a/rnd/autogpt_builder/src/components/Flow.tsx b/rnd/autogpt_builder/src/components/Flow.tsxindex 9c2e5af8de..a340af3f00 100644--- a/rnd/autogpt_builder/src/components/Flow.tsx+++ b/rnd/autogpt_builder/src/components/Flow.tsx@@ -753,7 +753,7 @@ const FlowEditor: React.FC<{}api.subscribeToExecution(newAgentId);- api.runGraph(newAgentId);+ await api.executeGraph(newAgentId);} catch (error) {console.error("Error running agent:", error);}diff --git a/rnd/autogpt_builder/src/lib/autogpt-server-api/client.ts b/rnd/autogpt_builder/src/lib/autogpt-server-api/client.tsindex 157a4a3e3b..f79f70d761 100644--- a/rnd/autogpt_builder/src/lib/autogpt-server-api/client.ts+++ b/rnd/autogpt_builder/src/lib/autogpt-server-api/client.ts@@ -242,13 +242,6 @@ export default class AutoGPTServerAPI {subscribeToExecution(graphId: string) {this.sendWebSocketMessage("subscribe", { graph_id: graphId });}-- runGraph(- graphId: string,- data: WebsocketMessageTypeMap["run_graph"]["data"] = {},- ) {- this.sendWebSocketMessage("run_graph", { graph_id: graphId, data });- }}/* *** UTILITY TYPES *** */@@ -264,6 +257,5 @@ type GraphCreateRequestBody =type WebsocketMessageTypeMap = {subscribe: { graph_id: string };- run_graph: { graph_id: string; data: { [key: string]: any } };execution_event: NodeExecutionResult;};diff --git a/rnd/autogpt_server/autogpt_server/server/model.py b/rnd/autogpt_server/autogpt_server/server/model.pyindex 6ca24535f4..92cc9f30df 100644--- a/rnd/autogpt_server/autogpt_server/server/model.py+++ b/rnd/autogpt_server/autogpt_server/server/model.py@@ -10,17 +10,6 @@ class Methods(enum.Enum):SUBSCRIBE = "subscribe"UNSUBSCRIBE = "unsubscribe"EXECUTION_EVENT = "execution_event"- GET_BLOCKS = "get_blocks"- EXECUTE_BLOCK = "execute_block"- GET_GRAPHS = "get_graphs"- GET_GRAPH = "get_graph"- CREATE_GRAPH = "create_graph"- RUN_GRAPH = "run_graph"- GET_GRAPH_RUNS = "get_graph_runs"- CREATE_SCHEDULED_RUN = "create_scheduled_run"- GET_SCHEDULED_RUNS = "get_scheduled_runs"- UPDATE_SCHEDULED_RUN = "update_scheduled_run"- UPDATE_CONFIG = "update_config"ERROR = "error"diff --git a/rnd/autogpt_server/autogpt_server/server/server.py b/rnd/autogpt_server/autogpt_server/server/server.pyindex dd340f54e7..7a5fdafcc7 100644--- a/rnd/autogpt_server/autogpt_server/server/server.py+++ b/rnd/autogpt_server/autogpt_server/server/server.py@@ -314,153 +314,14 @@ class AgentServer(AppService):await autogpt_server.server.ws_api.handle_unsubscribe(websocket, self.manager, message)- elif message.method == Methods.EXECUTION_EVENT:- print("Execution event received")- elif message.method == Methods.GET_BLOCKS:- data = self.get_graph_blocks()- await websocket.send_text(- WsMessage(- method=Methods.GET_BLOCKS,- success=True,- data=data,- ).model_dump_json()- )- elif message.method == Methods.EXECUTE_BLOCK:- assert isinstance(message.data, dict), "Data must be a dictionary"- data = self.execute_graph_block(- message.data["block_id"], message.data["data"]- )- await websocket.send_text(- WsMessage(- method=Methods.EXECUTE_BLOCK,- success=True,- data=data,- ).model_dump_json()- )- elif message.method == Methods.GET_GRAPHS:- data = await self.get_graphs(user_id=user_id)- await websocket.send_text(- WsMessage(- method=Methods.GET_GRAPHS,- success=True,- data=data,- ).model_dump_json()- )- print("Get graphs request received")- elif message.method == Methods.GET_GRAPH:- assert isinstance(message.data, dict), "Data must be a dictionary"- data = await self.get_graph(- message.data["graph_id"], user_id=user_id- )- await websocket.send_text(- WsMessage(- method=Methods.GET_GRAPH,- success=True,- data=data.model_dump(),- ).model_dump_json()- )- print("Get graph request received")- elif message.method == Methods.CREATE_GRAPH:- assert isinstance(message.data, dict), "Data must be a dictionary"- create_graph = CreateGraph.model_validate(message.data)- data = await self.create_new_graph(create_graph, user_id=user_id)- await websocket.send_text(- WsMessage(- method=Methods.CREATE_GRAPH,- success=True,- data=data.model_dump(),- ).model_dump_json()- )-- print("Create graph request received")- elif message.method == Methods.RUN_GRAPH:- assert isinstance(message.data, dict), "Data must be a dictionary"- data = await self.execute_graph(- message.data["graph_id"], message.data["data"], user_id=user_id- )- await websocket.send_text(- WsMessage(- method=Methods.RUN_GRAPH,- success=True,- data=data,- ).model_dump_json()- )-- print("Run graph request received")- elif message.method == Methods.GET_GRAPH_RUNS:- assert isinstance(message.data, dict), "Data must be a dictionary"- data = await self.list_graph_runs(- message.data["graph_id"], user_id=user_id- )- await websocket.send_text(- WsMessage(- method=Methods.GET_GRAPH_RUNS,- success=True,- data=data,- ).model_dump_json()- )- print("Get graph runs request received")- elif message.method == Methods.CREATE_SCHEDULED_RUN:- assert isinstance(message.data, dict), "Data must be a dictionary"- data = await self.create_schedule(- message.data["graph_id"],- message.data["cron"],- message.data["data"],- user_id=user_id,- )- await websocket.send_text(- WsMessage(- method=Methods.CREATE_SCHEDULED_RUN,- success=True,- data=data,- ).model_dump_json()- )-- print("Create scheduled run request received")- elif message.method == Methods.GET_SCHEDULED_RUNS:- assert isinstance(message.data, dict), "Data must be a dictionary"- data = self.get_execution_schedules(- message.data["graph_id"], user_id=user_id- )- await websocket.send_text(- WsMessage(- method=Methods.GET_SCHEDULED_RUNS,- success=True,- data=data,- ).model_dump_json()- )- print("Get scheduled runs request received")- elif message.method == Methods.UPDATE_SCHEDULED_RUN:- assert isinstance(message.data, dict), "Data must be a dictionary"- data = self.update_schedule(- message.data["schedule_id"], message.data, user_id=user_id- )- await websocket.send_text(- WsMessage(- method=Methods.UPDATE_SCHEDULED_RUN,- success=True,- data=data,- ).model_dump_json()- )-- print("Update scheduled run request received")- elif message.method == Methods.UPDATE_CONFIG:- assert isinstance(message.data, dict), "Data must be a dictionary"- data = self.update_configuration(message.data)- await websocket.send_text(- WsMessage(- method=Methods.UPDATE_CONFIG,- success=True,- data=data,- ).model_dump_json()- )-- print("Update config request received")elif message.method == Methods.ERROR:- print("Error message received")+ print("WebSocket Error message received:", message.data)+else:- print("Message type is not processed by the server")+ print(+ f"Message type {message.method} is not processed by the server"+ )await websocket.send_text(WsMessage(method=Methods.ERROR,