Skip to content

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.

feat(blocks): Various block QoL improvements (#8749)

Nicholas Tindlefd6c1d9f4f91
diff --git a/autogpt_platform/backend/backend/blocks/github/_api.py b/autogpt_platform/backend/backend/blocks/github/_api.py
index 1965caa764..6ec91eeb37 100644
--- a/autogpt_platform/backend/backend/blocks/github/_api.py
+++ b/autogpt_platform/backend/backend/blocks/github/_api.py
@@ -35,9 +35,9 @@ def _get_headers(credentials: GithubCredentials) -> dict[str, str]:
}
-def get_api(credentials: GithubCredentials) -> Requests:
+def get_api(credentials: GithubCredentials, convert_urls: bool = True) -> Requests:
return Requests(
trusted_origins=["https://api.github.com", "https://github.com"],
- extra_url_validator=_convert_to_api_url,
+ extra_url_validator=_convert_to_api_url if convert_urls else None,
extra_headers=_get_headers(credentials),
)
diff --git a/autogpt_platform/backend/backend/blocks/github/issues.py b/autogpt_platform/backend/backend/blocks/github/issues.py
index 8cab07db3f..ff1d0a41ad 100644
--- a/autogpt_platform/backend/backend/blocks/github/issues.py
+++ b/autogpt_platform/backend/backend/blocks/github/issues.py
@@ -46,15 +46,27 @@ class GithubCommentBlock(Block):
categories={BlockCategory.DEVELOPER_TOOLS},
input_schema=GithubCommentBlock.Input,
output_schema=GithubCommentBlock.Output,
- test_input={
- "issue_url": "https://github.com/owner/repo/issues/1",
- "comment": "This is a test comment.",
- "credentials": TEST_CREDENTIALS_INPUT,
- },
+ test_input=[
+ {
+ "issue_url": "https://github.com/owner/repo/issues/1",
+ "comment": "This is a test comment.",
+ "credentials": TEST_CREDENTIALS_INPUT,
+ },
+ {
+ "issue_url": "https://github.com/owner/repo/pull/1",
+ "comment": "This is a test comment.",
+ "credentials": TEST_CREDENTIALS_INPUT,
+ },
+ ],
test_credentials=TEST_CREDENTIALS,
test_output=[
("id", 1337),
("url", "https://github.com/owner/repo/issues/1#issuecomment-1337"),
+ ("id", 1337),
+ (
+ "url",
+ "https://github.com/owner/repo/issues/1#issuecomment-1337",
+ ),
],
test_mock={
"post_comment": lambda *args, **kwargs: (
@@ -70,6 +82,8 @@ class GithubCommentBlock(Block):
) -> tuple[int, str]:
api = get_api(credentials)
data = {"body": body_text}
+ if "pull" in issue_url:
+ issue_url = issue_url.replace("pull", "issues")
comments_url = issue_url + "/comments"
response = api.post(comments_url, json=data)
comment = response.json()
diff --git a/autogpt_platform/backend/backend/blocks/llm.py b/autogpt_platform/backend/backend/blocks/llm.py
index 71e1f2c3a3..e85f24e46b 100644
--- a/autogpt_platform/backend/backend/blocks/llm.py
+++ b/autogpt_platform/backend/backend/blocks/llm.py
@@ -526,7 +526,7 @@ class AIStructuredResponseGeneratorBlock(Block):
class AITextGeneratorBlock(Block):
class Input(BlockSchema):
prompt: str = SchemaField(
- description="The prompt to send to the language model.",
+ description="The prompt to send to the language model. You can use any of the {keys} from Prompt Values to fill in the prompt with values from the prompt values dictionary by putting them in curly braces.",
placeholder="Enter your prompt here...",
)
model: LlmModel = SchemaField(