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(server): author and contributor information on blocks (#7575)
Nicholas Tindleccf4397883bb
diff --git a/rnd/autogpt_server/autogpt_server/blocks/read_csv.py b/rnd/autogpt_server/autogpt_server/blocks/read_csv.pyindex 19604582b0..7044c515b7 100644--- a/rnd/autogpt_server/autogpt_server/blocks/read_csv.py+++ b/rnd/autogpt_server/autogpt_server/blocks/read_csv.py@@ -1,4 +1,5 @@-from autogpt_server.data.block import Block, BlockOutput, BlockSchema+from autogpt_server.data.block import Block, BlockCategory, BlockOutput, BlockSchema+from autogpt_server.data.model import ContributorDetailsclass ReadCsvBlock(Block):@@ -20,6 +21,8 @@ class ReadCsvBlock(Block):id="acf7625e-d2cb-4941-bfeb-2819fc6fc015",input_schema=ReadCsvBlock.Input,output_schema=ReadCsvBlock.Output,+ contributors=[ContributorDetails(name="Nicholas Tindle")],+ categories={BlockCategory.TEXT},test_input={"contents": "a, b, c\n1,2,3\n4,5,6",},diff --git a/rnd/autogpt_server/autogpt_server/data/block.py b/rnd/autogpt_server/autogpt_server/data/block.pyindex 4171566522..b3747c0ea6 100644--- a/rnd/autogpt_server/autogpt_server/data/block.py+++ b/rnd/autogpt_server/autogpt_server/data/block.py@@ -7,6 +7,7 @@ import jsonschemafrom prisma.models import AgentBlockfrom pydantic import BaseModel+from autogpt_server.data.model import ContributorDetailsfrom autogpt_server.util import jsonBlockData = tuple[str, Any] # Input & Output data should be a tuple of (name, data).@@ -111,10 +112,12 @@ class EmptySchema(BlockSchema):class Block(ABC, Generic[BlockSchemaInputType, BlockSchemaOutputType]):+def __init__(self,id: str = "",description: str = "",+ contributors: list[ContributorDetails] = [],categories: set[BlockCategory] | None = None,input_schema: Type[BlockSchemaInputType] = EmptySchema,output_schema: Type[BlockSchemaOutputType] = EmptySchema,@@ -143,6 +146,7 @@ class Block(ABC, Generic[BlockSchemaInputType, BlockSchemaOutputType]):self.test_mock = test_mockself.description = descriptionself.categories = categories or set()+ self.contributors = contributors or set()@abstractmethoddef run(self, input_data: BlockSchemaInputType) -> BlockOutput:@@ -169,6 +173,7 @@ class Block(ABC, Generic[BlockSchemaInputType, BlockSchemaOutputType]):"outputSchema": self.output_schema.jsonschema(),"description": self.description,"categories": [category.dict() for category in self.categories],+ "contributors": [contributor.dict() for contributor in self.contributors],}def execute(self, input_data: BlockInput) -> BlockOutput:diff --git a/rnd/autogpt_server/autogpt_server/data/model.py b/rnd/autogpt_server/autogpt_server/data/model.pyindex b86c05f25f..a31b3e235e 100644--- a/rnd/autogpt_server/autogpt_server/data/model.py+++ b/rnd/autogpt_server/autogpt_server/data/model.py@@ -2,7 +2,7 @@ from __future__ import annotationsfrom typing import Any, Callable, ClassVar, Optional, TypeVar-from pydantic import Field, GetCoreSchemaHandler+from pydantic import BaseModel, Field, GetCoreSchemaHandlerfrom pydantic_core import (CoreSchema,PydanticUndefined,@@ -116,3 +116,7 @@ def SchemaField(json_schema_extra=json_extra,**kwargs,)+++class ContributorDetails(BaseModel):+ name: str = Field(title="Name", description="The name of the contributor.")