Spaces:
Running
Running
Update assistants.py
Browse files- assistants.py +55 -5
assistants.py
CHANGED
@@ -38,7 +38,7 @@ def create_sales_agent(client):
|
|
38 |
),
|
39 |
model=MODEL,
|
40 |
tools=[{"type": "execute_order"},
|
41 |
-
{"type": "
|
42 |
)
|
43 |
show_json("assistant", assistant)
|
44 |
return assistant
|
@@ -58,9 +58,59 @@ def create_issues_repairs_agent(client):
|
|
58 |
""
|
59 |
),
|
60 |
model=MODEL,
|
61 |
-
tools=[{"type": "
|
62 |
-
{"type": "
|
63 |
-
{"type": "
|
64 |
)
|
65 |
show_json("assistant", assistant)
|
66 |
-
return assistant
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
),
|
39 |
model=MODEL,
|
40 |
tools=[{"type": "execute_order"},
|
41 |
+
{"type": "transfer_to_triage_agent"}],
|
42 |
)
|
43 |
show_json("assistant", assistant)
|
44 |
return assistant
|
|
|
58 |
""
|
59 |
),
|
60 |
model=MODEL,
|
61 |
+
tools=[{"type": "look_up_item"},
|
62 |
+
{"type": "execute_refund"},
|
63 |
+
{"type": "transfer_to_triage_agent"}],
|
64 |
)
|
65 |
show_json("assistant", assistant)
|
66 |
+
return assistant
|
67 |
+
|
68 |
+
def escalate_to_human(summary):
|
69 |
+
"""Only call this if explicitly asked to."""
|
70 |
+
print("Escalating to human agent...")
|
71 |
+
print("\n=== Escalation Report ===")
|
72 |
+
print(f"Summary: {summary}")
|
73 |
+
print("=========================\n")
|
74 |
+
exit()
|
75 |
+
|
76 |
+
def transfer_to_sales_agent():
|
77 |
+
"""Use for anything sales or buying related."""
|
78 |
+
return sales_agent
|
79 |
+
|
80 |
+
def transfer_to_issues_repairs_agent():
|
81 |
+
"""Use for issues, repairs, or refunds."""
|
82 |
+
return issues_and_repairs_agent
|
83 |
+
|
84 |
+
def transfer_to_triage_agent():
|
85 |
+
"""Call this if the user brings up a topic outside of your purview,
|
86 |
+
including escalating to human."""
|
87 |
+
return triage_agent
|
88 |
+
|
89 |
+
def execute_order(product, price: int):
|
90 |
+
"""Price should be in USD."""
|
91 |
+
print("\n\n=== Order Summary ===")
|
92 |
+
print(f"Product: {product}")
|
93 |
+
print(f"Price: ${price}")
|
94 |
+
print("=================\n")
|
95 |
+
confirm = input("Confirm order? y/n: ").strip().lower()
|
96 |
+
if confirm == "y":
|
97 |
+
print("Order execution successful!")
|
98 |
+
return "Success"
|
99 |
+
else:
|
100 |
+
print(color("Order cancelled!", "red"))
|
101 |
+
return "User cancelled order."
|
102 |
+
|
103 |
+
def look_up_item(search_query):
|
104 |
+
"""Use to find item ID.
|
105 |
+
Search query can be a description or keywords."""
|
106 |
+
item_id = "item_132612938"
|
107 |
+
print("Found item:", item_id)
|
108 |
+
return item_id
|
109 |
+
|
110 |
+
def execute_refund(item_id, reason="not provided"):
|
111 |
+
print("\n\n=== Refund Summary ===")
|
112 |
+
print(f"Item ID: {item_id}")
|
113 |
+
print(f"Reason: {reason}")
|
114 |
+
print("=================\n")
|
115 |
+
print("Refund execution successful!")
|
116 |
+
return "Success"
|