File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 14
14
ExtractResult ,
15
15
)
16
16
from stagehand .utils import (
17
+ convert_dict_keys_to_snake_case ,
17
18
inject_urls ,
18
19
transform_url_strings_to_ids ,
19
- convert_dict_keys_to_snake_case ,
20
20
)
21
21
22
22
T = TypeVar ("T" , bound = BaseModel )
@@ -151,7 +151,9 @@ async def extract(
151
151
152
152
processed_data_payload = raw_data_dict # Default to the raw dictionary
153
153
154
- if schema and isinstance (raw_data_dict , dict ): # schema is the Pydantic model type
154
+ if schema and isinstance (
155
+ raw_data_dict , dict
156
+ ): # schema is the Pydantic model type
155
157
# Try direct validation first
156
158
try :
157
159
validated_model_instance = schema .model_validate (raw_data_dict )
Original file line number Diff line number Diff line change @@ -416,11 +416,17 @@ async def extract(
416
416
except Exception as first_error :
417
417
# Fallback: normalize keys to snake_case and try once more
418
418
try :
419
- normalized = convert_dict_keys_to_snake_case (processed_data_payload )
419
+ normalized = convert_dict_keys_to_snake_case (
420
+ processed_data_payload
421
+ )
420
422
if not options_obj :
421
- validated_model = EmptyExtractSchema .model_validate (normalized )
423
+ validated_model = EmptyExtractSchema .model_validate (
424
+ normalized
425
+ )
422
426
else :
423
- validated_model = schema_to_validate_with .model_validate (normalized )
427
+ validated_model = schema_to_validate_with .model_validate (
428
+ normalized
429
+ )
424
430
processed_data_payload = validated_model
425
431
except Exception as second_error :
426
432
self ._stagehand .logger .error (
You can’t perform that action at this time.
0 commit comments