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(blocks): Reassign non-random IDs (#8229)
Reinier van der Leer8803740d4747
diff --git a/autogpt_platform/backend/backend/blocks/basic.py b/autogpt_platform/backend/backend/blocks/basic.pyindex b86d8d872b..095c3b0e92 100644--- a/autogpt_platform/backend/backend/blocks/basic.py+++ b/autogpt_platform/backend/backend/blocks/basic.py@@ -88,7 +88,7 @@ class FindInDictionaryBlock(Block):def __init__(self):super().__init__(- id="b2g2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6",+ id="0e50422c-6dee-4145-83d6-3a5a392f65de",description="Lookup the given key in the input dictionary/object/list and return the value.",input_schema=FindInDictionaryBlock.Input,output_schema=FindInDictionaryBlock.Output,@@ -429,7 +429,7 @@ class NoteBlock(Block):def __init__(self):super().__init__(- id="31d1064e-7446-4693-o7d4-65e5ca9110d1",+ id="cc10ff7b-7753-4ff2-9af6-9399b1a7eddc",description="This block is used to display a sticky note with the given text.",categories={BlockCategory.BASIC},input_schema=NoteBlock.Input,diff --git a/autogpt_platform/backend/backend/blocks/discord.py b/autogpt_platform/backend/backend/blocks/discord.pyindex 8565684a07..cd350a6199 100644--- a/autogpt_platform/backend/backend/blocks/discord.py+++ b/autogpt_platform/backend/backend/blocks/discord.py@@ -28,7 +28,7 @@ class ReadDiscordMessagesBlock(Block):def __init__(self):super().__init__(- id="d3f4g5h6-1i2j-3k4l-5m6n-7o8p9q0r1s2t", # Unique ID for the node+ id="df06086a-d5ac-4abb-9996-2ad0acb2eff7",input_schema=ReadDiscordMessagesBlock.Input, # Assign input schemaoutput_schema=ReadDiscordMessagesBlock.Output, # Assign output schemadescription="Reads messages from a Discord channel using a bot token.",@@ -146,7 +146,7 @@ class SendDiscordMessageBlock(Block):def __init__(self):super().__init__(- id="h1i2j3k4-5l6m-7n8o-9p0q-r1s2t3u4v5w6", # Unique ID for the node+ id="d0822ab5-9f8a-44a3-8971-531dd0178b6b",input_schema=SendDiscordMessageBlock.Input, # Assign input schemaoutput_schema=SendDiscordMessageBlock.Output, # Assign output schemadescription="Sends a message to a Discord channel using a bot token.",diff --git a/autogpt_platform/backend/backend/blocks/email_block.py b/autogpt_platform/backend/backend/blocks/email_block.pyindex edfb2f391b..96e69e1ffc 100644--- a/autogpt_platform/backend/backend/blocks/email_block.py+++ b/autogpt_platform/backend/backend/blocks/email_block.py@@ -43,7 +43,7 @@ class SendEmailBlock(Block):def __init__(self):super().__init__(- id="a1234567-89ab-cdef-0123-456789abcdef",+ id="4335878a-394e-4e67-adf2-919877ff49ae",description="This block sends an email using the provided SMTP credentials.",categories={BlockCategory.OUTPUT},input_schema=SendEmailBlock.Input,diff --git a/autogpt_platform/backend/backend/blocks/iteration.py b/autogpt_platform/backend/backend/blocks/iteration.pyindex 05ca5f5ed7..247a92d3c7 100644--- a/autogpt_platform/backend/backend/blocks/iteration.py+++ b/autogpt_platform/backend/backend/blocks/iteration.py@@ -19,7 +19,7 @@ class StepThroughItemsBlock(Block):def __init__(self):super().__init__(- id="f8e7d6c5-b4a3-2c1d-0e9f-8g7h6i5j4k3l",+ id="f66a3543-28d3-4ab5-8945-9b336371e2ce",input_schema=StepThroughItemsBlock.Input,output_schema=StepThroughItemsBlock.Output,categories={BlockCategory.LOGIC},diff --git a/autogpt_platform/backend/backend/blocks/llm.py b/autogpt_platform/backend/backend/blocks/llm.pyindex 868244cd8e..19d2e9621c 100644--- a/autogpt_platform/backend/backend/blocks/llm.py+++ b/autogpt_platform/backend/backend/blocks/llm.py@@ -392,7 +392,7 @@ class AITextSummarizerBlock(Block):def __init__(self):super().__init__(- id="c3d4e5f6-7g8h-9i0j-1k2l-m3n4o5p6q7r8",+ id="a0a69be1-4528-491c-a85a-a4ab6873e3f0",description="Utilize a Large Language Model (LLM) to summarize a long text.",categories={BlockCategory.AI, BlockCategory.TEXT},input_schema=AITextSummarizerBlock.Input,@@ -535,7 +535,7 @@ class AIConversationBlock(Block):def __init__(self):super().__init__(- id="c3d4e5f6-g7h8-i9j0-k1l2-m3n4o5p6q7r8",+ id="32a87eab-381e-4dd4-bdb8-4c47151be35a",description="Advanced LLM call that takes a list of messages and sends them to the language model.",categories={BlockCategory.AI},input_schema=AIConversationBlock.Input,diff --git a/autogpt_platform/backend/backend/blocks/rss.py b/autogpt_platform/backend/backend/blocks/rss.pyindex 3dd570385b..9a5a17ebee 100644--- a/autogpt_platform/backend/backend/blocks/rss.py+++ b/autogpt_platform/backend/backend/blocks/rss.py@@ -43,7 +43,7 @@ class ReadRSSFeedBlock(Block):def __init__(self):super().__init__(- id="c6731acb-4105-4zp1-bc9b-03d0036h370g",+ id="5ebe6768-8e5d-41e3-9134-1c7bd89a8d52",input_schema=ReadRSSFeedBlock.Input,output_schema=ReadRSSFeedBlock.Output,description="Reads RSS feed entries from a given URL.",diff --git a/autogpt_platform/backend/backend/blocks/search.py b/autogpt_platform/backend/backend/blocks/search.pyindex e51ff4013a..f8fc783e56 100644--- a/autogpt_platform/backend/backend/blocks/search.py+++ b/autogpt_platform/backend/backend/blocks/search.py@@ -25,7 +25,7 @@ class GetWikipediaSummaryBlock(Block, GetRequest):def __init__(self):super().__init__(- id="h5e7f8g9-1b2c-3d4e-5f6g-7h8i9j0k1l2m",+ id="f5b0f5d0-1862-4d61-94be-3ad0fa772760",description="This block fetches the summary of a given topic from Wikipedia.",categories={BlockCategory.SEARCH},input_schema=GetWikipediaSummaryBlock.Input,@@ -62,7 +62,7 @@ class SearchTheWebBlock(Block, GetRequest):def __init__(self):super().__init__(- id="b2c3d4e5-6f7g-8h9i-0j1k-l2m3n4o5p6q7",+ id="87840993-2053-44b7-8da4-187ad4ee518c",description="This block searches the internet for the given search query.",categories={BlockCategory.SEARCH},input_schema=SearchTheWebBlock.Input,@@ -109,7 +109,7 @@ class ExtractWebsiteContentBlock(Block, GetRequest):def __init__(self):super().__init__(- id="a1b2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6", # Unique ID for the block+ id="436c3984-57fd-4b85-8e9a-459b356883bd",description="This block scrapes the content from the given web URL.",categories={BlockCategory.SEARCH},input_schema=ExtractWebsiteContentBlock.Input,diff --git a/autogpt_platform/backend/backend/blocks/time_blocks.py b/autogpt_platform/backend/backend/blocks/time_blocks.pyindex 338ee88a42..9e95d428b9 100644--- a/autogpt_platform/backend/backend/blocks/time_blocks.py+++ b/autogpt_platform/backend/backend/blocks/time_blocks.py@@ -77,7 +77,7 @@ class GetCurrentDateAndTimeBlock(Block):def __init__(self):super().__init__(- id="b29c1b50-5d0e-4d9f-8f9d-1b0e6fcbf0h2",+ id="716a67b3-6760-42e7-86dc-18645c6e00fc",description="This block outputs the current date and time.",categories={BlockCategory.TEXT},input_schema=GetCurrentDateAndTimeBlock.Input,diff --git a/autogpt_platform/backend/graph_templates/Discord Bot Chat To LLM_v5.json b/autogpt_platform/backend/graph_templates/Discord Bot Chat To LLM_v5.jsonindex b6ea9e6286..34cdfa7ae0 100644--- a/autogpt_platform/backend/graph_templates/Discord Bot Chat To LLM_v5.json+++ b/autogpt_platform/backend/graph_templates/Discord Bot Chat To LLM_v5.json@@ -8,7 +8,7 @@"nodes": [{"id": "b8138bca-7892-42c2-9594-a845d3483413",- "block_id": "d3f4g5h6-1i2j-3k4l-5m6n-7o8p9q0r1s2t",+ "block_id": "df06086a-d5ac-4abb-9996-2ad0acb2eff7","input_default": {},"metadata": {"position": {@@ -59,7 +59,7 @@},{"id": "dda2d061-2ef9-4dc5-9433-918c8395a4ac",- "block_id": "h1i2j3k4-5l6m-7n8o-9p0q-r1s2t3u4v5w6",+ "block_id": "d0822ab5-9f8a-44a3-8971-531dd0178b6b","input_default": {},"metadata": {"position": {diff --git a/autogpt_platform/backend/graph_templates/Discord Chatbot with History_v145.json b/autogpt_platform/backend/graph_templates/Discord Chatbot with History_v145.jsonindex da36ec00de..0da2a83684 100644--- a/autogpt_platform/backend/graph_templates/Discord Chatbot with History_v145.json+++ b/autogpt_platform/backend/graph_templates/Discord Chatbot with History_v145.json@@ -110,7 +110,7 @@},{"id": "b45cfa51-5ead-4621-9f1c-f847dfea3e4c",- "block_id": "d3f4g5h6-1i2j-3k4l-5m6n-7o8p9q0r1s2t",+ "block_id": "df06086a-d5ac-4abb-9996-2ad0acb2eff7","input_default": {},"metadata": {"position": {@@ -146,7 +146,7 @@},{"id": "8eedcf71-1146-4f54-b522-bf9b6e2d26b2",- "block_id": "h1i2j3k4-5l6m-7n8o-9p0q-r1s2t3u4v5w6",+ "block_id": "d0822ab5-9f8a-44a3-8971-531dd0178b6b","input_default": {},"metadata": {"position": {@@ -197,7 +197,7 @@},{"id": "a568daee-45d2-4429-bf33-cbe9e1261f7b",- "block_id": "c3d4e5f6-g7h8-i9j0-k1l2-m3n4o5p6q7r8",+ "block_id": "32a87eab-381e-4dd4-bdb8-4c47151be35a","input_default": {"model": "llama-3.1-70b-versatile","max_tokens": 2000diff --git a/autogpt_platform/backend/graph_templates/Discord Search Bot_v17.json b/autogpt_platform/backend/graph_templates/Discord Search Bot_v17.jsonindex 7de268a970..366fcf7e62 100644--- a/autogpt_platform/backend/graph_templates/Discord Search Bot_v17.json+++ b/autogpt_platform/backend/graph_templates/Discord Search Bot_v17.json@@ -8,7 +8,7 @@"nodes": [{"id": "60ba4aac-1751-4be7-8745-1bd32191d4a2",- "block_id": "d3f4g5h6-1i2j-3k4l-5m6n-7o8p9q0r1s2t",+ "block_id": "df06086a-d5ac-4abb-9996-2ad0acb2eff7","input_default": {},"metadata": {"position": {@@ -45,7 +45,7 @@},{"id": "5658c4f7-8e67-4d30-93f2-157bdbd3ef87",- "block_id": "b2c3d4e5-6f7g-8h9i-0j1k-l2m3n4o5p6q7",+ "block_id": "87840993-2053-44b7-8da4-187ad4ee518c","input_default": {},"metadata": {"position": {@@ -118,7 +118,7 @@},{"id": "f3d62f22-d193-4f04-85d2-164200fca4c0",- "block_id": "h1i2j3k4-5l6m-7n8o-9p0q-r1s2t3u4v5w6",+ "block_id": "d0822ab5-9f8a-44a3-8971-531dd0178b6b","input_default": {},"metadata": {"position": {diff --git a/autogpt_platform/backend/graph_templates/Medium Blogger_v28.json b/autogpt_platform/backend/graph_templates/Medium Blogger_v28.jsonindex 69040bcb1e..2335f1684c 100644--- a/autogpt_platform/backend/graph_templates/Medium Blogger_v28.json+++ b/autogpt_platform/backend/graph_templates/Medium Blogger_v28.json@@ -8,7 +8,7 @@"nodes": [{"id": "382efac9-3def-4baf-b16a-d6d2512a5c8b",- "block_id": "b2c3d4e5-6f7g-8h9i-0j1k-l2m3n4o5p6q7",+ "block_id": "87840993-2053-44b7-8da4-187ad4ee518c","input_default": {"query": "19th July 2024 Microsoft Blackout"},@@ -44,7 +44,7 @@},{"id": "0cd8f670-8956-4942-ba28-aee732ec783f",- "block_id": "b2g2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6",+ "block_id": "0e50422c-6dee-4145-83d6-3a5a392f65de","input_default": {"key": "TITLE"},@@ -57,7 +57,7 @@},{"id": "4a15b6b9-036d-43d3-915a-7e931fbc6522",- "block_id": "b2g2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6",+ "block_id": "0e50422c-6dee-4145-83d6-3a5a392f65de","input_default": {"key": "CONTENT"},diff --git a/autogpt_platform/backend/migrations/20240930151406_reassign_block_ids/migration.sql b/autogpt_platform/backend/migrations/20240930151406_reassign_block_ids/migration.sqlnew file mode 100644index 0000000000..c6f7ae6f33--- /dev/null+++ b/autogpt_platform/backend/migrations/20240930151406_reassign_block_ids/migration.sql@@ -0,0 +1,18 @@+-- Update AgentBlock IDs: this should cascade to the AgentNode and UserBlockCredit tables+UPDATE "AgentBlock"+SET "id" = CASE+ WHEN "id" = 'a1b2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6' THEN '436c3984-57fd-4b85-8e9a-459b356883bd'+ WHEN "id" = 'b2g2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6' THEN '0e50422c-6dee-4145-83d6-3a5a392f65de'+ WHEN "id" = 'c3d4e5f6-7g8h-9i0j-1k2l-m3n4o5p6q7r8' THEN 'a0a69be1-4528-491c-a85a-a4ab6873e3f0'+ WHEN "id" = 'c3d4e5f6-g7h8-i9j0-k1l2-m3n4o5p6q7r8' THEN '32a87eab-381e-4dd4-bdb8-4c47151be35a'+ WHEN "id" = 'b2c3d4e5-6f7g-8h9i-0j1k-l2m3n4o5p6q7' THEN '87840993-2053-44b7-8da4-187ad4ee518c'+ WHEN "id" = 'h1i2j3k4-5l6m-7n8o-9p0q-r1s2t3u4v5w6' THEN 'd0822ab5-9f8a-44a3-8971-531dd0178b6b'+ WHEN "id" = 'd3f4g5h6-1i2j-3k4l-5m6n-7o8p9q0r1s2t' THEN 'df06086a-d5ac-4abb-9996-2ad0acb2eff7'+ WHEN "id" = 'h5e7f8g9-1b2c-3d4e-5f6g-7h8i9j0k1l2m' THEN 'f5b0f5d0-1862-4d61-94be-3ad0fa772760'+ WHEN "id" = 'a1234567-89ab-cdef-0123-456789abcdef' THEN '4335878a-394e-4e67-adf2-919877ff49ae'+ WHEN "id" = 'f8e7d6c5-b4a3-2c1d-0e9f-8g7h6i5j4k3l' THEN 'f66a3543-28d3-4ab5-8945-9b336371e2ce'+ WHEN "id" = 'b29c1b50-5d0e-4d9f-8f9d-1b0e6fcbf0h2' THEN '716a67b3-6760-42e7-86dc-18645c6e00fc'+ WHEN "id" = '31d1064e-7446-4693-o7d4-65e5ca9110d1' THEN 'cc10ff7b-7753-4ff2-9af6-9399b1a7eddc'+ WHEN "id" = 'c6731acb-4105-4zp1-bc9b-03d0036h370g' THEN '5ebe6768-8e5d-41e3-9134-1c7bd89a8d52'+ ELSE "id"+END;diff --git a/autogpt_platform/frontend/src/components/agent-import-form.tsx b/autogpt_platform/frontend/src/components/agent-import-form.tsxindex 4261ed6350..64ca5f8a31 100644--- a/autogpt_platform/frontend/src/components/agent-import-form.tsx+++ b/autogpt_platform/frontend/src/components/agent-import-form.tsx@@ -33,6 +33,44 @@ const formSchema = z.object({importAsTemplate: z.boolean(),});+function updateBlockIDs(graph: Graph) {+ // https://github.com/Significant-Gravitas/AutoGPT/issues/8223+ const updatedBlockIDMap: Record<string, string> = {+ "a1b2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6":+ "436c3984-57fd-4b85-8e9a-459b356883bd",+ "b2g2c3d4-5e6f-7g8h-9i0j-k1l2m3n4o5p6":+ "0e50422c-6dee-4145-83d6-3a5a392f65de",+ "c3d4e5f6-7g8h-9i0j-1k2l-m3n4o5p6q7r8":+ "a0a69be1-4528-491c-a85a-a4ab6873e3f0",+ "c3d4e5f6-g7h8-i9j0-k1l2-m3n4o5p6q7r8":+ "32a87eab-381e-4dd4-bdb8-4c47151be35a",+ "b2c3d4e5-6f7g-8h9i-0j1k-l2m3n4o5p6q7":+ "87840993-2053-44b7-8da4-187ad4ee518c",+ "h1i2j3k4-5l6m-7n8o-9p0q-r1s2t3u4v5w6":+ "d0822ab5-9f8a-44a3-8971-531dd0178b6b",+ "d3f4g5h6-1i2j-3k4l-5m6n-7o8p9q0r1s2t":+ "df06086a-d5ac-4abb-9996-2ad0acb2eff7",+ "h5e7f8g9-1b2c-3d4e-5f6g-7h8i9j0k1l2m":+ "f5b0f5d0-1862-4d61-94be-3ad0fa772760",+ "a1234567-89ab-cdef-0123-456789abcdef":+ "4335878a-394e-4e67-adf2-919877ff49ae",+ "f8e7d6c5-b4a3-2c1d-0e9f-8g7h6i5j4k3l":+ "f66a3543-28d3-4ab5-8945-9b336371e2ce",+ "b29c1b50-5d0e-4d9f-8f9d-1b0e6fcbf0h2":+ "716a67b3-6760-42e7-86dc-18645c6e00fc",+ "31d1064e-7446-4693-o7d4-65e5ca9110d1":+ "cc10ff7b-7753-4ff2-9af6-9399b1a7eddc",+ "c6731acb-4105-4zp1-bc9b-03d0036h370g":+ "5ebe6768-8e5d-41e3-9134-1c7bd89a8d52",+ };+ graph.nodes+ .filter((node) => node.block_id in updatedBlockIDMap)+ .forEach((node) => {+ node.block_id = updatedBlockIDMap[node.block_id];+ });+ return graph;+}+export const AgentImportForm: React.FC<React.FormHTMLAttributes<HTMLFormElement>> = ({ className, ...props }) => {@@ -116,6 +154,7 @@ export const AgentImportForm: React.FC<);}const agent = obj as Graph;+ updateBlockIDs(agent);setAgentObject(agent);form.setValue("agentName", agent.name);form.setValue("agentDescription", agent.description);