我們渴望為我們的 API 添加新功能。 我們最新的 API 解決方案是高級產品描述。
有多種方法可以使用 TextCortex API。 交互的核心是“提示”,它向我們的 AI 模型提供關於它應該創建什麼的指令。
使用高級 API 生成產品描述
什麼是高級產品描述 API:
我們的用戶需要一個輸出可靠的工具,並為他們提供所需的服務。 而在過去,我們只使用“產品標題”來生成描述。 我們現在添加了“產品功能”,可以添加這些功能以做出更準確的描述,並為我們的用戶保持高輸入輸出相關性。
每個 API 調用的核心是“提示”,它告訴我們的 AI 模型他們應該寫什麼。 一般來說,更多信息有助於人工智能根據您的需求創建更好、更相關的文本。
如果您已經創建了“提示”,您只需將其與 API 密鑰一起發送到我們的 API 端點。
假設您的產品詳細信息如下:
產品名稱:Gucci Skinny 女士牛仔褲
品牌:古馳
類別:“服裝、鞋履和珠寶”、“女性”
特點:“尺碼:中號”、“顏色:粉色”、“款式:修身款”、“材質:98% 棉、2% 氨綸”
在這種情況下,您需要構建一個如下所示的完整字符串以發送到我們的 API。 完整的提示將是:
產品名稱:'Gucci 緊身女式牛仔褲' 品牌:'Gucci' 類別:['服裝、鞋履和珠寶'、'女士'] 特點:['尺碼:中號'、'顏色:粉色'、'款式:修身版型' , '材料:棉 98%,氨綸 2%'] 產品描述:
# An example about how to build the prompt programatically using python product_name = 'Gucci Skinny women jeans' brand = 'Gucci' features = ['Size: Medium', 'Color: Pink', 'Style:Slim Fit', 'Materials:Cotton 98%, Elastane 2%'] category = ['Clothing, Shoes & Jewelry', 'Women'] prompt = 'Product name: "' + product_name + '" Brand: "' + brand + \ '" Category: ' + str(category) + \ ' Features: ' + str(features) + ' Product Description:' # You can use our python package to directly generate text from textcortex import TextCortex hemingwai = TextCortex(api_key='YOUR_API_KEY') generate_content = hemingwai.generate(prompt=prompt, target_segment='', character_count=1152, source_language='en', creativity=0.7) print(generate_content) ''' Output: [{'generated_text': " This pair of women's jeans from Gucci is perfect for the modern woman who wants to look great while still being comfortable. The classic slim-fit design is made of high quality fabric that feels soft to the touch. The pink color is perfect for any outfit and can be paired with everything from a simple white shirt to a pair of heels.", 'rank': 0.7143, 'text_length': 336, 'word_frequency': [], 'word_count': 62}] '''
方法 1:具有產品特性的請求-響應:
為了實現高輸入輸出相關性
如前所述,保持一般提示結構並將產品信息相應地從您的數據管理系統添加到我們的 API 中非常重要。
在下面的請求-響應示例中,您可以看到在調用的“提示”中有一個定義的功能結構,必須保留並作為字符串發送到我們的 API。
例如,如果您有詳細的產品功能可供使用,您可以發送如下提示:
curl -XPOST -H "Content-type: application/json" -d '{ "prompt": "Product name: 'Gucci Skinny women jeans' Brand: 'Gucci' Category: ['Clothing, Shoes & Jewelry', 'Women'] Features: ['Size: Medium', 'Color: Pink', 'Style:Slim Fit', 'Materials:Cotton 98%, Elastane 2%'] Product Description:", "category": "Product Description", "target_segment": "", "source_language": "auto", "creativity": 0.7, "character_count": 512, "api_key": "YOUR_API_KEY" }' "https://api.textcortex.com/hemingwai/generate_text"
回复

{ "status": "success", "ai_results": [ { "generated_text": " The Gucci jeans are the perfect combination of comfort and style. Made from soft and supple cotton with a slim fit, these women's jeans will ensure you look and feel your best.", "rank": 0.6757, "text_length": 178, "word_frequency": [], "word_count": 32 } ], "error": 200 }
方法 2:使用稀疏數據的請求-響應。 如果您沒有所有產品功能怎麼辦:
如果您沒有足夠的產品數據,您可以只發送“產品標題”來獲取產品描述。
由於人工智能沒有關於產品功能的說明,它可能包括或使用與產品相關的共同特徵。
為了控制和保持高輸入到輸出的相關性,向模型中添加盡可能多的信息。 與人類類似,某人對任務的指導和入職越多,他們的操作就越好、越快。
要求:
curl -XPOST -H "Content-type: application/json" -d '{ "prompt": "Product name: 'Balenciaga Mens Sports Shoes - Black'", "category": "Auto Complete", "target_segment": "", "source_language": "auto", "creativity": 0.7, "character_count": 512, "api_key": "YOUR_API_KEY" }' "https://api.textcortex.com/hemingwai/generate_text"
回复:
{ "status": "success", "ai_results": [ { "generated_text": " The Gucci jeans are the perfect combination of comfort and style. Made from soft and supple cotton with a slim fit, these women's jeans will ensure you look and feel your best.", "rank": 0.6757, "text_length": 178, "word_frequency": [], "word_count": 32 } ], "error": 200 }
而已! 你做到了 :) 如果你想以更簡單的方式以編程方式生成內容,請查看我們的 Python 和 Javascript 包:
TextCortex 文本生成器 Python 包
TextCortex 文本生成器 Javascript 包