openai-assistants / assistants.py
bstraehle's picture
Create assistants.py
1b90d5f verified
raw
history blame
2.62 kB
# Reference: https://github.com/openai/build-hours/blob/main/2-assistants/7_orchestration.py
from openai import OpenAI
MODEL = "gpt-4o-mini"
def create_triage_agent(client):
assistant = 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": "transfer_to_sales_agent"},
{"type": "transfer_to_issues_repairs_agent"},
{"type": "escalate_to_human"}],
)
show_json("assistant", assistant)
return assistant
def create_sales_agent(client):
assistant = 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": "execute_order"},
{"type": "transfer_back_to_triage"}],
)
show_json("assistant", assistant)
return assistant
def create_issues_repairs_agent(client):
assistant = 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": "execute_refund"},
{"type": "look_up_item"},
{"type": "transfer_back_to_triage"}],
)
show_json("assistant", assistant)
return assistant