Skip to content

Commit

Permalink
Fixed up failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanleomk committed Oct 5, 2024
1 parent 6629e8e commit 5ded593
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions instructor/multimodal.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def from_path(cls, path: str | Path) -> Image:
if suffix not in ["jpeg", "jpg", "png"]:
raise ValueError(f"Unsupported image format: {suffix}")

if path.stat().st_size == 0:
raise ValueError("Image file is empty")

media_type = "image/jpeg" if suffix in ["jpeg", "jpg"] else "image/png"
data = base64.b64encode(path.read_bytes()).decode("utf-8")
return cls(source=str(path), media_type=media_type, data=data)
Expand Down
3 changes: 2 additions & 1 deletion instructor/process_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ def handle_response_model(
else:
raise ValueError(f"Invalid patch mode: {mode}")

new_kwargs["messages"] = convert_messages(new_kwargs["messages"], mode)
if "messages" in new_kwargs:
new_kwargs["messages"] = convert_messages(new_kwargs["messages"], mode)

logger.debug(
f"Instructor Request: {mode.value=}, {response_model=}, {new_kwargs=}",
Expand Down

0 comments on commit 5ded593

Please sign in to comment.