mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-03-17 03:00:27 -04:00
fix(backend/store): remove camelcase truncation limit and add edge case tests
This commit is contained in:
@@ -177,6 +177,9 @@ def _get_enabled_blocks() -> types.MappingProxyType[str, Block[Any, Any]]:
|
||||
and their set never changes while the process is running. The returned
|
||||
mapping is wrapped in ``MappingProxyType`` so callers cannot accidentally
|
||||
mutate the cached data.
|
||||
|
||||
The cached block instances are lightweight singletons (no heavy resources
|
||||
or open connections), so pinning them for the process lifetime is fine.
|
||||
"""
|
||||
enabled: dict[str, Block[Any, Any]] = {}
|
||||
for block_id, block_cls in get_blocks().items():
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
"""Small text helpers shared across store search modules."""
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_MAX_CAMELCASE_INPUT_LEN = 500
|
||||
|
||||
|
||||
def split_camelcase(text: str) -> str:
|
||||
"""Split CamelCase into separate words.
|
||||
@@ -30,13 +24,6 @@ def split_camelcase(text: str) -> str:
|
||||
>>> split_camelcase("OAuth2Block")
|
||||
'OAuth2 Block'
|
||||
"""
|
||||
if len(text) > _MAX_CAMELCASE_INPUT_LEN:
|
||||
logger.debug(
|
||||
"split_camelcase: truncating input from %d to %d chars",
|
||||
len(text),
|
||||
_MAX_CAMELCASE_INPUT_LEN,
|
||||
)
|
||||
text = text[:_MAX_CAMELCASE_INPUT_LEN]
|
||||
if len(text) <= 1:
|
||||
return text
|
||||
|
||||
|
||||
@@ -27,6 +27,16 @@ from backend.api.features.store.text_utils import split_camelcase
|
||||
# "ABlock" stays "ABlock" because the algorithm requires the left
|
||||
# part of an uppercase run to retain at least 2 uppercase chars.
|
||||
("ABlock", "ABlock"),
|
||||
# Digit-to-uppercase transitions
|
||||
("Base64Encoder", "Base64 Encoder"),
|
||||
("UTF8Decoder", "UTF8 Decoder"),
|
||||
# Pure digits — no camelCase boundaries to split
|
||||
("123", "123"),
|
||||
# Known limitation: single-letter uppercase segments after digits
|
||||
# are not split from the following word. "3D" is only 1 uppercase
|
||||
# char so the uppercase-run rule cannot fire, producing "3 DRenderer"
|
||||
# rather than the ideal "3D Renderer".
|
||||
("3DRenderer", "3 DRenderer"),
|
||||
],
|
||||
)
|
||||
def test_split_camelcase(input_text: str, expected: str):
|
||||
|
||||
Reference in New Issue
Block a user