#invalid JSON schema with python client

2 messages · Page 1 of 1 (latest)

elfin dagger
#

I have been unable to send a request with a prompt and schema. I get OK results when I write a simplified schema within the prompt, however passing the class itself would be ideal per the documentation.

Code is as follows:

class SecondaryAsset(BaseModel):
    """
    Model for a secondary asset.
    """

    name: str
    url: str
    start_time: Optional[datetime | str]
    end_time: Optional[datetime | str]
    location: Optional[str] = None
    short_description: str = None
    long_description: str

app.extract(
            [source.source_url],
            prompt=selected_prompt, # stored in prompts.py
            schema=SecondaryAsset.model_json_schema(),
        )

The error I get:

Firecrawl extraction failed: Bad Request: Failed to extract. Bad Request - [{'code': 'custom', 'message': 'Invalid JSON schema.', 'path': ['schema']}]
plush raftBOT
#

I already replied over the support ticket, but for the benefit of others, I think you just need to change start_time and end_time to Optional[str] in your Pydantic model.