Urgent - need help with Image Analysis Project with GPT-4

Currently working on a project where users capture an image and upon hitting the 'Analyze' button, the image is sent to GPT-4 via an API. it then analyzes the image and returns the analysis results in JSON format.

The images are stored on one of my webserver once the 'Analyze' button is hit. From our webserver, the images are then sent to GPT-4 for analysis.

However, we've noticed that it takes a significant amount of time to receive the analysis results from GPT-4. Additionally, we sometimes encounter a runtime error stating "The operation select list item cannot accept the arguments:, 'not found'], [1]". This error is reported every 5 seconds.

To address these issues, we are exploring alternatives to speed up the response time and eliminate the error message. It could be use of Base64 encoding for the images.

Please help us in this case to improve the efficiency and user experience of our project. Any help would be greatly appreciated. Thank you!

The error is here:

you are assuming that "choices" is a list always...but in some cases, the responseContent has not "choice" so, in the before block you get "not found" which is not a list ...you need to protect all that code, to execute it only when success response and if it contains that tags...and also change this, because "choices" must be a list:

Regarding to the processing time, maybe you can take some ideas from here:
Latency optimization - OpenAI API

starting by reduce the maximum number of tokens...

hey ramon,

instead of using my webserver to store all images then send to gpt api to analyze, what could be some alternative solution? like using base 64'

I tried my best to reduce the number of token, compressed images using php script

Hi Ramon, as I mentioned earlier instead of using my webserver to store all images then send to gpt api to analyze, what could be some alternative solution? like using base 64'

I tried my best to reduce the number of token, compressed images using php script

I really need your help in this matter

Like I've said above, If the problem is the time response from GTP-4 then try to reduce that time....reducing the maximum items, or applying other recommendations...in you aia you take a photo and then sent it to openai...I don't know what are you referring with your webserver and with store all the images....

when it comes to the webserver, after user capture an image, i am storing all of those images in one of my webserver, from there i have created an api endpoint which send the image url joning with one of my domain name to the chatgpt

then i get the response

And what problem/doubt do you want to solve in this topic regarding your AI2 application?

to reduce the latency by implementing an alternative solution

but, if I have not understood you wrong, the latency problem is between your web server and chatGPT... I can't help you with that.

now I got it.

I would like to ask another question if possible,

Imagine you have captured an image and want to add additional information in a text box before initiating the analysis button. How can you utilize the text entered in the textbox as a prompt for the image analysis as well ?

Would you mind helping me out to achieve this Ramon? It will be huge helpful

Imagine you have captured an image and want to add additional information in a text box before initiating the analysis button. How can you utilize the text entered in the textbox as a prompt for the image analysis as well ?

Sorry, but I don't knor the api of gpt enough to be able to help you with this topic. I don't know if you can add that text like Context or similar in the request.

It's okay. I will figure out to achieve this-