If you had a ecommerce store before you probably faced the boring task of adding descriptions to your products. But after the release of OpenAI vision API these tasks can be speed up in many ways. Also, you can use RAG (retrieval augmented generation) to include documents that contain details about your product and give that to chatGPT so we can write a very detailed product description.

In this tutorial will show how to create this automated product description for a Samsung TV.

chatgpt.png

The image says “3 in 1”, “Gaming Hub and +65 free channels”.

Vision API

The first step is to send the image to OpenAI vision API. For simplicity, I will use an image saved in my firebase storage but you can also read the image base64 locally if you want. You also need to provide a prompt for the vision model which in my case I use “The following image is a product that I want to sell online. Please describe the product for me” but you are free to modify that.

from openai import OpenAI
import os

client = OpenAI(
    api_key=os.getenv("OPENAI_API_KEY"),
)

def get_image_description(image_url: str) -> str:
    
    response = client.chat.completions.create(
        model="gpt-4-vision-preview",
        messages=[
            {
            "role": "user",
            "content": [
                {"type": "text", "text": "The following image is a product that I want to sell online. Please describe the product for me"},
                {
                "type": "image_url",
                "image_url": {
                    "url": image_url
                },
                },
            ],
            }
        ],
        max_tokens=300,
    )
    return response.choices[0].message.content

RAG

Here I will do the most naive RAG that exists which is basically inserting the full document content inside the prompt but you can do more sophisticated RAG pipelines using vector databases, embeddings, rerank, and so on. Or you can use the new OpenAI assistant API.

def get_technical_description() -> str:
    with open('description.md', 'r') as f:
        return f.read()

My fake technical description (made by GPT 4).

Display Technology and Resolution:

The Samsung 4K TV typically utilizes a Quantum Dot LED (QLED) display, offering superior color accuracy and brightness compared to conventional LED TVs.

4K resolution (3840 x 2160 pixels) ensures highly detailed and sharp images, with a pixel density that provides a clear and crisp viewing experience even at close distances.

High Dynamic Range (HDR) Support:

Supports various HDR formats like HDR10, HDR10+, and Hybrid Log-Gamma (HLG), enhancing the contrast and color range of the image.

Refresh Rate and Image Processing:

A high refresh rate, often 120Hz, which reduces motion blur and is ideal for fast-paced content such as sports and action movies.

Advanced image processing technologies like Quantum Processor 4K enhance upscaling capabilities, improving lower resolution content to near 4K quality.

Smart TV Features and Operating System:

Runs on Tizen OS, Samsung's proprietary operating system, offering a user-friendly interface and access to a wide range of streaming services and apps.

Integrated voice assistants like Bixby, Google Assistant, and Alexa for hands-free control.

Connectivity:

Multiple HDMI (including eARC/ARC support) and USB ports for connecting external devices like gaming consoles, Blu-ray players, and sound systems.

Wireless connectivity options including Wi-Fi and Bluetooth for seamless integration with wireless soundbars, headphones, and other devices.

Support for Apple AirPlay 2 and screen mirroring.

Audio Capabilities:

Incorporates advanced audio technologies such as Dolby Atmos and object tracking sound, offering an immersive audio experience.

Acoustic Beam Technology, which directs sound to move in sync with the action on the screen.

Design and Build:

Slim and sleek design, often with a minimal bezel, providing an almost edge-to-edge display.

Wall-mountable with compatibility for various mounting standards.

Energy Efficiency and Sustainability:

Energy-efficient components and settings to minimize power consumption.

Use of sustainable and recyclable materials in construction and packaging.

Additional Features:

Adaptive Picture technology to optimize the screen brightness and contrast based on ambient light conditions.

Gaming features like Auto Low Latency Mode (ALLM) and Variable Refresh Rate (VRR) for an enhanced gaming experience.

Remote Control and User Interface:

Comes with a solar-powered remote control, reducing the need for disposable batteries.

Intuitive and customizable user interface, allowing users to arrange and access their favorite content and apps easily.