From a5fb012dc16106aa2f0cda44c4b3850c468e6f73 Mon Sep 17 00:00:00 2001 From: Krzysztof Czerwinski Date: Thu, 12 Feb 2026 15:52:24 +0900 Subject: [PATCH] Address feedback --- .../backend/api/features/builder/db.py | 21 ++++-- .../api/features/store/content_handlers.py | 67 +++++++------------ 2 files changed, 40 insertions(+), 48 deletions(-) diff --git a/autogpt_platform/backend/backend/api/features/builder/db.py b/autogpt_platform/backend/backend/api/features/builder/db.py index c273447ccc..4fef9151a5 100644 --- a/autogpt_platform/backend/backend/api/features/builder/db.py +++ b/autogpt_platform/backend/backend/api/features/builder/db.py @@ -388,7 +388,13 @@ async def _hybrid_search_blocks( Search blocks using hybrid search with builder-specific filtering. Uses unified_hybrid_search for semantic + lexical search, then applies - post-filtering for block/integration types and LLM model bonus scoring. + post-filtering for block/integration types and scoring adjustments. + + Scoring: + - Base: hybrid relevance score (0-1) scaled to 0-100, plus BLOCK_SCORE_BOOST + to prioritize blocks over marketplace agents in combined results + - +30 for exact name match, +15 for prefix name match + - +20 if the block has an LlmModel field and the query matches an LLM model name Args: query: The search query string @@ -604,6 +610,8 @@ async def _get_static_counts(): block: AnyBlockSchema = block_type() if block.disabled: continue + if block.id in EXCLUDED_BLOCK_IDS: + continue all_blocks += 1 @@ -757,8 +765,9 @@ async def get_suggested_blocks(count: int = 5) -> list[BlockInfo]: ) # Get the top blocks based on execution count - # But ignore Input and Output blocks + # But ignore Input, Output, Agent, and excluded blocks blocks: list[tuple[BlockInfo, int]] = [] + execution_counts = {row["block_id"]: row["execution_count"] for row in results} for block_type in load_all_blocks().values(): block: AnyBlockSchema = block_type() @@ -768,11 +777,9 @@ async def get_suggested_blocks(count: int = 5) -> list[BlockInfo]: backend.data.block.BlockType.AGENT, ): continue - # Find the execution count for this block - execution_count = next( - (row["execution_count"] for row in results if row["block_id"] == block.id), - 0, - ) + if block.id in EXCLUDED_BLOCK_IDS: + continue + execution_count = execution_counts.get(block.id, 0) blocks.append((block.get_info(), execution_count)) # Sort blocks by execution count blocks.sort(key=lambda x: x[1], reverse=True) diff --git a/autogpt_platform/backend/backend/api/features/store/content_handlers.py b/autogpt_platform/backend/backend/api/features/store/content_handlers.py index 84fdb4f763..e0e2da4c6c 100644 --- a/autogpt_platform/backend/backend/api/features/store/content_handlers.py +++ b/autogpt_platform/backend/backend/api/features/store/content_handlers.py @@ -183,73 +183,58 @@ class BlockHandler(ContentHandler): ] # Convert to ContentItem + from backend.blocks.llm import LlmModel + items = [] for block_id, block_cls in missing_blocks[:batch_size]: try: block_instance = block_cls() - # Skip disabled blocks - they shouldn't be indexed if block_instance.disabled: continue # Build searchable text from block metadata parts = [] - if hasattr(block_instance, "name") and block_instance.name: + if block_instance.name: parts.append(block_instance.name) - if ( - hasattr(block_instance, "description") - and block_instance.description - ): + if block_instance.description: parts.append(block_instance.description) - if hasattr(block_instance, "categories") and block_instance.categories: - # Convert BlockCategory enum to strings + if block_instance.categories: parts.append( " ".join(str(cat.value) for cat in block_instance.categories) ) - # Add input/output schema info - if hasattr(block_instance, "input_schema"): - schema = block_instance.input_schema - if hasattr(schema, "model_json_schema"): - schema_dict = schema.model_json_schema() - if "properties" in schema_dict: - for prop_name, prop_info in schema_dict[ - "properties" - ].items(): - if "description" in prop_info: - parts.append( - f"{prop_name}: {prop_info['description']}" - ) + # Add input schema field descriptions + schema_dict = block_instance.input_schema.model_json_schema() + if "properties" in schema_dict: + for prop_name, prop_info in schema_dict["properties"].items(): + if "description" in prop_info: + parts.append(f"{prop_name}: {prop_info['description']}") searchable_text = " ".join(parts) - # Convert categories set of enums to list of strings for JSON serialization - categories = getattr(block_instance, "categories", set()) categories_list = ( - [cat.value for cat in categories] if categories else [] + [cat.value for cat in block_instance.categories] + if block_instance.categories + else [] ) # Extract provider names from credentials fields provider_names: list[str] = [] - is_integration = False - if hasattr(block_instance, "input_schema"): - credentials_info = ( - block_instance.input_schema.get_credentials_fields_info() - ) - is_integration = len(credentials_info) > 0 - for info in credentials_info.values(): - for provider in info.provider: - provider_names.append(provider.value.lower()) + credentials_info = ( + block_instance.input_schema.get_credentials_fields_info() + ) + is_integration = len(credentials_info) > 0 + for info in credentials_info.values(): + for provider in info.provider: + provider_names.append(provider.value.lower()) # Check if block has LlmModel field in input schema has_llm_model_field = False - if hasattr(block_instance, "input_schema"): - from backend.blocks.llm import LlmModel - - for field in block_instance.input_schema.model_fields.values(): - if field.annotation == LlmModel: - has_llm_model_field = True - break + for field in block_instance.input_schema.model_fields.values(): + if field.annotation == LlmModel: + has_llm_model_field = True + break items.append( ContentItem( @@ -257,7 +242,7 @@ class BlockHandler(ContentHandler): content_type=ContentType.BLOCK, searchable_text=searchable_text, metadata={ - "name": getattr(block_instance, "name", ""), + "name": block_instance.name, "categories": categories_list, "providers": provider_names, "has_llm_model_field": has_llm_model_field,