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.
tweak(rnd): Hide non required field on Blocks (#7977)
Zamil Majdy54694709bbd9
diff --git a/rnd/autogpt_server/.env.example b/rnd/autogpt_server/.env.exampleindex aac0cf5ef6..5df926e0ba 100644--- a/rnd/autogpt_server/.env.example+++ b/rnd/autogpt_server/.env.example@@ -4,5 +4,49 @@ DB_NAME=agpt_localDB_PORT=5432DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}"PRISMA_SCHEMA="postgres/schema.prisma"-ENABLE_AUTH="false"++REDIS_HOST=localhost+REDIS_PORT=6379+REDIS_PASSWORD=password++AUTH_ENABLED=falseAPP_ENV="local"+SENTRY_DSN=++## ===== OPTIONAL API KEYS ===== ##++# LLM+OPENAI_API_KEY=+ANTHROPIC_API_KEY=+GROQ_API_KEY=++REDDIT_CLIENT_ID=+REDDIT_CLIENT_SECRET=+REDDIT_USERNAME=+REDDIT_PASSWORD=++# Discord+DISCORD_BOT_TOKEN=++# SMTP/Email+SMTP_SERVER=+SMTP_PORT=+SMTP_USERNAME=+SMTP_PASSWORD=++# D-ID+DID_API_KEY=++# Open Weather Map+OPENWEATHERMAP_API_KEY=++# SMTP+SMTP_SERVER=+SMTP_PORT=+SMTP_USERNAME=+SMTP_PASSWORD=++# Medium+MEDIUM_API_KEY=+MEDIUM_AUTHOR_ID=diff --git a/rnd/autogpt_server/.env.template b/rnd/autogpt_server/.env.templatedeleted file mode 100644index 396441a4c3..0000000000--- a/rnd/autogpt_server/.env.template+++ /dev/null@@ -1,22 +0,0 @@-# LLM-OPENAI_API_KEY=-ANTHROPIC_API_KEY=-GROQ_API_KEY=--REDDIT_CLIENT_ID=-REDDIT_CLIENT_SECRET=-REDDIT_USERNAME=-REDDIT_PASSWORD=--# Discord-DISCORD_BOT_TOKEN=--# SMTP/Email-SMTP_SERVER=-SMTP_PORT=-SMTP_USERNAME=-SMTP_PASSWORD=--# D-ID-DID_API_KEY=\ No newline at end of filediff --git a/rnd/autogpt_server/autogpt_server/blocks/llm.py b/rnd/autogpt_server/autogpt_server/blocks/llm.pyindex 3165f929f7..edfc8f7064 100644--- a/rnd/autogpt_server/autogpt_server/blocks/llm.py+++ b/rnd/autogpt_server/autogpt_server/blocks/llm.py@@ -84,6 +84,9 @@ class AIStructuredResponseGeneratorBlock(Block):api_key: BlockSecret = SecretField(value="")sys_prompt: str = ""retry: int = 3+ prompt_values: dict[str, str] = SchemaField(+ advanced=False, default={}, description="Values used to fill in the prompt."+ )class Output(BlockSchema):response: dict[str, str]@@ -167,6 +170,11 @@ class AIStructuredResponseGeneratorBlock(Block):lines = s.strip().split("\n")return "\n".join([line.strip().lstrip("|") for line in lines])+ values = input_data.prompt_values+ if values:+ input_data.prompt = input_data.prompt.format(**values)+ input_data.sys_prompt = input_data.sys_prompt.format(**values)+if input_data.sys_prompt:prompt.append({"role": "system", "content": input_data.sys_prompt})@@ -252,6 +260,9 @@ class AITextGeneratorBlock(Block):api_key: BlockSecret = SecretField(value="")sys_prompt: str = ""retry: int = 3+ prompt_values: dict[str, str] = SchemaField(+ advanced=False, default={}, description="Values used to fill in the prompt."+ )class Output(BlockSchema):response: strdiff --git a/rnd/autogpt_server/autogpt_server/data/block.py b/rnd/autogpt_server/autogpt_server/data/block.pyindex 38de9dd351..2d5637e66c 100644--- a/rnd/autogpt_server/autogpt_server/data/block.py+++ b/rnd/autogpt_server/autogpt_server/data/block.py@@ -59,6 +59,12 @@ class BlockSchema(BaseModel):return objcls.cached_jsonschema = cast(dict[str, Any], ref_to_dict(model))++ # Set default properties values+ for field in cls.cached_jsonschema.get("properties", {}).values():+ if isinstance(field, dict) and "advanced" not in field:+ field["advanced"] = True+return cls.cached_jsonschema@classmethoddiff --git a/rnd/autogpt_server/autogpt_server/data/model.py b/rnd/autogpt_server/autogpt_server/data/model.pyindex 0c877a4fe7..1893c67d45 100644--- a/rnd/autogpt_server/autogpt_server/data/model.py+++ b/rnd/autogpt_server/autogpt_server/data/model.py@@ -114,13 +114,15 @@ def SchemaField(exclude: bool = False,**kwargs,) -> T:- json_extra: dict[str, Any] = {}- if placeholder:- json_extra["placeholder"] = placeholder- if secret:- json_extra["secret"] = True- if advanced:- json_extra["advanced"] = True+ json_extra = {+ k: v+ for k, v in {+ "placeholder": placeholder,+ "secret": secret,+ "advanced": advanced,+ }.items()+ if v is not None+ }return Field(default,