Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,20 +12,23 @@ def transfer_to_triage_agent():
|
|
| 12 |
"""Call this if the user brings up a topic outside of your purview,
|
| 13 |
including escalating to human."""
|
| 14 |
print("=> transfer_to_triage_agent")
|
| 15 |
-
global triage_agent
|
| 16 |
set_current_agent(triage_agent)
|
|
|
|
| 17 |
|
| 18 |
def transfer_to_sales_agent():
|
| 19 |
"""Use for anything sales or buying related."""
|
| 20 |
print("=> transfer_to_sales_agent")
|
| 21 |
global sales_agent
|
| 22 |
set_current_agent(sales_agent)
|
|
|
|
| 23 |
|
| 24 |
def transfer_to_issues_repairs_agent():
|
| 25 |
"""Use for issues, repairs, or refunds."""
|
| 26 |
print("=> transfer_to_issues_repairs_agent")
|
| 27 |
global issues_repairs_agent
|
| 28 |
set_current_agent(issues_repairs_agent)
|
|
|
|
| 29 |
|
| 30 |
#
|
| 31 |
|
|
@@ -120,9 +123,9 @@ def create_issues_repairs_agent(client):
|
|
| 120 |
return client.beta.assistants.create(
|
| 121 |
name="Issues and Repairs Agent",
|
| 122 |
instructions=(
|
| 123 |
-
"You are a customer support agent for ACME Inc."
|
| 124 |
-
"Always answer in a sentence or less."
|
| 125 |
-
"Follow the following routine with the user:"
|
| 126 |
"1. First, ask probing questions and understand the user's problem deeper.\n"
|
| 127 |
" - unless the user has already provided a reason.\n"
|
| 128 |
"2. Propose a fix (make one up).\n"
|
|
@@ -188,7 +191,6 @@ def list_run_steps(client, thread, run):
|
|
| 188 |
run_id=run.id,
|
| 189 |
order="asc",
|
| 190 |
)
|
| 191 |
-
print("aaa")
|
| 192 |
|
| 193 |
for step in run_steps.data:
|
| 194 |
step_details = step.step_details
|
|
@@ -198,10 +200,8 @@ def list_run_steps(client, thread, run):
|
|
| 198 |
break
|
| 199 |
|
| 200 |
for tool_call in step_details.tool_calls:
|
| 201 |
-
print("bbb")
|
| 202 |
execute_tool_call(tool_call)
|
| 203 |
|
| 204 |
-
print("ccc")
|
| 205 |
return run_steps
|
| 206 |
|
| 207 |
def list_messages(client, thread):
|
|
@@ -234,7 +234,9 @@ def set_current_agent(agent):
|
|
| 234 |
|
| 235 |
def set_current_thread(thread):
|
| 236 |
global current_thread
|
|
|
|
| 237 |
current_thread = thread
|
|
|
|
| 238 |
|
| 239 |
def get_current_agent():
|
| 240 |
global current_agent
|
|
@@ -244,6 +246,8 @@ def get_current_agent():
|
|
| 244 |
|
| 245 |
def get_current_thread():
|
| 246 |
global current_thread
|
|
|
|
|
|
|
| 247 |
return current_thread
|
| 248 |
|
| 249 |
#
|
|
|
|
| 12 |
"""Call this if the user brings up a topic outside of your purview,
|
| 13 |
including escalating to human."""
|
| 14 |
print("=> transfer_to_triage_agent")
|
| 15 |
+
global triage_agent, triage_thread
|
| 16 |
set_current_agent(triage_agent)
|
| 17 |
+
set_current_thread(triage_thread)
|
| 18 |
|
| 19 |
def transfer_to_sales_agent():
|
| 20 |
"""Use for anything sales or buying related."""
|
| 21 |
print("=> transfer_to_sales_agent")
|
| 22 |
global sales_agent
|
| 23 |
set_current_agent(sales_agent)
|
| 24 |
+
set_current_thread(sales_thread)
|
| 25 |
|
| 26 |
def transfer_to_issues_repairs_agent():
|
| 27 |
"""Use for issues, repairs, or refunds."""
|
| 28 |
print("=> transfer_to_issues_repairs_agent")
|
| 29 |
global issues_repairs_agent
|
| 30 |
set_current_agent(issues_repairs_agent)
|
| 31 |
+
set_current_thread(issues_repairs_thread)
|
| 32 |
|
| 33 |
#
|
| 34 |
|
|
|
|
| 123 |
return client.beta.assistants.create(
|
| 124 |
name="Issues and Repairs Agent",
|
| 125 |
instructions=(
|
| 126 |
+
"You are a customer support agent for ACME Inc. "
|
| 127 |
+
"Always answer in a sentence or less. "
|
| 128 |
+
"Follow the following routine with the user: "
|
| 129 |
"1. First, ask probing questions and understand the user's problem deeper.\n"
|
| 130 |
" - unless the user has already provided a reason.\n"
|
| 131 |
"2. Propose a fix (make one up).\n"
|
|
|
|
| 191 |
run_id=run.id,
|
| 192 |
order="asc",
|
| 193 |
)
|
|
|
|
| 194 |
|
| 195 |
for step in run_steps.data:
|
| 196 |
step_details = step.step_details
|
|
|
|
| 200 |
break
|
| 201 |
|
| 202 |
for tool_call in step_details.tool_calls:
|
|
|
|
| 203 |
execute_tool_call(tool_call)
|
| 204 |
|
|
|
|
| 205 |
return run_steps
|
| 206 |
|
| 207 |
def list_messages(client, thread):
|
|
|
|
| 234 |
|
| 235 |
def set_current_thread(thread):
|
| 236 |
global current_thread
|
| 237 |
+
print("### set_current_thread ###")
|
| 238 |
current_thread = thread
|
| 239 |
+
show_json("Current Thread", current_thread)
|
| 240 |
|
| 241 |
def get_current_agent():
|
| 242 |
global current_agent
|
|
|
|
| 246 |
|
| 247 |
def get_current_thread():
|
| 248 |
global current_thread
|
| 249 |
+
print("### get_current_thread ###")
|
| 250 |
+
show_json("Current Thread", current_thread)
|
| 251 |
return current_thread
|
| 252 |
|
| 253 |
#
|