cbh123 / narrator

David Attenborough narrates your life
4.38k stars 535 forks source link

"expected an object, but got a string instead" #57

Open generalpublic opened 3 months ago

generalpublic commented 3 months ago

when running narrator.py, the error message below comes up.

openai.NotFoundError: Error code: 404 - {'error': {'message': 'The model gpt-4-vision-preview has been deprecated, learn more here: https://platform.openai.com/docs/deprecations', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}

looking at https://platform.openai.com/docs/deprecations, it shows that 'gpt-4-vision-preview's recommended replacement is 'gpt-4o'

When I replace the above in narrator.py line 58 with 'gpt-4o', the new error message I get is

openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid type for 'messages[1].content[1].image_url': expected an object, but got a string instead.", 'type': 'invalid_request_error', 'param': 'messages[1].content[1].image_url', 'code': 'invalid_type'}}

Anyone know a fix for this?

nacalai commented 1 month ago

I came to the same stop like you, but I managed to find the solution.

The code for generating the image seems to be wrong.

Open narrator.py -> find this part image

Replace with

def generate_new_line(base64_image):
    return [
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Describe this image"},
                {
                    "type": "image_url",
            "image_url": {
            "url": f"data:image/jpeg;base64,{base64_image}",
            }
                },
            ],
        },
    ]