-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
add example of how to upload image for GPT4 vision in README.md #249
Comments
Here is an example :
|
is it possibe to upload video for it ? |
@MohammadaliMirhamed Vision does not support video, but what people are doing is splitting up their videos into still frames and uploading that. |
Is there a way to upload the images? A lot of times it cannot read an image from a URL and image has to be uploaded. |
If I understood correctly, you need to upload an image to your server. Then, you can analyze it with GPT Vision |
I have sent https://m.media-amazon.com/images/I/81nUFx9sXoL._AC_UF894,1000_QL80_.jpg to GPT-4-VISION-PREVIEW |
It seems we can directly pass the base64 data to the api instead of url according to the doc here https://platform.openai.com/docs/guides/vision/quick-start. Here is an example:
|
Here I share the PHP version of @aconital: function encodeImage($imagePath): string {
$imageContent = file_get_contents($imagePath);
return base64_encode($imageContent);
}
$imagePath = '/path/to/image.jpg';
$base64Image = encodeImage($imagePath);
$payload = [
'model' => 'gpt-4-vision-preview',
'messages' => [
[
'role' => 'user',
'content' => [
[
'type' => 'text',
'text' => "What’s in this image?"
],
[
'type' => 'image_url',
'image_url' => "data:image/jpeg;base64,$base64Image"
],
],
]
],
'max_tokens' => 200,
];
$result = OpenAI::chat()->create($payload);
echo "<figure style='font-family:sans-serif;width: 500px'>
<img style='width: 100%' src='$imagePath' alt=''>
<figcaption>{$result->choices[0]->message->content}</figcaption>
</figure>"; Result: |
updated payload for php now expecting an object for the
|
First ,thanks for this amazing project.
As GPT-4 vision chat completion endpoint was introduced in v0.7.8,
an update of example in README.md would be great.
The text was updated successfully, but these errors were encountered: