forked from Significant-Gravitas/AutoGPT
Compare commits
16 Commits
master
...
zamilmajdy
Author | SHA1 | Date |
---|---|---|
|
12bd53f0ab | |
|
a16a2c7ec9 | |
|
2f61b3a5c6 | |
|
8830a7f412 | |
|
a035b937ac | |
|
009b369a57 | |
|
a0ecaa3e4d | |
|
04dbc16df8 | |
|
7e1be857f0 | |
|
252cd2aa1e | |
|
6d3503b0f2 | |
|
80d25ba9fd | |
|
dff3e9fefb | |
|
eba8acf13f | |
|
976c8d5afb | |
|
57ddeb4574 |
|
@ -2,13 +2,28 @@ from typing import Any
|
||||||
|
|
||||||
from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
|
from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
|
||||||
from backend.data.model import SchemaField
|
from backend.data.model import SchemaField
|
||||||
|
from backend.util.json import json
|
||||||
|
|
||||||
|
|
||||||
class StepThroughItemsBlock(Block):
|
class StepThroughItemsBlock(Block):
|
||||||
class Input(BlockSchema):
|
class Input(BlockSchema):
|
||||||
items: list | dict = SchemaField(
|
items: list = SchemaField(
|
||||||
|
advanced=False,
|
||||||
description="The list or dictionary of items to iterate over",
|
description="The list or dictionary of items to iterate over",
|
||||||
placeholder="[1, 2, 3, 4, 5] or {'key1': 'value1', 'key2': 'value2'}",
|
placeholder="[1, 2, 3, 4, 5] or {'key1': 'value1', 'key2': 'value2'}",
|
||||||
|
default=[],
|
||||||
|
)
|
||||||
|
items_object: dict = SchemaField(
|
||||||
|
advanced=False,
|
||||||
|
description="The list or dictionary of items to iterate over",
|
||||||
|
placeholder="[1, 2, 3, 4, 5] or {'key1': 'value1', 'key2': 'value2'}",
|
||||||
|
default={},
|
||||||
|
)
|
||||||
|
items_str: str = SchemaField(
|
||||||
|
advanced=False,
|
||||||
|
description="The list or dictionary of items to iterate over",
|
||||||
|
placeholder="[1, 2, 3, 4, 5] or {'key1': 'value1', 'key2': 'value2'}",
|
||||||
|
default="",
|
||||||
)
|
)
|
||||||
|
|
||||||
class Output(BlockSchema):
|
class Output(BlockSchema):
|
||||||
|
@ -39,7 +54,13 @@ class StepThroughItemsBlock(Block):
|
||||||
)
|
)
|
||||||
|
|
||||||
def run(self, input_data: Input, **kwargs) -> BlockOutput:
|
def run(self, input_data: Input, **kwargs) -> BlockOutput:
|
||||||
items = input_data.items
|
for data in [input_data.items, input_data.items_object, input_data.items_str]:
|
||||||
|
if not data:
|
||||||
|
continue
|
||||||
|
if isinstance(data, str):
|
||||||
|
items = json.loads(data)
|
||||||
|
else:
|
||||||
|
items = data
|
||||||
if isinstance(items, dict):
|
if isinstance(items, dict):
|
||||||
# If items is a dictionary, iterate over its values
|
# If items is a dictionary, iterate over its values
|
||||||
for item in items.values():
|
for item in items.values():
|
||||||
|
|
|
@ -140,20 +140,25 @@ class GetCurrentDateAndTimeBlock(Block):
|
||||||
class CountdownTimerBlock(Block):
|
class CountdownTimerBlock(Block):
|
||||||
class Input(BlockSchema):
|
class Input(BlockSchema):
|
||||||
input_message: Any = SchemaField(
|
input_message: Any = SchemaField(
|
||||||
|
advanced=False,
|
||||||
description="Message to output after the timer finishes",
|
description="Message to output after the timer finishes",
|
||||||
default="timer finished",
|
default="timer finished",
|
||||||
)
|
)
|
||||||
seconds: Union[int, str] = SchemaField(
|
seconds: Union[int, str] = SchemaField(
|
||||||
description="Duration in seconds", default=0
|
advanced=False, description="Duration in seconds", default=0
|
||||||
)
|
)
|
||||||
minutes: Union[int, str] = SchemaField(
|
minutes: Union[int, str] = SchemaField(
|
||||||
description="Duration in minutes", default=0
|
advanced=False, description="Duration in minutes", default=0
|
||||||
|
)
|
||||||
|
hours: Union[int, str] = SchemaField(
|
||||||
|
advanced=False, description="Duration in hours", default=0
|
||||||
|
)
|
||||||
|
days: Union[int, str] = SchemaField(
|
||||||
|
advanced=False, description="Duration in days", default=0
|
||||||
)
|
)
|
||||||
hours: Union[int, str] = SchemaField(description="Duration in hours", default=0)
|
|
||||||
days: Union[int, str] = SchemaField(description="Duration in days", default=0)
|
|
||||||
|
|
||||||
class Output(BlockSchema):
|
class Output(BlockSchema):
|
||||||
output_message: str = SchemaField(
|
output_message: Any = SchemaField(
|
||||||
description="Message after the timer finishes"
|
description="Message after the timer finishes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue