Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File attachment #54

Closed
igormedo opened this issue Jun 21, 2024 · 7 comments
Closed

File attachment #54

igormedo opened this issue Jun 21, 2024 · 7 comments

Comments

@igormedo
Copy link

Is it possible to attach an image or pdf to the query?

@kardolus
Copy link
Owner

It's not possible just yet. I will look into the API and get back to you. Would be a fun feature to add!

@kardolus
Copy link
Owner

I finally had some time and energy to work on the CLI again. However, unfortunately the current API does not support the uploading of images in the chat completion request:

https://platform.openai.com/docs/api-reference/chat/create

When it becomes available I will certainly add it to the CLI.

@vimagick
Copy link

Image URL can be included in message. Maybe it's helpful.

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What'\''s in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
            }
          }
        ]
      }
    ],
    "max_tokens": 300
  }'

@kardolus kardolus reopened this Dec 19, 2024
@kardolus
Copy link
Owner

Thanks! I will take a look

@kardolus kardolus moved this to Todo in LLM Kanban Dec 20, 2024
@kardolus kardolus moved this from Todo to In Progress in LLM Kanban Dec 26, 2024
@kardolus
Copy link
Owner

This actually works :)

curl --location --insecure --request POST 'https://api.openai.com/v1/chat/completions'     --header "Authorization: Bearer ${OPENAI_API_KEY}"     --header 'Content-Type: application/json'     --data-raw '{
       "model": "gpt-4o",
       "messages": [
         {"role": "user", "content": "What is this image"},
         { "role": "user", "content": [
             {
               "type": "image_url",
               "image_url": {
                 "url": "data:image/png;base64,'"$(base64 -i ~/Downloads/wifi2.png)"'"
               }
             }
           ]
         }
       ],
       "stream": false
    }' | jq .

But my default arg size (getconf ARG_MAX) is only 1MB... So that won't work for plenty of images. However, you can pass an URL to 4o models instead. I may just stick to that.

@kardolus
Copy link
Owner

Or I can detect local path vs URL and leave it up to the user to up ARG_MAX? I am not sure just yet.

@kardolus
Copy link
Owner

kardolus commented Jan 1, 2025

Fixed in this commit: 5c6bd63
And released here: https://github.com/kardolus/chatgpt-cli/releases/tag/v1.7.8

@kardolus kardolus closed this as completed Jan 1, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in LLM Kanban Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants