This commit is contained in:
Zamil Majdy
2024-07-02 14:40:58 +07:00
committed by Aarushi
parent db14c39449
commit f2c06e017e
2 changed files with 37 additions and 19 deletions

View File

@@ -3,7 +3,7 @@
from datetime import datetime, timedelta
import praw
from pydantic import BaseModel
from pydantic import BaseModel, Field
from autogpt_server.data.block import Block, BlockOutput, BlockSchema
@@ -40,14 +40,23 @@ def get_praw(creds: RedditCredentials) -> praw.Reddit:
class RedditGetPostsBlock(Block):
class Input(BlockSchema):
creds: RedditCredentials
subreddit: str
last_minutes: int | None = None
last_post: str | None = None
post_limit: int | None = None
creds: RedditCredentials = Field(description="Reddit credentials")
subreddit: str = Field(description="Subreddit name")
last_minutes: int | None = Field(
description="Post time to stop minutes ago while fetching posts",
default=None
)
last_post: str | None = Field(
description="Post ID to stop when reached while fetching posts",
default=None
)
post_limit: int | None = Field(
description="Number of posts to fetch",
default=10
)
class Output(BlockSchema):
post: RedditPost
post: RedditPost = Field(description="Reddit post")
def __init__(self):
super().__init__(
@@ -77,9 +86,9 @@ class RedditGetPostsBlock(Block):
class RedditPostCommentBlock(Block):
class Input(BlockSchema):
creds: RedditCredentials
post_id: str
comment: str
creds: RedditCredentials = Field(description="Reddit credentials")
post_id: str = Field(description="Reddit post ID")
comment: str = Field(description="Comment text")
class Output(BlockSchema):
comment_id: str

View File

@@ -1,19 +1,20 @@
import re
from typing import Any
from pydantic import Field
from autogpt_server.data.block import Block, BlockOutput, BlockSchema
class TextMatcherBlock(Block):
class Input(BlockSchema):
text: str
match: str
data: Any
case_sensitive: bool = True
text: str = Field(description="Text to match")
match: str = Field(description="Pattern (Regex) to match")
data: Any = Field(description="Data to be forwarded to output")
case_sensitive: bool = Field(description="Case sensitive match", default=True)
class Output(BlockSchema):
positive: Any
negative: Any
positive: Any = Field(description="Output data if match is found")
negative: Any = Field(description="Output data if match is not found")
def __init__(self):
super().__init__(
@@ -33,9 +34,17 @@ class TextMatcherBlock(Block):
class TextFormatterBlock(Block):
class Input(BlockSchema):
texts: list[str] = []
named_texts: dict[str, str] = {}
format: str
texts: list[str] = Field(
description="Texts (list) to format",
default=[]
)
named_texts: dict[str, str] = Field(
description="Texts (dict) to format",
default={}
)
format: str = Field(
description="Template to format the text using `texts` and `named_texts`",
)
class Output(BlockSchema):
output: str