Skip to content

Commit

Permalink
fix: anthropic pipeline image upload
Browse files Browse the repository at this point in the history
  • Loading branch information
justinh-rahb authored Jun 27, 2024
1 parent 4907bd0 commit 84db93a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/pipelines/providers/anthropic_manifold_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Anthropic Manifold Pipeline
author: justinh-rahb
date: 2024-06-20
version: 1.2
version: 1.3
license: MIT
description: A pipeline for generating text and processing images using the Anthropic API.
requirements: requests, anthropic
Expand Down Expand Up @@ -58,8 +58,8 @@ def pipelines(self) -> List[dict]:
return self.get_anthropic_models()

def process_image(self, image_data):
if image_data["image_url"]["url"].startswith("data:image"):
mime_type, base64_data = image_data["image_url"]["url"].split(",", 1)
if image_data["url"].startswith("data:image"):
mime_type, base64_data = image_data["url"].split(",", 1)
media_type = mime_type.split(":")[1].split(";")[0]
return {
"type": "image",
Expand All @@ -72,7 +72,7 @@ def process_image(self, image_data):
else:
return {
"type": "image",
"source": {"type": "url", "url": image_data["image_url"]["url"]},
"source": {"type": "url", "url": image_data["url"]},
}

def pipe(
Expand All @@ -99,7 +99,7 @@ def pipe(
if image_count >= 5:
raise ValueError("Maximum of 5 images per API call exceeded")

processed_image = self.process_image(item)
processed_image = self.process_image(item["image_url"])
processed_content.append(processed_image)

if processed_image["source"]["type"] == "base64":
Expand Down

0 comments on commit 84db93a

Please sign in to comment.