mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-08 22:05:08 -05:00
This change introduced async execution for blocks and the execution engine. Paralellism will be achieved through a single process asynchronous execution instead of process concurrency. ### Changes 🏗️ * Support async execution for the graph executor * Removed process creation for node execution * Update all blocks to support async executions ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [x] Manual graph executions, tested many of the impacted blocks.
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
import codecs
|
|
|
|
from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
|
|
from backend.data.model import SchemaField
|
|
|
|
|
|
class TextDecoderBlock(Block):
|
|
class Input(BlockSchema):
|
|
text: str = SchemaField(
|
|
description="A string containing escaped characters to be decoded",
|
|
placeholder='Your entire text block with \\n and \\" escaped characters',
|
|
)
|
|
|
|
class Output(BlockSchema):
|
|
decoded_text: str = SchemaField(
|
|
description="The decoded text with escape sequences processed"
|
|
)
|
|
|
|
def __init__(self):
|
|
super().__init__(
|
|
id="2570e8fe-8447-43ed-84c7-70d657923231",
|
|
description="Decodes a string containing escape sequences into actual text",
|
|
categories={BlockCategory.TEXT},
|
|
input_schema=TextDecoderBlock.Input,
|
|
output_schema=TextDecoderBlock.Output,
|
|
test_input={"text": """Hello\nWorld!\nThis is a \"quoted\" string."""},
|
|
test_output=[
|
|
(
|
|
"decoded_text",
|
|
"""Hello
|
|
World!
|
|
This is a "quoted" string.""",
|
|
)
|
|
],
|
|
)
|
|
|
|
async def run(self, input_data: Input, **kwargs) -> BlockOutput:
|
|
decoded_text = codecs.decode(input_data.text, "unicode_escape")
|
|
yield "decoded_text", decoded_text
|