-
Notifications
You must be signed in to change notification settings - Fork 421
Expand file tree
/
Copy pathcustomer_profile_tools.py
More file actions
106 lines (79 loc) · 3.01 KB
/
Copy pathcustomer_profile_tools.py
File metadata and controls
106 lines (79 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from customer_profiles import CustomerProfileManager
from strands import tool
from typing import Dict, Optional, List
# Initialize the customer profile manager
profile_manager = CustomerProfileManager()
@tool
def get_customer_profile(customer_id: str = None, email: str = None) -> Dict:
"""
Get customer profile information by customer ID or email.
Args:
customer_id (str, optional): The customer ID to lookup
email (str, optional): The customer email to lookup
Returns:
dict: Customer profile information or error message
"""
if not customer_id and not email:
return {"Either customer_id or email must be provided"}
profile = None
if customer_id:
profile = profile_manager.get_profile(customer_id)
elif email:
profile = profile_manager.get_profile_by_email(email)
if not profile:
return {"Customer profile not found"}
return profile.to_dict()
@tool
def list_customer_purchases(customer_id: str = None, email: str = None) -> List[Dict]:
"""
Get a list of customer purchases by customer ID or email.
Args:
customer_id (str, optional): The customer ID to lookup
email (str, optional): The customer email to lookup
Returns:
list: List of customer purchases or error message
"""
if not customer_id and not email:
return {"Either customer_id or email must be provided"}
profile = None
if customer_id:
profile = profile_manager.get_profile(customer_id)
elif email:
profile = profile_manager.get_profile_by_email(email)
if not profile:
return {"Customer profile not found"}
return profile.purchase_history
@tool
def list_customer_tickets(customer_id: str = None, email: str = None) -> List[Dict]:
"""
Get a list of customer support tickets by customer ID or email.
Args:
customer_id (str, optional): The customer ID to lookup
email (str, optional): The customer email to lookup
Returns:
list: List of customer support tickets or error message
"""
if not customer_id and not email:
return {"Either customer_id or email must be provided"}
profile = None
if customer_id:
profile = profile_manager.get_profile(customer_id)
elif email:
profile = profile_manager.get_profile_by_email(email)
if not profile:
return {"Customer profile not found"}
return profile.support_tickets
@tool
def update_customer_profile(customer_id: str, updates: Dict) -> Dict:
"""
Update customer profile information.
Args:
customer_id (str): The customer ID to update
updates (dict): The updates to apply to the profile
Returns:
dict: Updated customer profile or error message
"""
profile = profile_manager.update_profile(customer_id, updates)
if not profile:
return {"Customer profile not found"}
return profile.to_dict()