-
Notifications
You must be signed in to change notification settings - Fork 4.7k
gpt-4o-mini finetuned model can not support images #2330
Copy link
Copy link
Closed as not planned
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
When I use gpt-4o-mini finetuned model, returned error.
Error analyzing image: Error code: 500 - {'error': {'message': 'An error occurred while processing your request. You can retry your request, or contact us through our help center at help.openai.com if the error persists. Please include the request ID req_098bbb84c25a864353f8cbbffe69ef5a in your message.', 'type': 'server_error', 'param': None, 'code': 'server_error'}}
To Reproduce
execute codes
Code snippets
import base64
import requests
from openai import OpenAI
from dotenv import load_dotenv
load_dotenv()
client = OpenAI()
def encode_image_from_url(image_url):
try:
response = requests.get(image_url)
response.raise_for_status()
return base64.b64encode(response.content).decode("utf-8")
except Exception as e:
raise Exception(f"Failed to encode image from URL: {str(e)}")
def analyze_image_from_url(image_url, prompt="What's in this image?", max_tokens=300):
try:
base64_image = encode_image_from_url(image_url)
response = client.responses.create(
model="ft:gpt-4o-mini-2024-07-18:tripalink:v32-4omini:B6x9oB85",
input=[
{
"role": "user",
"content": [
{"type": "input_text", "text": prompt},
{
"type": "input_image",
"image_url": f"data:image/jpeg;base64,{base64_image}",
},
],
}
],
)
return response.output_text
except Exception as e:
return f"Error analyzing image: {str(e)}"
def main():
image_url = "https://api.twilio.com/2010-04-01/Accounts/ACdf24798277ad83a58883c54c31851dc1/Messages/MM3910587380118364d38e3c02b0864738/Media/MEfb1d04eb4ff46c5672e8610019816d60"
result = analyze_image_from_url(image_url)
print(result)
if __name__ == "__main__":
main()OS
15.2
Python version
3.11.11
Library version
1.76.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels