#I am having an issue with an API call to vision

1 messages · Page 1 of 1 (latest)

outer lotus
#

Basically in the test API call it works if I provide a smapel image howveer it says invalid image type when I provide a dynamic value.

frank smelt
#

Do you have a sample code of your dynamic value?

outer lotus
#

{
"model": "gpt-4-vision-preview",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "You are an app called Document designed to provide assessment information from analyzing images provided by the user. The user will upload an image here and you will provide assessment information based on what you see. Some images could be finished tests, others could be images of visual outcomes such as Montessori materials. First provide the user with information about what you see, then the assessment data."
},
{
"type": "image_url",
"image_url":"<image>"
}
]
}
],
"max_tokens": 300
}

#

with the <image> setting the dynamic value for bubble.io

#

thank you for any help in advance!

#

if I set a placeholder in the value section, it will work fine. I am thinking i could be how the url is formatted when saved in bubble.io but I don;t know

frank smelt
#

Do you happen to know what is the <image> value? I wonder if you are just exceeding the 300 token limit.

outer lotus
#

being dynamic it could be quite long. I can try to increase tokens?

frank smelt
#

Well, before you do that, make sure it is a valid url, if you are getting base64 image representation then the type is wrong for example

outer lotus
#

good point. Ok, trying!

#

this is what the file saves as

#

I don;t think that is valid or maybe too long

frank smelt
#

It is jpeg file type, you might need to have png images that are less than 4MB

#
OpenAI Developer Forum

I am using the create_edit api l like this : response = openai.Image.create_edit( image=open(original, “rb”), mask=open(mask, “rb”), prompt=query, user=user, n=1, response_format = “url”, size=size )but, sometime, the size is not 512 x 512, some time it is 256*345 or any other size, how to define the size ? because I want to make the pi...

outer lotus
#

it is def the formatting of the url.

#

I just can;t figure out other than url shortner API

frank smelt
#
MDN Web Docs

The encodeURI() function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two surrogate characters). Compared to encodeURIComponent(), this function encodes fewer characters, p...

#

However, I don't see any special characters, so I would still say it is jpg vs png

hoary shell
#

Jpg and png are allowed

#

so gpt must not be able to interpret that link that you're generating the image from

frank smelt
#

Yea you are right, it looks like the image format with the new model support these formats up to 20MB files
Please make sure your image is below 20 MB in size and is of one the following formats: ['png', 'jpeg', 'gif', 'webp']

#
    "error": {
        "message": "You uploaded an unsupported image. Please make sure your image is below 20 MB in size and is of one the following formats: ['png', 'jpeg', 'gif', 'webp'].",
        "type": "invalid_request_error",
        "param": null,
        "code": "invalid_image_format"
    }
}```

Funny enough it did work with the image provided by OP
#

{"id": "chatcmpl-xxxxx", "object": "chat.completion", "created": 1699387992, "model": "gpt-4-1106-vision-preview", "usage": {"prompt_tokens": 847, "completion_tokens": 246, "total_tokens": 1093}, "choices": [{"message": {"role": "assistant", "content": "What I see is a shelving unit, likely designed for organizing baby-related items. On the shelves, there are various products and supplies, including:\n\n- Diapers stacked in several of the smaller cubicles.\n- Baby wipes and other containers that likely hold supplies for changing or cleaning a baby.\n- Baby skincare products such as lotion, oil, and possibly shampoo.\n- A couple of other items that may be used during changing time or for storage.\n\nAssessment Information:\n\n- Organization: The items appear to be well-organized, suggesting a system that facilitates easy access and indicates a tidy, efficient environment, which is favorable for taking care of a baby.\n- Inventory Monitoring: The visible stock levels of diapers and wipes are high, which shows good resourcing and preparation for ongoing needs.\n- Product Placement: The placement of different items seems intentional, with frequently used items potentially placed for easier reach, showing effective use of space and consideration of utility.\n- Safety: From this image alone, there don't appear to be any sharp objects or hazardous materials within reach, indicating a child-safe environment on the shelving unit.\n\nThis assessment is based solely on the visual content provided in the image, and further contextual information could refine the assessment."}, "finish_details": {"type": "stop", "stop": "<|fim_suffix|>"}, "index": 0}]}

outer lotus
#

How?

#

Can you walk me through that?

#

Ahhh this is the json prompt

#

trying to understand the exact Json prompt that got you this repsonse.