mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-09 22:35:54 -05:00
## Block Development SDK - Simplifying Block Creation ### Problem Currently, creating a new block requires manual updates to **5+ files** scattered across the codebase: - `backend/data/block_cost_config.py` - Manually add block costs - `backend/integrations/credentials_store.py` - Add default credentials - `backend/integrations/providers.py` - Register new providers - `backend/integrations/oauth/__init__.py` - Register OAuth handlers - `backend/integrations/webhooks/__init__.py` - Register webhook managers This creates significant friction for developers, increases the chance of configuration errors, and makes the platform difficult to scale. ### Solution This PR introduces a **Block Development SDK** that provides: - Single import for all block development needs: `from backend.sdk import *` - Automatic registration of all block configurations - Zero external file modifications required - Provider-based configuration with inheritance ### Changes 🏗️ #### 1. **New SDK Module** (`backend/sdk/`) - **`__init__.py`**: Unified exports of 68+ block development components - **`registry.py`**: Central auto-registration system for all block configurations - **`builder.py`**: `ProviderBuilder` class for fluent provider configuration - **`provider.py`**: Provider configuration management - **`cost_integration.py`**: Automatic cost application system #### 2. **Provider Builder Pattern** ```python # Configure once, use everywhere my_provider = ( ProviderBuilder("my-service") .with_api_key("MY_SERVICE_API_KEY", "My Service API Key") .with_base_cost(5, BlockCostType.RUN) .build() ) ``` #### 3. **Automatic Cost System** - Provider base costs automatically applied to all blocks using that provider - Override with `@cost` decorator for block-specific pricing - Tiered pricing support with cost filters #### 4. **Dynamic Provider Support** - Modified `ProviderName` enum to accept any string via `_missing_` method - No more manual enum updates for new providers #### 5. **Application Integration** - Added `sync_all_provider_costs()` to `initialize_blocks()` for automatic cost registration - Maintains full backward compatibility with existing blocks #### 6. **Comprehensive Examples** (`backend/blocks/examples/`) - `simple_example_block.py` - Basic block structure - `example_sdk_block.py` - Provider with credentials - `cost_example_block.py` - Various cost patterns - `advanced_provider_example.py` - Custom API clients - `example_webhook_sdk_block.py` - Webhook configuration #### 7. **Extensive Testing** - 6 new test modules with 30+ test cases - Integration tests for all SDK features - Cost calculation verification - Provider registration tests ### Before vs After **Before SDK:** ```python # 1. Multiple complex imports from backend.data.block import Block, BlockCategory, BlockOutput from backend.data.model import SchemaField, CredentialsField # ... many more imports # 2. Update block_cost_config.py BLOCK_COSTS[MyBlock] = [BlockCost(...)] # 3. Update credentials_store.py DEFAULT_CREDENTIALS.append(...) # 4. Update providers.py enum # 5. Update oauth/__init__.py # 6. Update webhooks/__init__.py ``` **After SDK:** ```python from backend.sdk import * # Everything configured in one place my_provider = ( ProviderBuilder("my-service") .with_api_key("MY_API_KEY", "My API Key") .with_base_cost(10, BlockCostType.RUN) .build() ) class MyBlock(Block): class Input(BlockSchema): credentials: CredentialsMetaInput = my_provider.credentials_field() data: String = SchemaField(description="Input data") class Output(BlockSchema): result: String = SchemaField(description="Result") # That's it\! No external files to modify ``` ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Created new blocks using SDK pattern with provider configuration - [x] Verified automatic cost registration for provider-based blocks - [x] Tested cost override with @cost decorator - [x] Confirmed custom providers work without enum modifications - [x] Verified all example blocks execute correctly - [x] Tested backward compatibility with existing blocks - [x] Ran all SDK tests (30+ tests, all passing) - [x] Created blocks with credentials and verified authentication - [x] Tested webhook block configuration - [x] Verified application startup with auto-registration #### For configuration changes: - [x] `.env.example` is updated or already compatible with my changes (no changes needed) - [x] `docker-compose.yml` is updated or already compatible with my changes (no changes needed) - [x] I have included a list of my configuration changes in the PR description (under **Changes**) ### Impact - **Developer Experience**: Block creation time reduced from hours to minutes - **Maintainability**: All block configuration in one place - **Scalability**: Support hundreds of blocks without enum updates - **Type Safety**: Full IDE support with proper type hints - **Testing**: Easier to test blocks in isolation --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Abhimanyu Yadav <122007096+Abhi1992002@users.noreply.github.com>
127 lines
3.1 KiB
TOML
127 lines
3.1 KiB
TOML
[tool.poetry]
|
|
name = "autogpt-platform-backend"
|
|
version = "0.4.9"
|
|
description = "A platform for building AI-powered agentic workflows"
|
|
authors = ["AutoGPT <info@agpt.co>"]
|
|
readme = "README.md"
|
|
packages = [{ include = "backend", format = "sdist" }]
|
|
|
|
|
|
[tool.poetry.dependencies]
|
|
python = ">=3.10,<3.13"
|
|
aio-pika = "^9.5.5"
|
|
aiodns = "^3.5.0"
|
|
anthropic = "^0.57.1"
|
|
apscheduler = "^3.11.0"
|
|
autogpt-libs = { path = "../autogpt_libs", develop = true }
|
|
bleach = { extras = ["css"], version = "^6.2.0" }
|
|
click = "^8.2.0"
|
|
cryptography = "^43.0"
|
|
discord-py = "^2.5.2"
|
|
e2b-code-interpreter = "^1.5.2"
|
|
fastapi = "^0.115.14"
|
|
feedparser = "^6.0.11"
|
|
flake8 = "^7.3.0"
|
|
google-api-python-client = "^2.176.0"
|
|
google-auth-oauthlib = "^1.2.2"
|
|
google-cloud-storage = "^3.2.0"
|
|
googlemaps = "^4.10.0"
|
|
gravitasml = "^0.1.3"
|
|
groq = "^0.29.0"
|
|
jinja2 = "^3.1.6"
|
|
jsonref = "^1.1.0"
|
|
jsonschema = "^4.22.0"
|
|
launchdarkly-server-sdk = "^9.11.0"
|
|
mem0ai = "^0.1.114"
|
|
moviepy = "^2.1.2"
|
|
ollama = "^0.5.1"
|
|
openai = "^1.93.2"
|
|
pika = "^1.3.2"
|
|
pinecone = "^5.3.1"
|
|
poetry = "2.1.1" # CHECK DEPENDABOT SUPPORT BEFORE UPGRADING
|
|
postmarker = "^1.0"
|
|
praw = "~7.8.1"
|
|
prisma = "^0.15.0"
|
|
prometheus-client = "^0.22.1"
|
|
psutil = "^7.0.0"
|
|
psycopg2-binary = "^2.9.10"
|
|
pydantic = { extras = ["email"], version = "^2.11.7" }
|
|
pydantic-settings = "^2.10.1"
|
|
pytest = "^8.4.1"
|
|
pytest-asyncio = "^0.26.0"
|
|
python-dotenv = "^1.1.1"
|
|
python-multipart = "^0.0.20"
|
|
redis = "^5.2.0"
|
|
replicate = "^1.0.6"
|
|
sentry-sdk = {extras = ["anthropic", "fastapi", "launchdarkly", "openai", "sqlalchemy"], version = "^2.32.0"}
|
|
sqlalchemy = "^2.0.40"
|
|
strenum = "^0.4.9"
|
|
stripe = "^11.5.0"
|
|
supabase = "2.16.0"
|
|
tenacity = "^9.1.2"
|
|
todoist-api-python = "^2.1.7"
|
|
tweepy = "^4.16.0"
|
|
uvicorn = { extras = ["standard"], version = "^0.34.2" }
|
|
websockets = "^14.2"
|
|
youtube-transcript-api = "^0.6.2"
|
|
zerobouncesdk = "^1.1.2"
|
|
# NOTE: please insert new dependencies in their alphabetical location
|
|
pytest-snapshot = "^0.9.0"
|
|
aiofiles = "^24.1.0"
|
|
tiktoken = "^0.9.0"
|
|
aioclamd = "^1.0.0"
|
|
setuptools = "^80.9.0"
|
|
|
|
[tool.poetry.group.dev.dependencies]
|
|
aiohappyeyeballs = "^2.6.1"
|
|
black = "^24.10.0"
|
|
faker = "^33.3.1"
|
|
httpx = "^0.28.1"
|
|
isort = "^5.13.2"
|
|
poethepoet = "^0.36.0"
|
|
pyright = "^1.1.402"
|
|
pytest-mock = "^3.14.0"
|
|
pytest-watcher = "^0.4.2"
|
|
requests = "^2.32.4"
|
|
ruff = "^0.12.2"
|
|
# NOTE: please insert new dependencies in their alphabetical location
|
|
|
|
[build-system]
|
|
requires = ["poetry-core"]
|
|
build-backend = "poetry.core.masonry.api"
|
|
|
|
[tool.poetry.scripts]
|
|
app = "backend.app:main"
|
|
rest = "backend.rest:main"
|
|
ws = "backend.ws:main"
|
|
scheduler = "backend.scheduler:main"
|
|
executor = "backend.exec:main"
|
|
cli = "backend.cli:main"
|
|
format = "linter:format"
|
|
lint = "linter:lint"
|
|
test = "run_tests:test"
|
|
|
|
[tool.isort]
|
|
profile = "black"
|
|
|
|
[tool.pytest-watcher]
|
|
now = false
|
|
clear = true
|
|
delay = 0.2
|
|
runner = "pytest"
|
|
runner_args = []
|
|
patterns = ["*.py"]
|
|
ignore_patterns = []
|
|
|
|
[tool.pytest.ini_options]
|
|
asyncio_mode = "auto"
|
|
asyncio_default_fixture_loop_scope = "session"
|
|
filterwarnings = [
|
|
"ignore:'audioop' is deprecated:DeprecationWarning:discord.player",
|
|
"ignore:invalid escape sequence:DeprecationWarning:tweepy.api",
|
|
]
|
|
|
|
[tool.ruff]
|
|
target-version = "py310"
|
|
|