code: from llama_index.multi_modal_llms import GeminiMultiModal
  from llama_index.program import MultiModalLLMCompletionProgram
  from llama_index.output_parsers import PydanticOutputParser
  from llama_index.multi_modal_llms.openai import OpenAIMultiModal
  from pydantic import BaseModel, Field
  from typing_extensions import Annotated
  
  damages_initial_prompt_str = """
  The images are of a damaged {make_name} {model_name} {year} car. 
  The images are taken from different angles.
  Please analyze them and tell me what parts are damaged and what is the estimated cost of repair.
  """
  
  conditions_report_initial_prompt_str = """
  The images are of a damaged vehicle. 
  I need to fill a vehicle condition report based on the picture(s).
  Please fill the following details based on the image(s):
  FRONT
  1. Roof
  2. Windshield
  3. Hood
  4. Grill
  5. Front bumper
  6. Right mirror
  7. Left mirror
  8. Front right light
  9. Front left light
  BACK
  10. Rear Window
  11. Trunk/TGate
  12. Trunk/Cargo area
  13. Rear bumper
  14. Tail lights
  DRIVERS SIDE 
  15. Left fender
  16. Left front door
  17. Left rear door
  18. Left rear quarter panel
  PASSENGER SIDE
  19. Right rear quarter
  20. Right rear door
  21. Right front door
  22. Right fender
  TIRES
  T1. Front left tire
  T2. Front right tire
  T3. Rear left tire
  T4. Rear right tire
  
  For each of the details you must answer with a score based on this descriptions to reflect the condition: 
  
  - 0: Not visible
  - 1: Seems OK (no damage)
  - 2: Minor damage (scratches, dents)
  - 3: Major damage (bent, broken, missing)
  """
  
  
  class DamagedPart(BaseModel):
      """Data model of the damaged part"""
  
      part_name: str = Field(..., description="Name of the damaged part")
      cost: float = Field(..., description="Estimated cost of repair")
  
  
  class DamagedParts(BaseModel):
      """Data model of the damaged parts"""
  
      damaged_parts: list[DamagedPart] = Field(..., description="List of damaged parts")
      summary: str = Field(..., description="Summary of the damage")
  
  
  class ConditionsReport(BaseModel):
      """Data model of conditions report"""
  
      roof: Annotated[int, Field(0, ge=0, le=3, description="Roof condition")]
      windshield: Annotated[int, Field(0, ge=0, le=3, description="Windshield condition")]
      hood: Annotated[int, Field(0, ge=0, le=3, description="Hood condition")]
      grill: Annotated[int, Field(0, ge=0, le=3, description="Grill condition")]
      front_bumper: Annotated[
          int, Field(0, ge=0, le=3, description="Front bumper condition")
      ]
      right_mirror: Annotated[
          int, Field(0, ge=0, le=3, description="Right mirror condition")
      ]
      left_mirror: Annotated[
          int, Field(0, ge=0, le=3, description="Left mirror condition")
      ]
      front_right_light: Annotated[
          int, Field(0, ge=0, le=3, description="Front right light condition")
      ]
      front_left_light: Annotated[
          int, Field(0, ge=0, le=3, description="Front left light condition")
      ]
      # back
      rear_window: Annotated[
          int, Field(0, ge=0, le=3, description="Rear window condition")
      ]
      trunk_tgate: Annotated[
          int, Field(0, ge=0, le=3, description="Trunk/TGate condition")
      ]
      trunk_cargo_area: Annotated[
          int, Field(0, ge=0, le=3, description="Trunk/Cargo area condition")
      ]
      rear_bumper: Annotated[
          int, Field(0, ge=0, le=3, description="Rear bumper condition")
      ]
      right_tail_light: Annotated[
          int, Field(0, ge=0, le=3, description="Right tail light condition")
      ]
      left_tail_light: Annotated[
          int, Field(0, ge=0, le=3, description="Left tail light condition")
      ]
      # left
      left_rear_quarter: Annotated[
          int, Field(0, ge=0, le=3, description="Left rear quarter condition")
      ]
      left_rear_door: Annotated[
          int, Field(0, ge=0, le=3, description="Left rear door condition")
      ]
      left_front_door: Annotated[
          int, Field(0, ge=0, le=3, description="Left front door condition")
      ]
      left_fender: Annotated[
          int, Field(0, ge=0, le=3, description="Left fender condition")
      ]
      left_front_tire: Annotated[
          int, Field(0, ge=0, le=3, description="Left front tire condition")
      ]
      left_rear_tire: Annotated[
          int, Field(0, ge=0, le=3, description="Left rear tire condition")
      ]
      # right
      right_rear_quarter: Annotated[
          int, Field(0, ge=0, le=3, description="Right rear quarter condition")
      ]
      right_rear_door: Annotated[
          int, Field(0, ge=0, le=3, description="Right rear door condition")
      ]
      right_front_door: Annotated[
          int, Field(0, ge=0, le=3, description="Right front door condition")
      ]
      right_fender: Annotated[
          int, Field(0, ge=0, le=3, description="Right fender condition")
      ]
      right_front_tire: Annotated[
          int, Field(0, ge=0, le=3, description="Right front tire condition")
      ]
      right_rear_tire: Annotated[
          int, Field(0, ge=0, le=3, description="Right rear tire condition")
      ]
  
  
  def pydantic_llm(
      output_class, image_documents, prompt_template_str, selected_llm_model
  ):
      openai_mm_llm = OpenAIMultiModal(model="gpt-4-vision-preview")
      gemini_llm = GeminiMultiModal(model_name="models/gemini-pro-vision")
  
      multi_modal_llm = gemini_llm
  
      if selected_llm_model == "OpenAI":
          multi_modal_llm = openai_mm_llm
  
      llm_program = MultiModalLLMCompletionProgram.from_defaults(
          output_parser=PydanticOutputParser(output_class),
          image_documents=image_documents,
          prompt_template_str=prompt_template_str,
          multi_modal_llm=multi_modal_llm,
          verbose=True,
      )
  
      response = llm_program()
      return response
  
