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

Request image support #42

Merged
merged 13 commits into from
Oct 25, 2024
Merged

Request image support #42

merged 13 commits into from
Oct 25, 2024

Conversation

sixlive
Copy link
Contributor

@sixlive sixlive commented Oct 23, 2024

Description

Closes #28

This PR adds image sending support for Prism and all first-party providers that support images. To accomplish this there was a pretty heavy refactor to the way messages work. It should be mostly backwards compatible.

Note: not all providers support all types of images, I tried to handle this by throwing an exception when unsupported methods are used.

Usage

Prism::text()
    ->using(Provider::OpenAI, 'gpt-4o')
    ->withMessages([
        new UserMessage(
            'What is this image',
            additionalContent: [
                Image::fromPath(storage_path('logo.png')),
                Image::fromBase64(base64_encode(storage_path('logo.png')), 'image/png'),
                Image::fromUrl('https://storage.echolabs.dev/assets/logo.png'),
            ],
        ),
    ])
    ->generate();

@sixlive sixlive self-assigned this Oct 23, 2024
@sixlive sixlive marked this pull request as ready for review October 24, 2024 20:53
@sixlive sixlive merged commit 12dcbd1 into main Oct 25, 2024
6 checks passed
@sixlive sixlive deleted the request-image-support branch October 25, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sending images with text
1 participant