File size: 3,323 Bytes
1b90d5f
 
 
966c032
8a597b5
 
 
1b90d5f
 
 
8a597b5
 
 
 
 
 
 
 
 
 
1b90d5f
5c2bca4
1b90d5f
 
 
 
 
 
 
 
966c032
 
 
1b90d5f
 
 
5c2bca4
1b90d5f
 
 
 
 
 
 
 
 
 
 
 
 
 
966c032
 
1b90d5f
 
 
5c2bca4
1b90d5f
 
 
 
 
 
 
 
 
 
 
 
 
966c032
 
 
5c2bca4
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
# Reference: https://github.com/openai/build-hours/blob/main/2-assistants/7_orchestration.py

from openai import OpenAI

from tools import escalate_to_human
from tools import transfer_to_sales_agent, transfer_to_issues_repairs_agent, transfer_to_triage_agent 
from tools import execute_order, execute_refund, look_up_item

MODEL = "gpt-4o-mini"

escalate_to_human_json = function_to_schema(escalate_to_human)

transfer_to_sales_agent_json = function_to_schema(transfer_to_sales_agent)
transfer_to_issues_repairs_agent_json = function_to_schema(transfer_to_issues_repairs_agent)
transfer_to_triage_agent_json = function_to_schema(transfer_to_triage_agent)

execute_order_json = function_to_schema(execute_order)
execute_refund_json = function_to_schema(execute_refund)
look_up_item_json = function_to_schema(look_up_item)

def create_triage_agent(client):
    return client.beta.assistants.create(
        name="Triage Agent",
        instructions=(
            "You are a customer service bot for ACME Inc. "
            "Introduce yourself. Always be very brief. "
            "Gather information to direct the customer to the right department. "
            "But make your questions subtle and natural."
        ),
        model=MODEL,
        tools=[{"type": "function", "function": transfer_to_sales_agent_json},
               {"type": "function", "function": transfer_to_issues_repairs_agent_json},
               {"type": "function", "function": escalate_to_human_json}],
    )

def create_sales_agent(client):
    return client.beta.assistants.create(
        name="Sales Agent",
        instructions=(
            "You are a sales agent for ACME Inc."
            "Always answer in a sentence or less."
            "Follow the following routine with the user:"
            "1. Ask them about any problems in their life related to catching roadrunners.\n"
            "2. Casually mention one of ACME's crazy made-up products can help.\n"
            " - Don't mention price.\n"
            "3. Once the user is bought in, drop a ridiculous price.\n"
            "4. Only after everything, and if the user says yes, "
            "tell them a crazy caveat and execute their order.\n"
            ""
        ),
        model=MODEL,
        tools=[{"type": "function", "function": execute_order_json},
               {"type": "function", "function": transfer_to_triage_agent_json}],
    )
    
def create_issues_repairs_agent(client):
    return client.beta.assistants.create(
        name="Issues and Repairs Agent",
        instructions=(
            "You are a customer support agent for ACME Inc."
            "Always answer in a sentence or less."
            "Follow the following routine with the user:"
            "1. First, ask probing questions and understand the user's problem deeper.\n"
            " - unless the user has already provided a reason.\n"
            "2. Propose a fix (make one up).\n"
            "3. ONLY if not satesfied, offer a refund.\n"
            "4. If accepted, search for the ID and then execute refund."
            ""
        ),
        model=MODEL,
        tools=[{"type": "function", "function": look_up_item_json},
               {"type": "function", "function": execute_refund_json},
               {"type": "function", "function": transfer_to_triage_agent_json}],
    )