Runs the image-to-text conversion using the provided image URL. Args: image_url (str): The URL of the image to convert. Returns: str: The text description of the image.
(self, image_url: str)
| 21 | super().__init__(**llm_config, max_tokens=256) |
| 22 | |
| 23 | def run(self, image_url: str) -> str: |
| 24 | """ |
| 25 | Runs the image-to-text conversion using the provided image URL. |
| 26 | |
| 27 | Args: |
| 28 | image_url (str): The URL of the image to convert. |
| 29 | |
| 30 | Returns: |
| 31 | str: The text description of the image. |
| 32 | """ |
| 33 | message = HumanMessage( |
| 34 | content=[ |
| 35 | {"type": "text", "text": "What is this image showing"}, |
| 36 | { |
| 37 | "type": "image_url", |
| 38 | "image_url": { |
| 39 | "url": image_url, |
| 40 | "detail": "auto", |
| 41 | }, |
| 42 | }, |
| 43 | ] |
| 44 | ) |
| 45 | |
| 46 | result = self.invoke([message]).content |
| 47 | return result |