Add schema validation and default value filling for extraction results (#4063)
Co-authored-by: Suchintan <suchintan@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ from skyvern.core.script_generations.skyvern_page_ai import SkyvernPageAi
|
||||
from skyvern.forge import app
|
||||
from skyvern.forge.prompts import prompt_engine
|
||||
from skyvern.forge.sdk.api.files import validate_download_url
|
||||
from skyvern.forge.sdk.api.llm.schema_validator import validate_and_fill_extraction_result
|
||||
from skyvern.forge.sdk.core import skyvern_context
|
||||
from skyvern.forge.sdk.schemas.totp_codes import OTPType
|
||||
from skyvern.services.otp_service import poll_otp_value
|
||||
@@ -540,6 +541,14 @@ class RealSkyvernPageAi(SkyvernPageAi):
|
||||
screenshots=self.scraped_page.screenshots,
|
||||
prompt_name="extract-information",
|
||||
)
|
||||
|
||||
# Validate and fill missing fields based on schema
|
||||
if schema:
|
||||
result = validate_and_fill_extraction_result(
|
||||
extraction_result=result,
|
||||
schema=schema,
|
||||
)
|
||||
|
||||
if context and context.script_mode:
|
||||
print(f"\n✨ 📊 Extracted Information:\n{'-' * 50}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user