datadabllp

tailored recommendations

Jul 19th, 2024
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. def financial_advisor_chatbot(customer_data, conversation_history, user_input):
  2.     prompt = f"""
  3.    You are a financial advisor chatbot for a bank. Use the following customer data and conversation history to provide personalized financial advice:
  4.  
  5.    Customer Data:
  6.    - Income: ${customer_data['income']}
  7.    - Savings: ${customer_data['savings']}
  8.    - Debt: ${customer_data['debt']}
  9.    - Financial Goals: {', '.join(customer_data['financial_goals'])}
  10.  
  11.    Conversation History:
  12.    {conversation_history}
  13.  
  14.    Customer's Latest Question: {user_input}
  15.  
  16.    Provide a personalized response that addresses the customer's question and offers relevant financial advice based on their profile.
  17.    """
  18.    
  19.     response = llm.generate(prompt)
  20.     return response.text
  21.  
  22. # Example usage
  23. customer = {
  24.     "income": 75000,
  25.     "savings": 50000,
  26.     "debt": 20000,
  27.     "financial_goals": ["buy a house", "save for retirement"]
  28. }
  29.  
  30. conversation_history = [
  31.     "Customer: What's the best way to save for a down payment on a house?",
  32.     "Bot: Based on your current savings and income, I'd recommend...",
  33.     "Customer: How much should I be saving each month?",
  34.     "Bot: Considering your goal to buy a house and save for retirement..."
  35. ]
  36.  
  37. user_input = "Should I focus on paying off my debt or saving for a house down payment?"
  38.  
  39. response = financial_advisor_chatbot(customer, conversation_history, user_input)
  40. print(response)
  41.  
Advertisement
Add Comment
Please, Sign In to add comment