dspy icon indicating copy to clipboard operation
dspy copied to clipboard

Add GPT-4 Vision API wrapper

Open jmanhype opened this issue 1 year ago • 16 comments

Introduce a new GPT4Vision class in visionopenai.py that wraps the GPT-4 Vision API. This abstraction layer simplifies the process of making requests to the API for analyzing images. Key functionality includes:

Encoding images to base64 Preparing image metadata in the required format Calculating token costs for images Making API requests with both text and image prompts Error handling and validation

jmanhype avatar Mar 20 '24 03:03 jmanhype

Also is there any way to add tests for this?

isaacbmiller avatar Mar 20 '24 20:03 isaacbmiller

Also is there any way to add tests for this?

I have a unittest created.

jmanhype avatar Mar 21 '24 19:03 jmanhype

I have a unittest created.

Where?

isaacbmiller avatar Mar 22 '24 03:03 isaacbmiller

Adding GPT-4 Vision capabilties would be super useful! Any progress with fixing the failing check here? 🙂

landworth avatar Mar 29 '24 14:03 landworth

Did you try whether this really works or not?

What does the Signature look like to pass an image?

nqyy avatar Mar 30 '24 22:03 nqyy

Thanks @jmanhype for the contribution! Could you resolve https://github.com/stanfordnlp/dspy/pull/682#pullrequestreview-1950064068?

Also, it would be great if you add documentation for this under the documentation folder as with the other LMs. Thanks!

arnavsinghvi11 avatar Apr 01 '24 18:04 arnavsinghvi11

I just made those updates

jmanhype avatar Apr 04 '24 14:04 jmanhype

@jmanhype

Also run "ruff check . --fix-only"

add documentation for this under the documentation folder as with the other LMs. Thanks!

arnavsinghvi11 avatar Apr 04 '24 22:04 arnavsinghvi11

Done

jmanhype avatar Apr 05 '24 00:04 jmanhype

@jmanhype did you push? don't see new commits.

arnavsinghvi11 avatar Apr 05 '24 04:04 arnavsinghvi11

ok everything has been updated

jmanhype avatar Apr 09 '24 02:04 jmanhype

Hi @jmanhype still needs ruff check . --fix-only to be run.

Also, to properly call dspy.GPT4Vision, you need to import it as the other LM modules:

arnavsinghvi11 avatar Apr 09 '24 04:04 arnavsinghvi11

Ruff check is false positive it passes locally

jmanhype avatar May 18 '24 14:05 jmanhype

@arnavsinghvi11 Is there any update on this? cc : @jmanhype

AyushPibit1234 avatar Jul 23 '24 11:07 AyushPibit1234

Just needs to be merged the ruff error is a false positive

jmanhype avatar Jul 23 '24 15:07 jmanhype

Hey @jmanhype I did actually find a ruff error and I added GPT4Vision to the init files in dsp and dspy like @arnavsinghvi11 mentioned.

See this branch: https://github.com/stanfordnlp/dspy/tree/jmanhype/main

isaacbmiller avatar Jul 24 '24 04:07 isaacbmiller