Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dspy/adapters/types/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import mimetypes
import os
import warnings
from functools import lru_cache
from typing import Any, Union
from urllib.parse import urlparse

Expand Down Expand Up @@ -65,6 +66,7 @@ def __init__(self, url: Any = None, *, download: bool = False, **data):
# Delegate the rest of initialization to pydantic's BaseModel.
super().__init__(**data)

@lru_cache(maxsize=32)
def format(self) -> list[dict[str, Any]] | str:
try:
image_url = encode_image(self.url)
Expand Down