-
-
Notifications
You must be signed in to change notification settings - Fork 781
Expand file tree
/
Copy pathhandoff_basic.py
More file actions
61 lines (51 loc) · 2.29 KB
/
handoff_basic.py
File metadata and controls
61 lines (51 loc) · 2.29 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
"""
Basic handoff example demonstrating agent-to-agent delegation.
This example shows how agents can hand off tasks to specialized agents.
"""
from praisonaiagents import Agent
# Create specialized agents
billing_agent = Agent(
name="Billing Agent",
role="Billing Specialist",
goal="Handle all billing-related inquiries and tasks",
backstory="I am an expert in billing systems, payment processing, and invoice management."
)
refund_agent = Agent(
name="Refund Agent",
role="Refund Specialist",
goal="Process refund requests and handle refund-related issues",
backstory="I specialize in processing refunds, evaluating refund eligibility, and ensuring customer satisfaction."
)
technical_support_agent = Agent(
name="Technical Support",
role="Technical Support Specialist",
goal="Resolve technical issues and provide technical assistance",
backstory="I am skilled in troubleshooting technical problems and providing solutions."
)
# Create a triage agent with handoffs to specialized agents
triage_agent = Agent(
name="Triage Agent",
role="Customer Service Triage",
goal="Understand customer needs and route them to the appropriate specialist",
backstory="I analyze customer requests and direct them to the most suitable specialist for efficient resolution.",
instructions="""Analyze the customer's request and determine which specialist can best help:
- For billing questions, payment issues, or invoices, transfer to the Billing Agent
- For refund requests or refund status inquiries, transfer to the Refund Agent
- For technical problems or product issues, transfer to Technical Support
Always explain why you're transferring the customer before doing so.""",
handoffs=[billing_agent, refund_agent, technical_support_agent]
)
# Example usage
if __name__ == "__main__":
print("=== Customer Service Triage System ===\n")
# Test different types of requests
test_requests = [
"I need a refund for my last purchase",
"Why was I charged twice on my credit card?",
"The app keeps crashing when I try to login"
]
for request in test_requests:
print(f"\nCustomer: {request}")
response = triage_agent.chat(request)
print(f"Response: {response}")
print("-" * 50)