datadabllp

prompt an LLM

Jul 19th, 2024
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. def generate_personalized_description(product, customer_data):
  2.     prompt = f"""
  3.    Generate a product description for {product['name']} tailored for a customer with the following attributes:
  4.    - Age: {customer_data['age']}
  5.    - Interests: {', '.join(customer_data['interests'])}
  6.    - Past purchases: {', '.join(customer_data['past_purchases'])}
  7.    - Skill level: {customer_data['skill_level']}
  8.  
  9.    The description should highlight features that would appeal to this specific customer based on their profile.
  10.    """
  11.    
  12.     response = llm.generate(prompt)
  13.     return response.text
  14.  
  15. # Example usage
  16. product = {
  17.     "name": "AlpineX Hiking Boots",
  18.     "features": ["waterproof", "lightweight", "durable"]
  19. }
  20.  
  21. customer = {
  22.     "age": 35,
  23.     "interests": ["hiking", "photography"],
  24.     "past_purchases": ["backpack", "trekking poles"],
  25.     "skill_level": "intermediate"
  26. }
  27.  
  28. personalized_description = generate_personalized_description(product, customer)
  29. print(personalized_description)
  30.  
Advertisement
Add Comment
Please, Sign In to add comment