Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

When using the GPT-4V model in this library, GPT replied, "Sorry, I cannot access external URLs to view images." However, when I use the curl command, GPT can access image links #421

Open
yangleimiao opened this issue Nov 23, 2023 · 3 comments

Comments

@yangleimiao
Copy link

yangleimiao commented Nov 23, 2023

When using the GPT-4V model in this library, GPT replied, "Sorry, I cannot access external URLs to view images." However, when I use the curl command, GPT can access image links.

my curl commend

  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxx" \
  -d '{
    "model":"gpt-4-vision-preview",
    "messages":[
        {
            "role":"user",
            "content":[
                {
                    "type":"text",
                    "text":"What’s in this image?"
                },
                {
                    "type":"image_url",
                    "image_url":{
                        "url":"https://wework.qpic.cn/wwpic/xxxx",
                        "detail":"low"
                    }
                }
            ]
        }
    ],
    "max_tokens":300
}'

and this is my code

String model = "gpt-4-vision-preview";
        List<ChatMessage> messages = new ArrayList<>();
        JSONArray contents = new JSONArray();
        JSONObject textContent = new JSONObject();
        textContent.put("type","text");
        textContent.put("text","What’s in this image?");
        contents.add(textContent);
        JSONObject imageContent = new JSONObject();
        imageContent.put("type","image_url");
        JSONObject url = new JSONObject();
        //url.put("url","https://upload.wikimedia.org/wikipedia/commons/thumb/2/20/John_Everett_Millais_-_%22A_Reverie%22_from_The_Window%3B_or%2C_The_Song_of_the_Wrens.jpg/403px-John_Everett_Millais_-_%22A_Reverie%22_from_The_Window%3B_or%2C_The_Song_of_the_Wrens.jpg");
        url.put("url","https://wework.qpic.cn/wwpic/xxxx");
        url.put("detail","low");
        imageContent.put("image_url",url);
        contents.add(imageContent);
        log.info("contents:{}",contents.toString());
        messages.add(new ChatMessage(ChatMessageRole.USER.value(),contents.toString()));
        log.info("===messages:{}",messages);

and I use ChatCompletionRequest

ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder()
                .model(model)
                .messages(messages)
                .maxTokens(300)
                .n(1)
                .build();

Can anyone help me solve this problem?

@JanCong
Copy link

JanCong commented Nov 27, 2023

The PR #413 will be solved for this.

@yangleimiao
Copy link
Author

The PR #413 will be solved for this.

So, there is no support yet?When I replaced the link in the example with an image from Wikipedia, I was able to successfully obtain a response. I thought I didn't know how to use it.
Thank you so much.

@namankhurpia
Copy link

namankhurpia commented Dec 9, 2023

Hi @yangleimiao

try using this library it has support for Vision - https://github.com/namankhurpia/Easy-open-ai

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants