TextGen / product_description_generation.py
abdullah10's picture
Upload 35 files
8bc7dc5
raw
history blame
1.7 kB
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
def product_description_gen(product_name, product_desc, tone_of_voice, llm):
'''
Description:
This function generates an engaging product description based on user-provided inputs.
It utilizes the LangChain library to prompt an AI model (Language Model) to create a product description tailored to the specified product name, description, tone of voice, and a provided LLM (Long Language Model).
'''
'''
Parameters:
product_name (str) -> Required: The name of the product for which the description is generated.
product_desc (str) -> Required: A brief description of the product.
tone_of_voice (str) -> Required: The intended tone of the product description (e.g., professional, friendly, persuasive).
llm -> Required: The Long Language Model (LLM) used for generating the description.
'''
'''
Return Value:
product_desc (str): The generated Amazon product description.
'''
productDesc_prompt = f"Write an engagging and {tone_of_voice} Amazon product description of {product_name} Product here is a short description of my product:\n\n{product_desc}\n"
productDesc_promptTemp = PromptTemplate(
input_variables=["text_input"],
template="You are a content creator and product description writer who helps clients to write their product description on amazon:\n{text_input}\nAmazon Product Description:")
productDesc_extraction_chain = LLMChain(llm=llm, prompt=productDesc_promptTemp)
product_desc = productDesc_extraction_chain.run(productDesc_prompt)
return product_desc