We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c40a872 commit 4a5558fCopy full SHA for 4a5558f
1 file changed
‎main.py‎
@@ -136,11 +136,17 @@ def generate_vision_with_langchain(img, prompt):
136
"""
137
Generate a image vision result using LangChain with Vertex AI model.
138
139
- # Create a message with both text and image
+ # Convert PIL Image to bytes
140
+ img_byte_arr = BytesIO()
141
+ img.save(img_byte_arr, format=img.format or 'JPEG')
142
+ img_bytes = img_byte_arr.getvalue()
143
+
144
+ # Create a message with both text and image using proper Vertex AI format
145
message = HumanMessage(
146
content=[
147
{"type": "text", "text": prompt},
- {"type": "image_url", "image_url": {"url": img}}
148
+ # Use blob for binary data
149
+ {"type": "image_url", "image_url": {"blob": img_bytes}}
150
]
151
)
152
0 commit comments