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 1414 ExtractResult ,
1515)
1616from stagehand .utils import (
17+ convert_dict_keys_to_snake_case ,
1718 inject_urls ,
1819 transform_url_strings_to_ids ,
19- convert_dict_keys_to_snake_case ,
2020)
2121
2222T = TypeVar ("T" , bound = BaseModel )
@@ -151,7 +151,9 @@ async def extract(
151151
152152 processed_data_payload = raw_data_dict # Default to the raw dictionary
153153
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
155157 # Try direct validation first
156158 try :
157159 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(
416416 except Exception as first_error :
417417 # Fallback: normalize keys to snake_case and try once more
418418 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+ )
420422 if not options_obj :
421- validated_model = EmptyExtractSchema .model_validate (normalized )
423+ validated_model = EmptyExtractSchema .model_validate (
424+ normalized
425+ )
422426 else :
423- validated_model = schema_to_validate_with .model_validate (normalized )
427+ validated_model = schema_to_validate_with .model_validate (
428+ normalized
429+ )
424430 processed_data_payload = validated_model
425431 except Exception as second_error :
426432 self ._stagehand .logger .error (
You can’t perform that action at this time.
0 commit comments