Skip to content

Conversation

miguelg719
Copy link
Collaborator

No description provided.

Copy link

linear bot commented Mar 3, 2025

BB-955 Fix snake_case migration on Python

Requests are now snake case, but this is causing an issue in the body for the API request where it expects camelCase.

@miguelg719 miguelg719 marked this pull request as ready for review March 3, 2025 02:30
..., description="Instruction specifying what data to extract using AI."
)
model_name: Optional[AvailableModel] = Field(None, alias="modelName")
model_name: Optional[AvailableModel] = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the model name really optional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes there's a default in config

"""Serialize schema_definition to a JSON schema if it's a Pydantic model"""
if isinstance(schema_definition, type) and issubclass(schema_definition, BaseModel):
return schema_definition.model_json_schema()
return schema_definition
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have a test for it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smoke tested locally w/ example.py:

class News(BaseModel):
    description: str
    url: str

...

  data = await page.extract(ExtractOptions(
      instruction="extract the first result from the search",
      schema_definition=News,
  ))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, confirming it works for me as well!

@filip-michalsky
Copy link
Collaborator

LGTM - just need to test the schema serializer for extract and confirm it works

Copy link
Collaborator

@filip-michalsky filip-michalsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, tested locally with the example as well!

@filip-michalsky
Copy link
Collaborator

feel free to merge this :)

@miguelg719 miguelg719 merged commit 6d456bc into main Mar 4, 2025
@filip-michalsky filip-michalsky deleted the miguel/bb-955-fix-snake_case-migration-on-python branch March 11, 2025 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants