code: from typing import Optional
  
  from pydantic import BaseModel, ConfigDict, Field, model_validator
  
  from lancedb.pydantic import LanceModel, Vector
  
  
  class Wine(BaseModel):
      model_config = ConfigDict(
          populate_by_name=True,
          validate_assignment=True,
          extra="allow",
          str_strip_whitespace=True,
          json_schema_extra={
              "example": {
                  "id": 45100,
                  "points": 85,
                  "title": "Balduzzi 2012 Reserva Merlot (Maule Valley)",
                  "description": "Ripe in color and aromas, this chunky wine delivers heavy baked-berry and raisin aromas in front of a jammy, extracted palate. Raisin and cooked berry flavors finish plump, with earthy notes.",
                  "price": 10.0,
                  "variety": "Merlot",
                  "winery": "Balduzzi",
                  "vineyard": "Reserva",
                  "country": "Chile",
                  "province": "Maule Valley",
                  "region_1": "null",
                  "region_2": "null",
                  "taster_name": "Michael Schachner",
                  "taster_twitter_handle": "@wineschach",
              }
          },
      )
  
      id: int
      points: int
      title: str
      description: Optional[str]
      price: Optional[float]
      variety: Optional[str]
      winery: Optional[str]
      vineyard: Optional[str] = Field(..., alias="designation")
      country: Optional[str]
      province: Optional[str]
      region_1: Optional[str]
      region_2: Optional[str]
      taster_name: Optional[str]
      taster_twitter_handle: Optional[str]
  
      @model_validator(mode="before")
      def _fill_country_unknowns(cls, values):
          "Fill in missing country values with 'Unknown', as we always want this field to be queryable"
          country = values.get("country")
          if not country:
              values["country"] = "Unknown"
          return values
  
      @model_validator(mode="before")
      def _add_to_vectorize_fields(cls, values):
          "Add a field to_vectorize that will be used to create sentence embeddings"
          variety = values.get("variety", "")
          title = values.get("title", "")
          description = values.get("description", "")
          to_vectorize = list(filter(None, [variety, title, description]))
          values["to_vectorize"] = " ".join(to_vectorize).strip()
          return values
  
  
  class LanceModelWine(BaseModel):
      """
      Pydantic model for LanceDB, with a vector field added for sentence embeddings
      """
  
      id: int
      points: int
      title: str
      description: Optional[str]
      price: Optional[float]
      variety: Optional[str]
      winery: Optional[str]
      vineyard: Optional[str] = Field(..., alias="designation")
      country: Optional[str]
      province: Optional[str]
      region_1: Optional[str]
      region_2: Optional[str]
      taster_name: Optional[str]
      taster_twitter_handle: Optional[str]
      to_vectorize: str
      vector: Vector(384)
  
  
  class SearchResult(LanceModel):
      "Model to return search results"
  
      model_config = ConfigDict(
          extra="ignore",
          json_schema_extra={
              "example": {
                  "id": 374,
                  "title": "Borgo Conventi 2002 I Fiori del Borgo Sauvignon Blanc (Collio)",
                  "description": "Crisp, green, grassy wine with fresh acidity and herbeceous character. It is very New World with its tropical flavors and open, forward fruit.",
                  "country": "Italy",
                  "variety": "Sauvignon Blanc",
                  "price": 15,
                  "points": 88,
              }
          },
      )
  
      id: int
      title: str
      description: Optional[str]
      country: Optional[str]
      variety: Optional[str]
      price: Optional[float]
      points: Optional[int]
  
apis: lancedb.pydantic.Vector
extract_api: [((189, 894), 'pydantic.ConfigDict', 'ConfigDict', ([], {'populate_by_name': '(True)', 'validate_assignment': '(True)', 'extra': '"""allow"""', 'str_strip_whitespace': '(True)', 'json_schema_extra': "{'example': {'id': 45100, 'points': 85, 'title':\n    'Balduzzi 2012 Reserva Merlot (Maule Valley)', 'description':\n    'Ripe in color and aromas, this chunky wine delivers heavy baked-berry and raisin aromas in front of a jammy, extracted palate. Raisin and cooked berry flavors finish plump, with earthy notes.'\n    , 'price': 10.0, 'variety': 'Merlot', 'winery': 'Balduzzi', 'vineyard':\n    'Reserva', 'country': 'Chile', 'province': 'Maule Valley', 'region_1':\n    'null', 'region_2': 'null', 'taster_name': 'Michael Schachner',\n    'taster_twitter_handle': '@wineschach'}}"}), "(populate_by_name=True, validate_assignment=True, extra='allow',\n    str_strip_whitespace=True, json_schema_extra={'example': {'id': 45100,\n    'points': 85, 'title': 'Balduzzi 2012 Reserva Merlot (Maule Valley)',\n    'description':\n    'Ripe in color and aromas, this chunky wine delivers heavy baked-berry and raisin aromas in front of a jammy, extracted palate. Raisin and cooked berry flavors finish plump, with earthy notes.'\n    , 'price': 10.0, 'variety': 'Merlot', 'winery': 'Balduzzi', 'vineyard':\n    'Reserva', 'country': 'Chile', 'province': 'Maule Valley', 'region_1':\n    'null', 'region_2': 'null', 'taster_name': 'Michael Schachner',\n    'taster_twitter_handle': '@wineschach'}})\n", (199, 894), False, 'from pydantic import BaseModel, ConfigDict, Field, model_validator\n'), ((1355, 1386), 'pydantic.Field', 'Field', (['...'], {'alias': '"""designation"""'}), "(..., alias='designation')\n", (1360, 1386), False, 'from pydantic import BaseModel, ConfigDict, Field, model_validator\n'), ((1576, 1606), 'pydantic.model_validator', 'model_validator', ([], {'mode': '"""before"""'}), "(mode='before')\n", (1591, 1606), False, 'from pydantic import BaseModel, ConfigDict, Field, model_validator\n'), ((1888, 1918), 'pydantic.model_validator', 'model_validator', ([], {'mode': '"""before"""'}), "(mode='before')\n", (1903, 1918), False, 'from pydantic import BaseModel, ConfigDict, Field, model_validator\n'), ((2662, 2693), 'pydantic.Field', 'Field', (['...'], {'alias': '"""designation"""'}), "(..., alias='designation')\n", (2667, 2693), False, 'from pydantic import BaseModel, ConfigDict, Field, model_validator\n'), ((2911, 2922), 'lancedb.pydantic.Vector', 'Vector', (['(384)'], {}), '(384)\n', (2917, 2922), False, 'from lancedb.pydantic import LanceModel, Vector\n'), ((3014, 3422), 'pydantic.ConfigDict', 'ConfigDict', ([], {'extra': '"""ignore"""', 'json_schema_extra': "{'example': {'id': 374, 'title':\n    'Borgo Conventi 2002 I Fiori del Borgo Sauvignon Blanc (Collio)',\n    'description':\n    'Crisp, green, grassy wine with fresh acidity and herbeceous character. It is very New World with its tropical flavors and open, forward fruit.'\n    , 'country': 'Italy', 'variety': 'Sauvignon Blanc', 'price': 15,\n    'points': 88}}"}), "(extra='ignore', json_schema_extra={'example': {'id': 374,\n    'title':\n    'Borgo Conventi 2002 I Fiori del Borgo Sauvignon Blanc (Collio)',\n    'description':\n    'Crisp, green, grassy wine with fresh acidity and herbeceous character. It is very New World with its tropical flavors and open, forward fruit.'\n    , 'country': 'Italy', 'variety': 'Sauvignon Blanc', 'price': 15,\n    'points': 88}})\n", (3024, 3422), False, 'from pydantic import BaseModel, ConfigDict, Field, model_validator\n')]