-: All right, welcome back.
So in this video, we're gonna have a look
at how you can automate product descriptions
using OpenAI's Vision.
We're gonna have a look at, see,
the kind of package imports
you'll be importing is OpenAI, os,
and then we're gonna use text wrap
to easily see the product descriptions that we get back.
If you don't have an OpenAI API key,
you'll need to insert one here
and then we're gonna load a text_wrapper.
And to start with, we'll use a prompt
to specifically say, Act as a fashion retailer.
You're responsible for writing
effective product descriptions.
We're gonna have a look at this black navy trousers
and see how we can automatically generate
product descriptions for that.
So what we're gonna use is the OpenAI's Vision API,
and you'll see we have to use this gpt-4-vision-preview.
We've also got some interesting things.
So you can see here there's this image_url,
which is the image URL I just showed you.
And we've got our prompt
that's specifically telling the ChatGPT API,
in this case the Vision API,
that we want to get a product description
from this specific image.
Now, after loading the client,
we can then see what kind of product description
we get back.
And you can see it takes around
about maybe four to 10 seconds on average
to use the vision API.
It can take a little bit longer.
As you can see here,
we're clocking in at about 11.6 seconds.
Now, we have got a product description
for this specific pair of navy pants
in the suit section of ASOS.
But in particular,
I'm not particularly happy with this prompt.
And the reason why is it's quite large
in terms of the product description.
So we wanna limit this
to maybe two to four sentences in length.
So we we're gonna do is we're gonna add some examples.
In this case we're not gonna have a product context,
but that could be interesting
if you needed to be more specific.
That could be something you could add into the prompt.
So you'll now see our improved prompt
is acting as a fashion retailer.
We're asking it to use all the images
because ChatGPT vision API
can accept multiple images
and also we've got some examples
which we've specified earlier
that really helped clarify the length and tone.
We've also got a rule section,
so you could add a rule section here
so that the product description
must be between two to four length
in terms of sentences
and also it must be in a professional tone.
We've also said use the following images.
So let's have a look at this.
So this is a single image,
but you'll see that after this comes back
already I've got a cash response here
and here's another one.
The actual product description length is a lot less
and we've still got some good pits
specifically talking here about the cargo trousers.
So this is a different image.
What we are looking at here
is specifically the cargo trousers.
And that can be interesting from our point of view
because what we're trying to do
is get a reduced amount of size.
Now I want to go and take it another step further.
And what I want to do is I want to say
for this product context,
the item is gonna be a cargo trousers in black
and it's not gonna be a hoodie.
And what we are then saying is act as a fashion retailer.
And so same kind of prompt,
we've got our examples in here, we've got our rules.
The product context is now no longer an empty string.
What's interesting about this
is when you look at cargo pants in particular,
you'll see that the cargo pants themselves,
they actually have a top as well, a hoodie top.
And we wanna make sure that ChatGPT
is really not going to talk about the hoodie at all.
And you'll see in this separate model picture,
we really want to talk about these black cargo trousers.
And so that's why you might have a section
like the product context
to say the product description is this cargo trousers,
it's not the hoodie or some type of product title.
And the other interesting thing as well
is notice how we've put both the images
that I just showed you into ChatGPT, vision API.
So you can have multiple images
to really refine those products description outputs.
So let's have a look and see how long this takes.
Probably should take about five to seven seconds.
So again, you've got five seconds
and if we have a look,
it's roughly about the length that we want.
You've got a nice bit here around the leisure wardrobe.
We've got the ultimate blended comforts
and perfect for those on-the-go moments
or relaxing weekends.
So I'm really happy with how this product description
has turned out.
So hopefully this gives you a bit of insight
into how you could use this at e-commerce websites
to automate your product descriptions using ChatGPT, API.