File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 16
16
ObserveOptions ,
17
17
ObserveResult ,
18
18
)
19
- from .types import DefaultExtractSchema
19
+ from .types import DefaultExtractSchema , EmptyExtractSchema
20
20
21
21
_INJECTION_SCRIPT = None
22
22
@@ -361,12 +361,17 @@ async def extract(
361
361
processed_data_payload = result_dict
362
362
if schema_to_validate_with and isinstance (processed_data_payload , dict ):
363
363
try :
364
- validated_model = schema_to_validate_with .model_validate (
365
- processed_data_payload
366
- )
367
- processed_data_payload = (
368
- validated_model # Payload is now the Pydantic model instance
369
- )
364
+ # For extract with no params
365
+ if not options_obj :
366
+ validated_model = EmptyExtractSchema .model_validate (
367
+ processed_data_payload
368
+ )
369
+ processed_data_payload = validated_model
370
+ else :
371
+ validated_model = schema_to_validate_with .model_validate (
372
+ processed_data_payload
373
+ )
374
+ processed_data_payload = validated_model
370
375
except Exception as e :
371
376
self ._stagehand .logger .error (
372
377
f"Failed to validate extracted data against schema { schema_to_validate_with .__name__ } : { e } . Keeping raw data dict in .data field."
You can’t perform that action at this time.
0 commit comments