mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-13 16:25:05 -05:00
I'm getting circular import issues because there is a lot of cross-importing between `backend.data`, `backend.blocks`, and other modules. This change reduces block-related cross-imports and thus risk of breaking circular imports. ### Changes 🏗️ - Strip down `backend.data.block` - Move `Block` base class and related class/enum defs to `backend.blocks._base` - Move `is_block_auth_configured` to `backend.blocks._utils` - Move `get_blocks()`, `get_io_block_ids()` etc. to `backend.blocks` (`__init__.py`) - Update imports everywhere - Remove unused and poorly typed `Block.create()` - Change usages from `block_cls.create()` to `block_cls()` - Improve typing of `load_all_blocks` and `get_blocks` - Move cross-import of `backend.api.features.library.model` from `backend/data/__init__.py` to `backend/data/integrations.py` - Remove deprecated attribute `NodeModel.webhook` - Re-generate OpenAPI spec and fix frontend usage - Eliminate module-level `backend.blocks` import from `blocks/agent.py` - Eliminate module-level `backend.data.execution` and `backend.executor.manager` imports from `blocks/helpers/review.py` - Replace `BlockInput` with `GraphInput` for graph inputs ### 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: - CI static type-checking + tests should be sufficient for this
78 lines
1.8 KiB
Python
78 lines
1.8 KiB
Python
from typing import Literal
|
|
|
|
from pydantic import BaseModel
|
|
|
|
import backend.api.features.library.model as library_model
|
|
import backend.api.features.store.model as store_model
|
|
from backend.blocks._base import BlockInfo
|
|
from backend.integrations.providers import ProviderName
|
|
from backend.util.models import Pagination
|
|
|
|
FilterType = Literal[
|
|
"blocks",
|
|
"integrations",
|
|
"marketplace_agents",
|
|
"my_agents",
|
|
]
|
|
|
|
BlockTypeFilter = Literal["all", "input", "action", "output"]
|
|
|
|
|
|
class SearchEntry(BaseModel):
|
|
search_query: str | None = None
|
|
filter: list[FilterType] | None = None
|
|
by_creator: list[str] | None = None
|
|
search_id: str | None = None
|
|
|
|
|
|
# Suggestions
|
|
class SuggestionsResponse(BaseModel):
|
|
otto_suggestions: list[str]
|
|
recent_searches: list[SearchEntry]
|
|
providers: list[ProviderName]
|
|
top_blocks: list[BlockInfo]
|
|
|
|
|
|
# All blocks
|
|
class BlockCategoryResponse(BaseModel):
|
|
name: str
|
|
total_blocks: int
|
|
blocks: list[BlockInfo]
|
|
|
|
model_config = {"use_enum_values": False} # Use enum names like "AI"
|
|
|
|
|
|
# Input/Action/Output and see all for block categories
|
|
class BlockResponse(BaseModel):
|
|
blocks: list[BlockInfo]
|
|
pagination: Pagination
|
|
|
|
|
|
# Providers
|
|
class Provider(BaseModel):
|
|
name: ProviderName
|
|
description: str
|
|
integration_count: int
|
|
|
|
|
|
class ProviderResponse(BaseModel):
|
|
providers: list[Provider]
|
|
pagination: Pagination
|
|
|
|
|
|
class SearchResponse(BaseModel):
|
|
items: list[BlockInfo | library_model.LibraryAgent | store_model.StoreAgent]
|
|
search_id: str
|
|
total_items: dict[FilterType, int]
|
|
pagination: Pagination
|
|
|
|
|
|
class CountResponse(BaseModel):
|
|
all_blocks: int
|
|
input_blocks: int
|
|
action_blocks: int
|
|
output_blocks: int
|
|
integrations: int
|
|
marketplace_agents: int
|
|
my_agents: int
|