You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importbase64importrequests# OpenAI API Keyapi_key="****"# Function to encode the imagedefencode_image(image_path):
withopen(image_path, "rb") asimage_file:
returnbase64.b64encode(image_file.read()).decode('utf-8')
# Path to your imageimage_path="00000000_img_front.png"# Getting the base64 stringbase64_image=encode_image(image_path)
headers= {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
payload= {
"model": "gpt-4-vision-preview",
"messages": [
{
"role": "user",
"content":
[
{
"type": "text",
"text": "What’s in this image?"
},
{
"type": "image_url",
"image_url": {
"url": f"data:image/jpeg;base64,{base64_image}"
}
}
]
}
],
"max_tokens": 300
}
response=requests.post("http://0.0.0.0:7999/v1/chat/completions", headers=headers, json=payload)
print(response.json())
Thanks for the great work, I have successfully deployed Chat-to-api.
But it seems to encounter bugs when call Chat-to-api by the image input mode.
Response is "{'code': '500', 'msg': 'invalid type: sequence, expected a string at line 1 column 75'}"
Could that be supported?
The text was updated successfully, but these errors were encountered:
Thanks for the great work, I have successfully deployed Chat-to-api.
But it seems to encounter bugs when call Chat-to-api by the image input mode.
Response is "{'code': '500', 'msg': 'invalid type: sequence, expected a string at line 1 column 75'}"
Could that be supported?
The text was updated successfully, but these errors were encountered: