mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-17 02:03:00 -05:00
Compare commits
3 Commits
fix/execut
...
codex/inve
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0a32131d4 | ||
|
|
cdb1f50561 | ||
|
|
e9a3ba36ab |
@@ -1,8 +1,47 @@
|
|||||||
from typing import Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from backend.sdk import BaseModel, SchemaField
|
from backend.sdk import BaseModel, SchemaField
|
||||||
|
|
||||||
|
|
||||||
|
def _to_camel_case(value: str) -> str:
|
||||||
|
"""Convert snake_case string to camelCase.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
value: Snake case string to convert
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
String converted to camelCase format
|
||||||
|
"""
|
||||||
|
parts = value.split("_")
|
||||||
|
return parts[0] + "".join(part.capitalize() for part in parts[1:])
|
||||||
|
|
||||||
|
|
||||||
|
def to_camel_case_dict(data: dict[str, Any]) -> dict[str, Any]:
|
||||||
|
"""Recursively convert dictionary keys from snake_case to camelCase.
|
||||||
|
|
||||||
|
Handles nested dictionaries and lists containing dictionaries by recursively
|
||||||
|
converting all snake_case keys to camelCase format.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data: Dictionary with snake_case keys to convert
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dictionary with all keys converted to camelCase
|
||||||
|
"""
|
||||||
|
result: dict[str, Any] = {}
|
||||||
|
for key, val in data.items():
|
||||||
|
camel_key = _to_camel_case(key)
|
||||||
|
if isinstance(val, dict):
|
||||||
|
result[camel_key] = to_camel_case_dict(val)
|
||||||
|
elif isinstance(val, list):
|
||||||
|
result[camel_key] = [
|
||||||
|
to_camel_case_dict(v) if isinstance(v, dict) else v for v in val
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
result[camel_key] = val
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class TextSettings(BaseModel):
|
class TextSettings(BaseModel):
|
||||||
max_characters: int = SchemaField(
|
max_characters: int = SchemaField(
|
||||||
default=1000,
|
default=1000,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from backend.sdk import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from ._config import exa
|
from ._config import exa
|
||||||
from .helpers import ContentSettings
|
from .helpers import ContentSettings, to_camel_case_dict
|
||||||
|
|
||||||
|
|
||||||
class ExaSearchBlock(Block):
|
class ExaSearchBlock(Block):
|
||||||
@@ -93,7 +93,7 @@ class ExaSearchBlock(Block):
|
|||||||
"query": input_data.query,
|
"query": input_data.query,
|
||||||
"useAutoprompt": input_data.use_auto_prompt,
|
"useAutoprompt": input_data.use_auto_prompt,
|
||||||
"numResults": input_data.number_of_results,
|
"numResults": input_data.number_of_results,
|
||||||
"contents": input_data.contents.model_dump(),
|
"contents": to_camel_case_dict(input_data.contents.model_dump()),
|
||||||
}
|
}
|
||||||
|
|
||||||
date_field_mapping = {
|
date_field_mapping = {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from backend.sdk import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from ._config import exa
|
from ._config import exa
|
||||||
from .helpers import ContentSettings
|
from .helpers import ContentSettings, to_camel_case_dict
|
||||||
|
|
||||||
|
|
||||||
class ExaFindSimilarBlock(Block):
|
class ExaFindSimilarBlock(Block):
|
||||||
@@ -95,7 +95,7 @@ class ExaFindSimilarBlock(Block):
|
|||||||
payload = {
|
payload = {
|
||||||
"url": input_data.url,
|
"url": input_data.url,
|
||||||
"numResults": input_data.number_of_results,
|
"numResults": input_data.number_of_results,
|
||||||
"contents": input_data.contents.model_dump(),
|
"contents": to_camel_case_dict(input_data.contents.model_dump()),
|
||||||
}
|
}
|
||||||
|
|
||||||
optional_field_mapping = {
|
optional_field_mapping = {
|
||||||
|
|||||||
Reference in New Issue
Block a user