apis: llama_index.multi_modal_llms.GeminiMultiModal llama_index.multi_modal_llms.openai.OpenAIMultiModal llama_index.output_parsers.PydanticOutputParser
extract_api: [((1607, 1657), 'pydantic.Field', 'Field', (['...'], {'description': '"""Name of the damaged part"""'}), "(..., description='Name of the damaged part')\n", (1612, 1657), False, 'from pydantic import BaseModel, Field\n'), ((1676, 1726), 'pydantic.Field', 'Field', (['...'], {'description': '"""Estimated cost of repair"""'}), "(..., description='Estimated cost of repair')\n", (1681, 1726), False, 'from pydantic import BaseModel, Field\n'), ((1842, 1889), 'pydantic.Field', 'Field', (['...'], {'description': '"""List of damaged parts"""'}), "(..., description='List of damaged parts')\n", (1847, 1889), False, 'from pydantic import BaseModel, Field\n'), ((1909, 1956), 'pydantic.Field', 'Field', (['...'], {'description': '"""Summary of the damage"""'}), "(..., description='Summary of the damage')\n", (1914, 1956), False, 'from pydantic import BaseModel, Field\n'), ((5072, 5118), 'llama_index.multi_modal_llms.openai.OpenAIMultiModal', 'OpenAIMultiModal', ([], {'model': '"""gpt-4-vision-preview"""'}), "(model='gpt-4-vision-preview')\n", (5088, 5118), False, 'from llama_index.multi_modal_llms.openai import OpenAIMultiModal\n'), ((5136, 5191), 'llama_index.multi_modal_llms.GeminiMultiModal', 'GeminiMultiModal', ([], {'model_name': '"""models/gemini-pro-vision"""'}), "(model_name='models/gemini-pro-vision')\n", (5152, 5191), False, 'from llama_index.multi_modal_llms import GeminiMultiModal\n'), ((2062, 2112), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Roof condition"""'}), "(0, ge=0, le=3, description='Roof condition')\n", (2067, 2112), False, 'from pydantic import BaseModel, Field\n'), ((2145, 2201), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Windshield condition"""'}), "(0, ge=0, le=3, description='Windshield condition')\n", (2150, 2201), False, 'from pydantic import BaseModel, Field\n'), ((2228, 2278), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Hood condition"""'}), "(0, ge=0, le=3, description='Hood condition')\n", (2233, 2278), False, 'from pydantic import BaseModel, Field\n'), ((2306, 2357), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Grill condition"""'}), "(0, ge=0, le=3, description='Grill condition')\n", (2311, 2357), False, 'from pydantic import BaseModel, Field\n'), ((2401, 2459), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Front bumper condition"""'}), "(0, ge=0, le=3, description='Front bumper condition')\n", (2406, 2459), False, 'from pydantic import BaseModel, Field\n'), ((2508, 2566), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Right mirror condition"""'}), "(0, ge=0, le=3, description='Right mirror condition')\n", (2513, 2566), False, 'from pydantic import BaseModel, Field\n'), ((2614, 2671), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Left mirror condition"""'}), "(0, ge=0, le=3, description='Left mirror condition')\n", (2619, 2671), False, 'from pydantic import BaseModel, Field\n'), ((2725, 2788), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Front right light condition"""'}), "(0, ge=0, le=3, description='Front right light condition')\n", (2730, 2788), False, 'from pydantic import BaseModel, Field\n'), ((2841, 2903), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Front left light condition"""'}), "(0, ge=0, le=3, description='Front left light condition')\n", (2846, 2903), False, 'from pydantic import BaseModel, Field\n'), ((2962, 3019), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Rear window condition"""'}), "(0, ge=0, le=3, description='Rear window condition')\n", (2967, 3019), False, 'from pydantic import BaseModel, Field\n'), ((3067, 3124), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Trunk/TGate condition"""'}), "(0, ge=0, le=3, description='Trunk/TGate condition')\n", (3072, 3124), False, 'from pydantic import BaseModel, Field\n'), ((3177, 3239), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Trunk/Cargo area condition"""'}), "(0, ge=0, le=3, description='Trunk/Cargo area condition')\n", (3182, 3239), False, 'from pydantic import BaseModel, Field\n'), ((3287, 3344), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Rear bumper condition"""'}), "(0, ge=0, le=3, description='Rear bumper condition')\n", (3292, 3344), False, 'from pydantic import BaseModel, Field\n'), ((3397, 3459), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Right tail light condition"""'}), "(0, ge=0, le=3, description='Right tail light condition')\n", (3402, 3459), False, 'from pydantic import BaseModel, Field\n'), ((3511, 3572), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Left tail light condition"""'}), "(0, ge=0, le=3, description='Left tail light condition')\n", (3516, 3572), False, 'from pydantic import BaseModel, Field\n'), ((3637, 3700), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Left rear quarter condition"""'}), "(0, ge=0, le=3, description='Left rear quarter condition')\n", (3642, 3700), False, 'from pydantic import BaseModel, Field\n'), ((3751, 3811), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Left rear door condition"""'}), "(0, ge=0, le=3, description='Left rear door condition')\n", (3756, 3811), False, 'from pydantic import BaseModel, Field\n'), ((3863, 3924), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Left front door condition"""'}), "(0, ge=0, le=3, description='Left front door condition')\n", (3868, 3924), False, 'from pydantic import BaseModel, Field\n'), ((3972, 4029), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Left fender condition"""'}), "(0, ge=0, le=3, description='Left fender condition')\n", (3977, 4029), False, 'from pydantic import BaseModel, Field\n'), ((4081, 4142), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Left front tire condition"""'}), "(0, ge=0, le=3, description='Left front tire condition')\n", (4086, 4142), False, 'from pydantic import BaseModel, Field\n'), ((4193, 4253), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Left rear tire condition"""'}), "(0, ge=0, le=3, description='Left rear tire condition')\n", (4198, 4253), False, 'from pydantic import BaseModel, Field\n'), ((4320, 4384), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Right rear quarter condition"""'}), "(0, ge=0, le=3, description='Right rear quarter condition')\n", (4325, 4384), False, 'from pydantic import BaseModel, Field\n'), ((4436, 4497), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Right rear door condition"""'}), "(0, ge=0, le=3, description='Right rear door condition')\n", (4441, 4497), False, 'from pydantic import BaseModel, Field\n'), ((4550, 4612), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Right front door condition"""'}), "(0, ge=0, le=3, description='Right front door condition')\n", (4555, 4612), False, 'from pydantic import BaseModel, Field\n'), ((4661, 4719), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Right fender condition"""'}), "(0, ge=0, le=3, description='Right fender condition')\n", (4666, 4719), False, 'from pydantic import BaseModel, Field\n'), ((4772, 4834), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Right front tire condition"""'}), "(0, ge=0, le=3, description='Right front tire condition')\n", (4777, 4834), False, 'from pydantic import BaseModel, Field\n'), ((4886, 4947), 'pydantic.Field', 'Field', (['(0)'], {'ge': '(0)', 'le': '(3)', 'description': '"""Right rear tire condition"""'}), "(0, ge=0, le=3, description='Right rear tire condition')\n", (4891, 4947), False, 'from pydantic import BaseModel, Field\n'), ((5393, 5427), 'llama_index.output_parsers.PydanticOutputParser', 'PydanticOutputParser', (['output_class'], {}), '(output_class)\n', (5413, 5427), False, 'from llama_index.output_parsers import PydanticOutputParser\n')]