From 21602d61fc662754915d95326d50f85be97498e8 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 10:15:46 +0000 Subject: [PATCH 01/10] add get contents block --- .../backend/backend/blocks/exa/contents.py | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 autogpt_platform/backend/backend/blocks/exa/contents.py diff --git a/autogpt_platform/backend/backend/blocks/exa/contents.py b/autogpt_platform/backend/backend/blocks/exa/contents.py new file mode 100644 index 000000000000..1cfc32e828c7 --- /dev/null +++ b/autogpt_platform/backend/backend/blocks/exa/contents.py @@ -0,0 +1,83 @@ +from typing import List + +from pydantic import BaseModel + +from backend.blocks.exa._auth import ( + ExaCredentials, + ExaCredentialsField, + ExaCredentialsInput, +) +from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema +from backend.data.model import SchemaField +from backend.util.request import requests + + +class ContentRetrievalSettings(BaseModel): + text: dict = SchemaField( + description="Text content settings", + default={"maxCharacters": 1000, "includeHtmlTags": False}, + ) + highlights: dict = SchemaField( + description="Highlight settings", + default={ + "numSentences": 3, + "highlightsPerUrl": 3, + "query": "", + }, + ) + summary: dict = SchemaField( + description="Summary settings", + default={"query": ""}, + ) + + +class ExaContentsBlock(Block): + class Input(BlockSchema): + credentials: ExaCredentialsInput = ExaCredentialsField() + ids: List[str] = SchemaField( + description="Array of document IDs obtained from searches", + ) + contents: ContentRetrievalSettings = SchemaField( + description="Content retrieval settings", + default=ContentRetrievalSettings(), + ) + + class Output(BlockSchema): + results: list = SchemaField( + description="List of document contents", + default=[], + ) + + def __init__(self): + super().__init__( + id="c52be83f-f8cd-4180-b243-af35f986b461", + description="Retrieves document contents using Exa's contents API", + categories={BlockCategory.SEARCH}, + input_schema=ExaContentsBlock.Input, + output_schema=ExaContentsBlock.Output, + ) + + def run( + self, input_data: Input, *, credentials: ExaCredentials, **kwargs + ) -> BlockOutput: + url = "https://api.exa.ai/contents" + headers = { + "Content-Type": "application/json", + "x-api-key": credentials.api_key.get_secret_value(), + } + + payload = { + "ids": input_data.ids, + "text": input_data.contents.text, + "highlights": input_data.contents.highlights, + "summary": input_data.contents.summary, + } + + try: + response = requests.post(url, headers=headers, json=payload) + response.raise_for_status() + data = response.json() + yield "results", data.get("results", []) + except Exception as e: + yield "error", str(e) + yield "results", [] \ No newline at end of file From a1b8ece5c1fc55cbe291544f3f12389cd367ac54 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 11:00:54 +0000 Subject: [PATCH 02/10] refactor exa --- .../backend/backend/blocks/exa/helpers.py | 18 +++ .../backend/backend/blocks/exa/search.py | 17 +-- .../backend/backend/blocks/exa/similar.py | 126 ++++++++++++++++++ 3 files changed, 145 insertions(+), 16 deletions(-) create mode 100644 autogpt_platform/backend/backend/blocks/exa/helpers.py create mode 100644 autogpt_platform/backend/backend/blocks/exa/similar.py diff --git a/autogpt_platform/backend/backend/blocks/exa/helpers.py b/autogpt_platform/backend/backend/blocks/exa/helpers.py new file mode 100644 index 000000000000..5c2658ff4944 --- /dev/null +++ b/autogpt_platform/backend/backend/blocks/exa/helpers.py @@ -0,0 +1,18 @@ +from pydantic import BaseModel + +from backend.data.model import SchemaField + + +class ContentSettings(BaseModel): + text: dict = SchemaField( + description="Text content settings", + default={"maxCharacters": 1000, "includeHtmlTags": False}, + ) + highlights: dict = SchemaField( + description="Highlight settings", + default={"numSentences": 3, "highlightsPerUrl": 3}, + ) + summary: dict = SchemaField( + description="Summary settings", + default={"query": ""}, + ) \ No newline at end of file diff --git a/autogpt_platform/backend/backend/blocks/exa/search.py b/autogpt_platform/backend/backend/blocks/exa/search.py index ed3270f46a81..333dbae05777 100644 --- a/autogpt_platform/backend/backend/blocks/exa/search.py +++ b/autogpt_platform/backend/backend/blocks/exa/search.py @@ -8,26 +8,11 @@ ExaCredentialsField, ExaCredentialsInput, ) +from backend.blocks.exa.helpers import ContentSettings from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema from backend.data.model import SchemaField from backend.util.request import requests - -class ContentSettings(BaseModel): - text: dict = SchemaField( - description="Text content settings", - default={"maxCharacters": 1000, "includeHtmlTags": False}, - ) - highlights: dict = SchemaField( - description="Highlight settings", - default={"numSentences": 3, "highlightsPerUrl": 3}, - ) - summary: dict = SchemaField( - description="Summary settings", - default={"query": ""}, - ) - - class ExaSearchBlock(Block): class Input(BlockSchema): credentials: ExaCredentialsInput = ExaCredentialsField() diff --git a/autogpt_platform/backend/backend/blocks/exa/similar.py b/autogpt_platform/backend/backend/blocks/exa/similar.py new file mode 100644 index 000000000000..04afee2a7e5e --- /dev/null +++ b/autogpt_platform/backend/backend/blocks/exa/similar.py @@ -0,0 +1,126 @@ +from datetime import datetime +from typing import List + +from pydantic import BaseModel + +from backend.blocks.exa._auth import ( + ExaCredentials, + ExaCredentialsField, + ExaCredentialsInput, +) +from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema +from backend.data.model import SchemaField +from backend.util.request import requests + +from .helpers import ContentSettings + + +class ExaFindSimilarBlock(Block): + class Input(BlockSchema): + credentials: ExaCredentialsInput = ExaCredentialsField() + url: str = SchemaField( + description="The url for which you would like to find similar links" + ) + numResults: int = SchemaField( + description="Number of results to return", + default=10, + ) + includeDomains: List[str] = SchemaField( + description="Domains to include in search", + default=[], + ) + excludeDomains: List[str] = SchemaField( + description="Domains to exclude from search", + default=[], + ) + startCrawlDate: datetime = SchemaField( + description="Start date for crawled content", + ) + endCrawlDate: datetime = SchemaField( + description="End date for crawled content", + ) + startPublishedDate: datetime = SchemaField( + description="Start date for published content", + ) + endPublishedDate: datetime = SchemaField( + description="End date for published content", + ) + includeText: List[str] = SchemaField( + description="Text patterns to include (max 1 string, up to 5 words)", + default=[], + ) + excludeText: List[str] = SchemaField( + description="Text patterns to exclude (max 1 string, up to 5 words)", + default=[], + ) + contents: ContentSettings = SchemaField( + description="Content retrieval settings", + default=ContentSettings(), + ) + + class Output(BlockSchema): + results: list = SchemaField( + description="List of similar documents with title, URL, published date, author, and score", + default=[], + ) + + def __init__(self): + super().__init__( + id="5e7315d1-af61-4a0c-9350-7c868fa7438a", + description="Finds similar links using Exa's findSimilar API", + categories={BlockCategory.SEARCH}, + input_schema=ExaFindSimilarBlock.Input, + output_schema=ExaFindSimilarBlock.Output, + ) + + def run( + self, input_data: Input, *, credentials: ExaCredentials, **kwargs + ) -> BlockOutput: + url = "https://api.exa.ai/findSimilar" + headers = { + "Content-Type": "application/json", + "x-api-key": credentials.api_key.get_secret_value(), + } + + payload = { + "url": input_data.url, + "numResults": input_data.numResults, + "contents": { + "text": input_data.contents.text, + "highlights": input_data.contents.highlights, + "summary": input_data.contents.summary, + }, + } + + # Add optional fields if they have values + optional_fields = [ + "includeDomains", + "excludeDomains", + "includeText", + "excludeText", + ] + for field in optional_fields: + value = getattr(input_data, field) + if value: # Only add non-empty values + payload[field] = value + + # Add dates if they exist + date_fields = [ + "startCrawlDate", + "endCrawlDate", + "startPublishedDate", + "endPublishedDate", + ] + for field in date_fields: + value = getattr(input_data, field, None) + if value: + payload[field] = value.strftime("%Y-%m-%dT%H:%M:%S.000Z") + + try: + response = requests.post(url, headers=headers, json=payload) + response.raise_for_status() + data = response.json() + yield "results", data.get("results", []) + except Exception as e: + yield "error", str(e) + yield "results", [] \ No newline at end of file From 9fe656d473b8147583727363d3aa9a69c8ee2958 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 12:12:55 +0000 Subject: [PATCH 03/10] revamped blocks --- .../backend/backend/blocks/exa/helpers.py | 48 ++++++++++-- .../backend/backend/blocks/exa/search.py | 78 +++++++++---------- .../backend/backend/blocks/exa/similar.py | 66 ++++++++-------- 3 files changed, 110 insertions(+), 82 deletions(-) diff --git a/autogpt_platform/backend/backend/blocks/exa/helpers.py b/autogpt_platform/backend/backend/blocks/exa/helpers.py index 5c2658ff4944..7585e517c4f4 100644 --- a/autogpt_platform/backend/backend/blocks/exa/helpers.py +++ b/autogpt_platform/backend/backend/blocks/exa/helpers.py @@ -1,18 +1,54 @@ +from typing import Optional + from pydantic import BaseModel from backend.data.model import SchemaField +class TextSettings(BaseModel): + max_characters: int = SchemaField( + default=1000, + description="Maximum number of characters to return", + placeholder="1000", + ) + include_html_tags: bool = SchemaField( + default=False, + description="Whether to include HTML tags in the text", + placeholder="False", + ) + + +class HighlightSettings(BaseModel): + num_sentences: int = SchemaField( + default=3, + description="Number of sentences per highlight", + placeholder="3", + ) + highlights_per_url: int = SchemaField( + default=3, + description="Number of highlights per URL", + placeholder="3", + ) + + +class SummarySettings(BaseModel): + query: Optional[str] = SchemaField( + default="", + description="Query string for summarization", + placeholder="Enter query", + ) + + class ContentSettings(BaseModel): - text: dict = SchemaField( + text: TextSettings = SchemaField( + default=TextSettings(), description="Text content settings", - default={"maxCharacters": 1000, "includeHtmlTags": False}, ) - highlights: dict = SchemaField( + highlights: HighlightSettings = SchemaField( + default=HighlightSettings(), description="Highlight settings", - default={"numSentences": 3, "highlightsPerUrl": 3}, ) - summary: dict = SchemaField( + summary: SummarySettings = SchemaField( + default=SummarySettings(), description="Summary settings", - default={"query": ""}, ) \ No newline at end of file diff --git a/autogpt_platform/backend/backend/blocks/exa/search.py b/autogpt_platform/backend/backend/blocks/exa/search.py index 333dbae05777..8a6afe5883ad 100644 --- a/autogpt_platform/backend/backend/blocks/exa/search.py +++ b/autogpt_platform/backend/backend/blocks/exa/search.py @@ -17,7 +17,7 @@ class ExaSearchBlock(Block): class Input(BlockSchema): credentials: ExaCredentialsInput = ExaCredentialsField() query: str = SchemaField(description="The search query") - useAutoprompt: bool = SchemaField( + use_auto_prompt: bool = SchemaField( description="Whether to use autoprompt", default=True, ) @@ -29,35 +29,35 @@ class Input(BlockSchema): description="Category to search within", default="", ) - numResults: int = SchemaField( + number_of_results: int = SchemaField( description="Number of results to return", default=10, ) - includeDomains: List[str] = SchemaField( + include_domains: List[str] = SchemaField( description="Domains to include in search", default=[], ) - excludeDomains: List[str] = SchemaField( + exclude_domains: List[str] = SchemaField( description="Domains to exclude from search", default=[], ) - startCrawlDate: datetime = SchemaField( + start_crawl_date: datetime = SchemaField( description="Start date for crawled content", ) - endCrawlDate: datetime = SchemaField( + end_crawl_date: datetime = SchemaField( description="End date for crawled content", ) - startPublishedDate: datetime = SchemaField( + start_published_date: datetime = SchemaField( description="Start date for published content", ) - endPublishedDate: datetime = SchemaField( + end_published_date: datetime = SchemaField( description="End date for published content", ) - includeText: List[str] = SchemaField( + include_text: List[str] = SchemaField( description="Text patterns to include", default=[], ) - excludeText: List[str] = SchemaField( + exclude_text: List[str] = SchemaField( description="Text patterns to exclude", default=[], ) @@ -82,7 +82,7 @@ def __init__(self): ) def run( - self, input_data: Input, *, credentials: ExaCredentials, **kwargs + self, input_data: Input, *, credentials: ExaCredentials, **kwargs ) -> BlockOutput: url = "https://api.exa.ai/search" headers = { @@ -92,44 +92,38 @@ def run( payload = { "query": input_data.query, - "useAutoprompt": input_data.useAutoprompt, - "numResults": input_data.numResults, - "contents": { - "text": {"maxCharacters": 1000, "includeHtmlTags": False}, - "highlights": { - "numSentences": 3, - "highlightsPerUrl": 3, - }, - "summary": {"query": ""}, - }, + "useAutoprompt": input_data.use_auto_prompt, + "numResults": input_data.number_of_results, + "contents": input_data.contents.dict(), + } + + date_field_mapping = { + "start_crawl_date": "startCrawlDate", + "end_crawl_date": "endCrawlDate", + "start_published_date": "startPublishedDate", + "end_published_date": "endPublishedDate", } # Add dates if they exist - date_fields = [ - "startCrawlDate", - "endCrawlDate", - "startPublishedDate", - "endPublishedDate", - ] - for field in date_fields: - value = getattr(input_data, field, None) + for input_field, api_field in date_field_mapping.items(): + value = getattr(input_data, input_field, None) if value: - payload[field] = value.strftime("%Y-%m-%dT%H:%M:%S.000Z") + payload[api_field] = value.strftime("%Y-%m-%dT%H:%M:%S.000Z") - # Add other fields - optional_fields = [ - "type", - "category", - "includeDomains", - "excludeDomains", - "includeText", - "excludeText", - ] + optional_field_mapping = { + "type": "type", + "category": "category", + "include_domains": "includeDomains", + "exclude_domains": "excludeDomains", + "include_text": "includeText", + "exclude_text": "excludeText", + } - for field in optional_fields: - value = getattr(input_data, field) + # Add other fields + for input_field, api_field in optional_field_mapping.items(): + value = getattr(input_data, input_field) if value: # Only add non-empty values - payload[field] = value + payload[api_field] = value try: response = requests.post(url, headers=headers, json=payload) diff --git a/autogpt_platform/backend/backend/blocks/exa/similar.py b/autogpt_platform/backend/backend/blocks/exa/similar.py index 04afee2a7e5e..16733687ac03 100644 --- a/autogpt_platform/backend/backend/blocks/exa/similar.py +++ b/autogpt_platform/backend/backend/blocks/exa/similar.py @@ -21,35 +21,35 @@ class Input(BlockSchema): url: str = SchemaField( description="The url for which you would like to find similar links" ) - numResults: int = SchemaField( + number_of_results: int = SchemaField( description="Number of results to return", default=10, ) - includeDomains: List[str] = SchemaField( + include_domains: List[str] = SchemaField( description="Domains to include in search", default=[], ) - excludeDomains: List[str] = SchemaField( + exclude_domains: List[str] = SchemaField( description="Domains to exclude from search", default=[], ) - startCrawlDate: datetime = SchemaField( + start_crawl_date: datetime = SchemaField( description="Start date for crawled content", ) - endCrawlDate: datetime = SchemaField( + end_crawl_date: datetime = SchemaField( description="End date for crawled content", ) - startPublishedDate: datetime = SchemaField( + start_published_date: datetime = SchemaField( description="Start date for published content", ) - endPublishedDate: datetime = SchemaField( + end_published_date: datetime = SchemaField( description="End date for published content", ) - includeText: List[str] = SchemaField( + include_text: List[str] = SchemaField( description="Text patterns to include (max 1 string, up to 5 words)", default=[], ) - excludeText: List[str] = SchemaField( + exclude_text: List[str] = SchemaField( description="Text patterns to exclude (max 1 string, up to 5 words)", default=[], ) @@ -74,7 +74,7 @@ def __init__(self): ) def run( - self, input_data: Input, *, credentials: ExaCredentials, **kwargs + self, input_data: Input, *, credentials: ExaCredentials, **kwargs ) -> BlockOutput: url = "https://api.exa.ai/findSimilar" headers = { @@ -84,37 +84,35 @@ def run( payload = { "url": input_data.url, - "numResults": input_data.numResults, - "contents": { - "text": input_data.contents.text, - "highlights": input_data.contents.highlights, - "summary": input_data.contents.summary, - }, + "numResults": input_data.number_of_results, + "contents": input_data.contents.dict(), + } + + optional_field_mapping = { + "include_domains": "includeDomains", + "exclude_domains": "excludeDomains", + "include_text": "includeText", + "exclude_text": "excludeText", } # Add optional fields if they have values - optional_fields = [ - "includeDomains", - "excludeDomains", - "includeText", - "excludeText", - ] - for field in optional_fields: - value = getattr(input_data, field) + for input_field, api_field in optional_field_mapping.items(): + value = getattr(input_data, input_field) if value: # Only add non-empty values - payload[field] = value + payload[api_field] = value + + date_field_mapping = { + "start_crawl_date": "startCrawlDate", + "end_crawl_date": "endCrawlDate", + "start_published_date": "startPublishedDate", + "end_published_date": "endPublishedDate", + } # Add dates if they exist - date_fields = [ - "startCrawlDate", - "endCrawlDate", - "startPublishedDate", - "endPublishedDate", - ] - for field in date_fields: - value = getattr(input_data, field, None) + for input_field, api_field in date_field_mapping.items(): + value = getattr(input_data, input_field, None) if value: - payload[field] = value.strftime("%Y-%m-%dT%H:%M:%S.000Z") + payload[api_field] = value.strftime("%Y-%m-%dT%H:%M:%S.000Z") try: response = requests.post(url, headers=headers, json=payload) From 627f6f26982b412fd21bfa345a7f363149d1654f Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 12:13:38 +0000 Subject: [PATCH 04/10] linting --- autogpt_platform/backend/backend/blocks/exa/contents.py | 2 +- autogpt_platform/backend/backend/blocks/exa/helpers.py | 2 +- autogpt_platform/backend/backend/blocks/exa/search.py | 5 ++--- autogpt_platform/backend/backend/blocks/exa/similar.py | 6 ++---- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/autogpt_platform/backend/backend/blocks/exa/contents.py b/autogpt_platform/backend/backend/blocks/exa/contents.py index 1cfc32e828c7..919d24f73930 100644 --- a/autogpt_platform/backend/backend/blocks/exa/contents.py +++ b/autogpt_platform/backend/backend/blocks/exa/contents.py @@ -80,4 +80,4 @@ def run( yield "results", data.get("results", []) except Exception as e: yield "error", str(e) - yield "results", [] \ No newline at end of file + yield "results", [] diff --git a/autogpt_platform/backend/backend/blocks/exa/helpers.py b/autogpt_platform/backend/backend/blocks/exa/helpers.py index 7585e517c4f4..a392d5367fed 100644 --- a/autogpt_platform/backend/backend/blocks/exa/helpers.py +++ b/autogpt_platform/backend/backend/blocks/exa/helpers.py @@ -51,4 +51,4 @@ class ContentSettings(BaseModel): summary: SummarySettings = SchemaField( default=SummarySettings(), description="Summary settings", - ) \ No newline at end of file + ) diff --git a/autogpt_platform/backend/backend/blocks/exa/search.py b/autogpt_platform/backend/backend/blocks/exa/search.py index 8a6afe5883ad..c26a5826fec0 100644 --- a/autogpt_platform/backend/backend/blocks/exa/search.py +++ b/autogpt_platform/backend/backend/blocks/exa/search.py @@ -1,8 +1,6 @@ from datetime import datetime from typing import List -from pydantic import BaseModel - from backend.blocks.exa._auth import ( ExaCredentials, ExaCredentialsField, @@ -13,6 +11,7 @@ from backend.data.model import SchemaField from backend.util.request import requests + class ExaSearchBlock(Block): class Input(BlockSchema): credentials: ExaCredentialsInput = ExaCredentialsField() @@ -82,7 +81,7 @@ def __init__(self): ) def run( - self, input_data: Input, *, credentials: ExaCredentials, **kwargs + self, input_data: Input, *, credentials: ExaCredentials, **kwargs ) -> BlockOutput: url = "https://api.exa.ai/search" headers = { diff --git a/autogpt_platform/backend/backend/blocks/exa/similar.py b/autogpt_platform/backend/backend/blocks/exa/similar.py index 16733687ac03..dae6639b688a 100644 --- a/autogpt_platform/backend/backend/blocks/exa/similar.py +++ b/autogpt_platform/backend/backend/blocks/exa/similar.py @@ -1,8 +1,6 @@ from datetime import datetime from typing import List -from pydantic import BaseModel - from backend.blocks.exa._auth import ( ExaCredentials, ExaCredentialsField, @@ -74,7 +72,7 @@ def __init__(self): ) def run( - self, input_data: Input, *, credentials: ExaCredentials, **kwargs + self, input_data: Input, *, credentials: ExaCredentials, **kwargs ) -> BlockOutput: url = "https://api.exa.ai/findSimilar" headers = { @@ -121,4 +119,4 @@ def run( yield "results", data.get("results", []) except Exception as e: yield "error", str(e) - yield "results", [] \ No newline at end of file + yield "results", [] From 9cfea444f0de687864c27fe32a331981c323a139 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 12:22:14 +0000 Subject: [PATCH 05/10] make contents block advanced fields --- .../backend/backend/blocks/exa/contents.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/autogpt_platform/backend/backend/blocks/exa/contents.py b/autogpt_platform/backend/backend/blocks/exa/contents.py index 919d24f73930..5317f56e31a4 100644 --- a/autogpt_platform/backend/backend/blocks/exa/contents.py +++ b/autogpt_platform/backend/backend/blocks/exa/contents.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Optional from pydantic import BaseModel @@ -13,21 +13,24 @@ class ContentRetrievalSettings(BaseModel): - text: dict = SchemaField( + text: Optional[dict] = SchemaField( description="Text content settings", default={"maxCharacters": 1000, "includeHtmlTags": False}, + advanced=True, ) - highlights: dict = SchemaField( + highlights: Optional[dict] = SchemaField( description="Highlight settings", default={ "numSentences": 3, "highlightsPerUrl": 3, "query": "", }, + advanced=True, ) - summary: dict = SchemaField( + summary: Optional[dict] = SchemaField( description="Summary settings", default={"query": ""}, + advanced=True, ) @@ -40,6 +43,7 @@ class Input(BlockSchema): contents: ContentRetrievalSettings = SchemaField( description="Content retrieval settings", default=ContentRetrievalSettings(), + advanced=True, ) class Output(BlockSchema): From 9dae615c626f67a5ad753b8edfa24735c0435665 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 12:25:18 +0000 Subject: [PATCH 06/10] make search and similar have advanced fields --- autogpt_platform/backend/backend/blocks/exa/search.py | 8 ++++++++ autogpt_platform/backend/backend/blocks/exa/similar.py | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/autogpt_platform/backend/backend/blocks/exa/search.py b/autogpt_platform/backend/backend/blocks/exa/search.py index c26a5826fec0..f06962e52718 100644 --- a/autogpt_platform/backend/backend/blocks/exa/search.py +++ b/autogpt_platform/backend/backend/blocks/exa/search.py @@ -19,18 +19,22 @@ class Input(BlockSchema): use_auto_prompt: bool = SchemaField( description="Whether to use autoprompt", default=True, + advanced=True, ) type: str = SchemaField( description="Type of search", default="", + advanced=True, ) category: str = SchemaField( description="Category to search within", default="", + advanced=True, ) number_of_results: int = SchemaField( description="Number of results to return", default=10, + advanced=True, ) include_domains: List[str] = SchemaField( description="Domains to include in search", @@ -39,6 +43,7 @@ class Input(BlockSchema): exclude_domains: List[str] = SchemaField( description="Domains to exclude from search", default=[], + advanced=True, ) start_crawl_date: datetime = SchemaField( description="Start date for crawled content", @@ -55,14 +60,17 @@ class Input(BlockSchema): include_text: List[str] = SchemaField( description="Text patterns to include", default=[], + advanced=True, ) exclude_text: List[str] = SchemaField( description="Text patterns to exclude", default=[], + advanced=True, ) contents: ContentSettings = SchemaField( description="Content retrieval settings", default=ContentSettings(), + advanced=True, ) class Output(BlockSchema): diff --git a/autogpt_platform/backend/backend/blocks/exa/similar.py b/autogpt_platform/backend/backend/blocks/exa/similar.py index dae6639b688a..45792731265e 100644 --- a/autogpt_platform/backend/backend/blocks/exa/similar.py +++ b/autogpt_platform/backend/backend/blocks/exa/similar.py @@ -22,14 +22,17 @@ class Input(BlockSchema): number_of_results: int = SchemaField( description="Number of results to return", default=10, + advanced=True, ) include_domains: List[str] = SchemaField( description="Domains to include in search", default=[], + advanced=True, ) exclude_domains: List[str] = SchemaField( description="Domains to exclude from search", default=[], + advanced=True, ) start_crawl_date: datetime = SchemaField( description="Start date for crawled content", @@ -46,14 +49,17 @@ class Input(BlockSchema): include_text: List[str] = SchemaField( description="Text patterns to include (max 1 string, up to 5 words)", default=[], + advanced=True, ) exclude_text: List[str] = SchemaField( description="Text patterns to exclude (max 1 string, up to 5 words)", default=[], + advanced=True, ) contents: ContentSettings = SchemaField( description="Content retrieval settings", default=ContentSettings(), + advanced=True, ) class Output(BlockSchema): From 0bc564670eaba345eb9acc2f09edbc17bb3369b5 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 12:40:00 +0000 Subject: [PATCH 07/10] update css --- .../frontend/src/components/customnode.css | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/autogpt_platform/frontend/src/components/customnode.css b/autogpt_platform/frontend/src/components/customnode.css index b361257c7313..64b6bc17a281 100644 --- a/autogpt_platform/frontend/src/components/customnode.css +++ b/autogpt_platform/frontend/src/components/customnode.css @@ -4,6 +4,79 @@ transition: border-color 0.3s ease-in-out; } +.custom-node [data-id="input-handles"] { + padding: 0 1.25rem; + margin-bottom: 1rem; +} + +.custom-node [data-id="input-handles"] > div > div { + margin-bottom: 1rem; +} + +.handle-container { + display: flex; + position: relative; + margin-bottom: 0px; + padding: 0.75rem 1.25rem; + min-height: 44px; + height: 100%; +} + +.custom-node input:not([type="checkbox"]), +.custom-node textarea, +.custom-node select { + width: calc(100% - 2.5rem); + max-width: 400px; + margin: 0.5rem 1.25rem; +} + +.custom-node [data-id^="date-picker"] { + margin: 0.5rem 1.25rem; + width: calc(100% - 2.5rem); +} + + +.custom-node [data-list-container] { + margin: 0.5rem 1.25rem; + width: calc(100% - 2.5rem); +} + + +.custom-node [data-add-item] { + margin: 0.5rem 1.25rem; + width: calc(100% - 2.5rem); + padding: 0.5rem; +} + + +.array-item-container { + display: flex; + align-items: center; + margin: 0.5rem 1.25rem; + width: calc(100% - 2.5rem); +} + + +.custom-node [data-content-settings] { + margin: 0.5rem 1.25rem; + width: calc(100% - 2.5rem); +} + + +.custom-node .custom-switch { + padding: 0.5rem 1.25rem; + display: flex; + align-items: center; + justify-content: space-between; +} + +.error-message { + color: #d9534f; + font-size: 13px; + margin: 0.25rem 1.25rem; + padding-left: 0.5rem; +} + /* Existing styles */ .handle-container { display: flex; From fe23c87e3eefd73438bb56e0ca54eee0ec7ffd05 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 12:56:51 +0000 Subject: [PATCH 08/10] linter --- autogpt_platform/frontend/src/components/customnode.css | 5 ----- 1 file changed, 5 deletions(-) diff --git a/autogpt_platform/frontend/src/components/customnode.css b/autogpt_platform/frontend/src/components/customnode.css index 64b6bc17a281..dd116fc67272 100644 --- a/autogpt_platform/frontend/src/components/customnode.css +++ b/autogpt_platform/frontend/src/components/customnode.css @@ -35,20 +35,17 @@ width: calc(100% - 2.5rem); } - .custom-node [data-list-container] { margin: 0.5rem 1.25rem; width: calc(100% - 2.5rem); } - .custom-node [data-add-item] { margin: 0.5rem 1.25rem; width: calc(100% - 2.5rem); padding: 0.5rem; } - .array-item-container { display: flex; align-items: center; @@ -56,13 +53,11 @@ width: calc(100% - 2.5rem); } - .custom-node [data-content-settings] { margin: 0.5rem 1.25rem; width: calc(100% - 2.5rem); } - .custom-node .custom-switch { padding: 0.5rem 1.25rem; display: flex; From 183b0af10038668fd5befab7672197b8a89d2397 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 13:39:44 +0000 Subject: [PATCH 09/10] list any --- autogpt_platform/backend/backend/blocks/exa/similar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogpt_platform/backend/backend/blocks/exa/similar.py b/autogpt_platform/backend/backend/blocks/exa/similar.py index 45792731265e..d7fcdcb4a6a8 100644 --- a/autogpt_platform/backend/backend/blocks/exa/similar.py +++ b/autogpt_platform/backend/backend/blocks/exa/similar.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import List +from typing import List, Any from backend.blocks.exa._auth import ( ExaCredentials, @@ -63,7 +63,7 @@ class Input(BlockSchema): ) class Output(BlockSchema): - results: list = SchemaField( + results: List[Any] = SchemaField( description="List of similar documents with title, URL, published date, author, and score", default=[], ) From a9bede8f50f023fef1302adb4dbe2379a73c9c00 Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 20 Dec 2024 13:55:13 +0000 Subject: [PATCH 10/10] linting --- autogpt_platform/backend/backend/blocks/exa/similar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogpt_platform/backend/backend/blocks/exa/similar.py b/autogpt_platform/backend/backend/blocks/exa/similar.py index d7fcdcb4a6a8..b9a44fe9023d 100644 --- a/autogpt_platform/backend/backend/blocks/exa/similar.py +++ b/autogpt_platform/backend/backend/blocks/exa/similar.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import List, Any +from typing import Any, List from backend.blocks.exa._auth import ( ExaCredentials,