Hello,
I’m trying to build a very simple program where I send gpt-4-vision-preview a photo of a veryt short text document and ask it to return the transcript. I’m getting <response 400> as an answer when trying with the original jpg file (1.9mb) encoded locally and passed as base64, <response 200> when downsizing to 129kb, and “TypeError: Object of type set is not JSON serializable” when passing the image directly via link. This is what I’m coding below. What am I doing wrong?
image_path = “/Users/myname/Documents/programname/folder1/imagename.jpg”
completion0 = openai.chat.completions.create(
model=“gpt-4-vision-preview”,
messages=[
{
“role”: “user”,
“content”: [
{“type”: “text”, “text”: “Please create a list of all the items on this document, and their associated categories. Output the list only, no accompanying notes or acknowledgements”},
{
“type”: “image_url”,
“image_url”: {
“url”: {image_path},
},
},
],
}
],
max_tokens=300,
)
print(completion0.choices[0].message.content)