Sổ tay nấu ăn

Bạn có thể sử dụng API của chúng tôi để tạo tiêu đề và nội dung mô tả sản phẩm bằng mọi thông tin sản phẩm mà bạn có. API này chấp nhận:

  • Một từ điển JSON không bắt buộc chứa các thuộc tính sản phẩm của bạn. Ví dụ: {"brand": "MyBrand", "title": "White Tee", "size": "XL"}.
  • Hình ảnh sản phẩm không bắt buộc. Ví dụ: {"uri": "https://my-store.com/img/1.png"}.
  • Các lựa chọn định dạng tiêu đề, ví dụ: attribute_separator, target_language, attribute_order.
  • Ví dụ về việc gắn nhãn dữ liệu. (như bên dưới)

Trước tiên, hãy thiết lập các điều kiện tiên quyết.

import requests
API_KEY=""
API_ENDPOINT=""

Tăng tốc độ tạo sản phẩm bằng cách chỉ cần có một hình ảnh là bạn có thể nhận được tiêu đề được đề xuất.

my_product_image = 'https://cdn.shopify.com/s/files/1/0653/5879/0892/products/1672082339438_550x825.jpg?v=1672082415'

payload = {}
payload |= {'output_spec': {'workflow_id': 'title', 'attribute_separator': '-'}}
payload |= {'product_info':{}}
payload['product_info'] |= {'product_image':{'uri': my_product_image}}

response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
suggested_title = response.json()['title']['text']
print(suggested_title)
Rustic Ceramic & Leather Leaves Necklace

Đẩy nhanh quá trình tạo sản phẩm bằng cách lấy tiêu đề được đề xuất từ nội dung mô tả.

Nếu quy trình tạo sản phẩm của bạn nhắc người dùng cung cấp hình ảnh và nội dung mô tả ngắn, bạn có thể sử dụng mẫu sau để đề xuất tiêu đề sản phẩm cho họ.

my_product_description = 'selling size 12 nike dunks. oh they are red by the way!'

payload = {}
payload |= {'output_spec': {'workflow_id': 'title'}}
payload |= {'product_info':{'product_attributes': {'description': my_product_description}}}

response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
print(response.json()['title']['text'])
Nike Dunks Red Size 12

Tăng tốc độ tạo sản phẩm bằng cách nhận tiêu đề đề xuất từ tiêu đề và nội dung mô tả.

Trong ví dụ này, chúng ta gắn nhãn rõ ràng cho các thuộc tính sản phẩm mà chúng ta muốn AI xác định.

title = 'Volumizing & Lengthening Mascara - Dark Brown'
description = "This high-impact mascara delivers both voluptuous volume and dramatic length without clumping or smudging."

payload = {}
payload |= {'output_spec': {'workflow_id': 'title'}}
payload |= {'product_info':{'product_attributes': {'title': title, 'description': description, 'brand': 'Luxe Beauty'}}}
payload |= {
  "title_examples": [
    {
      "product_info": {
        "title": "Lash Paradise Volumizing & Lengthening Mascara - Waterproof - Blackest Black",
        "colour": "Black"
      },
      "title_format": "product",
      "category": "mascara",
      "final_product_info": {
        "product": "Mascara",
        "brand": "Lash Paradise",
        "mascara_type": "Volumizing & Lengthening",
        "colour": "Blackest Black",
        "waterproof": "Waterproof",
      }
    },
    {
      "product_info": {
        "title": "Hypnose Drama Instant Full Body Volume Mascara - Black",
        "colour": "Black"
      },
      "title_format": "product",
      "category": "mascara",
      "final_product_info": {
        "product": "Mascara",
        "brand": "Hypnose",
        "sub_brand": "Drama",
        "mascara_type": "Full Body Volume",
        "colour": "Black",
        "eye_lash_type": "All lash types"
      }
    }
  ]
}

response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
print(response.json())
{
  "title": {
    "text": "Luxe Beauty Dark Brown Volumizing & Lengthening Mascara"
  },
  "metadata": {
    "metadata": {
      "attributes": {
        "brand": "Luxe Beauty",
        "colour": "Dark Brown",
        "mascara_type": "Volumizing & Lengthening",
        "product": "Mascara"
      },
    }
  }
}

Đẩy nhanh quá trình tạo sản phẩm bằng cách lấy nội dung mô tả được đề xuất từ tiêu đề.

Nếu quy trình tạo sản phẩm nhắc người dùng cung cấp hình ảnh và tiêu đề, bạn có thể sử dụng mẫu sau để đề xuất nội dung mô tả sản phẩm cho họ.

my_product_title = 'Rustic Ceramic & Leather Leaves Necklace'

payload = {}
payload |= {'output_spec': {'workflow_id': 'description'}}
payload |= {'product_info':{'product_attributes': {'title': my_product_title}}}

response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
print(response.json()['description']['text'])
Rustic Ceramic & Leather Leaves Necklace is a beautiful necklace made from high-quality ceramic and leather. It features a unique design that is sure to turn heads.

Tăng tốc quá trình tạo sản phẩm bằng cách lấy cả tiêu đề và nội dung mô tả từ thương hiệu và màu sắc.

Lưu ý cách chúng ta đặt workflow_id thành "tide" trong ví dụ này để lấy cả tiêu đề và nội dung mô tả.

payload = {}
payload |= {'output_spec': {'workflow_id': 'tide'}}
payload |= {'product_info':{'product_attributes': {'brand': 'Mr. Beast', 'color': 'purple'}}}
payload['product_info'] |= {'product_image':{'uri':'https://mrbeast.store/cdn/shop/files/0015dlv_0000_327.jpg?v=1702754475&width=500'}}

response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
print(response.text)
{
  "title": {
    "text": "Pajamas - Mr. Beast | Purple"
  },
  "description": {
    "text": "Slip into the ultimate comfort and style with these Mr. Beast pajamas in a vibrant shade of purple. Crafted from the softest materials, these pajamas will envelop you in a cozy embrace, ensuring a restful night's sleep. The shorts feature a relaxed fit, allowing for easy movement, while the top boasts a classic design with a comfortable neckline. Whether you're lounging at home or drifting off to dreamland, these Mr. Beast pajamas are the perfect choice for a peaceful and stylish slumber."
  },
}

Hỗ trợ ngôn ngữ đích

Trường này chỉ định ngôn ngữ của văn bản mô tả được tạo trong phản hồi API. Tham số này được thêm vào dưới dạng một phần của các tham số output_spec.

{"output_spec": {"target_language": "language"}}

Giá trị mẫu:

"korean" (Korean)
"english" (English)
"spanish" (Spanish)
"french" (French)
"pirate" (Pirate)

Ví dụ về JSON cho tải trọng

title = "Granos de café negro"
description = "Los granos de café negro en California"

payload = {}
payload |= {"output_spec":
  {
    "workflow_id": "description",
    "target_language":"japanese", # specify language here
    "attribute_order": ["scent", "product"],
    "tone":"playful"}
}
payload |= {"product_info":{"product_attributes": {"description": description, "brand": "Parfums de Paris", "scent": "Floral"}}}

Ví dụ về kết quả đầu ra

{
  "description": {
    "text": "カリフォルニアの黒いコーヒー豆は、あなたの鼻をくすぐる、甘く、フローラルな香りです。この香りは、コーヒー豆の豊かな香りと、ジャスミンとバラの繊細な花の香りをブレンドしたものです。カリフォルニアの黒いコーヒー豆は、あなたの家を居心地の良いカフェに変え、あなたをリラックスした気分にさせてくれるでしょう。この香りは、コーヒー好きにも、フローラルな香り好きにも最適です。カリフォルニアの黒いコーヒー豆で、あなたの家を幸せな香りで満たしましょう!"
  }
}

Việc nhập mã ngôn ngữ không chính xác có thể dẫn đến lỗi.

Nếu ngôn ngữ hoặc giá trị không được hỗ trợ, văn bản mô tả sẽ mặc định là tiếng Anh.

Cá nhân hoá giọng điệu để tạo nội dung mô tả

Để giúp xây dựng thương hiệu và phân biệt cửa hàng trực tuyến của bạn với những cửa hàng khác, bạn có thể cá nhân hoá tông giọng của nội dung mô tả được tạo. Text API cung cấp 2 lựa chọn:

Bạn có thể chọn trong danh sách các giọng điệu để tạo nội dung mô tả mới. Danh sách này bao gồm các kiểu giọng điệu sau:

  • Mặc định
  • Vui nhộn
  • Trang trọng
  • Có sức thuyết phục
  • Cuộc trò chuyện

Bạn có thể cung cấp nội dung mô tả hiện có hoặc các thành phần văn bản khác theo giọng điệu của thương hiệu. LLM sẽ phân tích giọng điệu của văn bản và tạo "bộ mô tả phong cách viết" theo những khía cạnh sau:

  • Mức độ trang trọng (ví dụ: trang trọng, suồng sã)
  • Độ chi tiết (ví dụ: ngắn gọn, rất chi tiết)
  • Văn phong (ví dụ: chuyên nghiệp, giàu thông tin, tích cực, thuyết phục)
  • Cấu trúc câu (ví dụ: câu đơn giản có ít liên từ")
  • Những từ và cụm từ được dùng thường xuyên nhất