-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (46 loc) · 1.74 KB
/
main.py
File metadata and controls
59 lines (46 loc) · 1.74 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
import asyncio
import os
from dotenv import load_dotenv
import braintrust
from src.agent import WhileLoopAgent, AgentOptions
from src.tools import get_all_tools
# Load environment variables
load_dotenv()
async def main():
"""Run the customer service agent demo."""
# Initialize Braintrust logger with experiment name
logger = braintrust.init(
project="canonical-agent-customer-service",
experiment="interactive-queries"
)
agent = WhileLoopAgent(
AgentOptions(
model="gpt-4o-mini",
system_prompt="""You are a helpful customer service agent. You can:
1. Search for users by name, email, or subscription details
2. Get detailed information about specific users
3. Send email notifications to customers
4. Update subscription plans and statuses
Always be polite and helpful. When you need more information, ask clarifying questions.
When you complete an action, summarize what you did for the customer.""",
tools=get_all_tools(),
max_iterations=10,
openai_api_key=os.getenv("BRAINTRUST_API_KEY"),
)
)
queries = [
"Find all premium users with expired subscriptions",
"Get details for john@co.com and send them a renewal reminder",
"Cancel the subscription for jane@co.com",
"Search for users with basic plans",
"Find all premium users with active subscriptions and send them a thank you email",
]
print("🤖 Customer Service Agent Demo")
print("================================\n")
for query in queries:
print(f"Query: {query}")
response = await agent.run(query)
print(f"Response: {response}")
print("---\n")
if __name__ == "__main__":
asyncio.run(main())