Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,10 @@ def transfer_to_english_agent():
|
|
12 |
"""Transfer English-speaking users to the English agent."""
|
13 |
return english_agent
|
14 |
|
|
|
|
|
|
|
|
|
15 |
def verify_order_task():
|
16 |
"""Handle order verification task."""
|
17 |
return order_verifier_agent
|
@@ -20,7 +24,7 @@ def verify_order_task():
|
|
20 |
general_agent = Agent(
|
21 |
name="General Agent",
|
22 |
instructions="Assist the user based on language and delegate tasks if needed.",
|
23 |
-
functions=[transfer_to_spanish_agent, transfer_to_english_agent],
|
24 |
)
|
25 |
|
26 |
# Spanish-specific agent
|
@@ -35,6 +39,12 @@ english_agent = Agent(
|
|
35 |
instructions="You only speak English. Help with customer support in English.",
|
36 |
)
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
# Task-specific agent for verifying orders
|
39 |
order_verifier_agent = Agent(
|
40 |
name="Order Verifier",
|
@@ -50,12 +60,14 @@ def customer_support_demo(user_input):
|
|
50 |
response = client.run(agent=spanish_agent, messages=messages)
|
51 |
elif "hello" in user_input.lower():
|
52 |
response = client.run(agent=english_agent, messages=messages)
|
|
|
|
|
53 |
else:
|
54 |
response = client.run(agent=general_agent, messages=messages)
|
55 |
|
56 |
return response.messages[-1]["content"]
|
57 |
|
58 |
-
# Create the Gradio interface
|
59 |
iface = gr.Interface(
|
60 |
fn=customer_support_demo,
|
61 |
inputs="text",
|
|
|
12 |
"""Transfer English-speaking users to the English agent."""
|
13 |
return english_agent
|
14 |
|
15 |
+
def transfer_to_hindi_agent():
|
16 |
+
"""Transfer Hindi-speaking users to the Hindi agent."""
|
17 |
+
return hindi_agent
|
18 |
+
|
19 |
def verify_order_task():
|
20 |
"""Handle order verification task."""
|
21 |
return order_verifier_agent
|
|
|
24 |
general_agent = Agent(
|
25 |
name="General Agent",
|
26 |
instructions="Assist the user based on language and delegate tasks if needed.",
|
27 |
+
functions=[transfer_to_spanish_agent, transfer_to_english_agent, transfer_to_hindi_agent],
|
28 |
)
|
29 |
|
30 |
# Spanish-specific agent
|
|
|
39 |
instructions="You only speak English. Help with customer support in English.",
|
40 |
)
|
41 |
|
42 |
+
# Hindi-specific agent
|
43 |
+
hindi_agent = Agent(
|
44 |
+
name="Hindi Agent",
|
45 |
+
instructions="You only speak Hindi. Help with customer support in Hindi.",
|
46 |
+
)
|
47 |
+
|
48 |
# Task-specific agent for verifying orders
|
49 |
order_verifier_agent = Agent(
|
50 |
name="Order Verifier",
|
|
|
60 |
response = client.run(agent=spanish_agent, messages=messages)
|
61 |
elif "hello" in user_input.lower():
|
62 |
response = client.run(agent=english_agent, messages=messages)
|
63 |
+
elif "नमस्ते" in user_input.lower():
|
64 |
+
response = client.run(agent=hindi_agent, messages=messages)
|
65 |
else:
|
66 |
response = client.run(agent=general_agent, messages=messages)
|
67 |
|
68 |
return response.messages[-1]["content"]
|
69 |
|
70 |
+
# Create the Gradio interface with a label and description
|
71 |
iface = gr.Interface(
|
72 |
fn=customer_support_demo,
|
73 |
inputs="text",
|