Skip to content

Commit

Permalink
rename to transfer_function_description
Browse files Browse the repository at this point in the history
  • Loading branch information
longcw committed Dec 26, 2024
1 parent 92ab58d commit a94f06d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions examples/voice-pipeline-agent/multi_task/restaurant_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, menu: str):
functions=[self.start_new_order],
options=AgentTaskOptions(
before_enter_cb=before_enter_cb,
before_enter_cb_description=(
transfer_function_description=(
"Called to transfer to the greeter when the user asks for general questions "
"or starting over after checking out."
),
Expand Down Expand Up @@ -121,7 +121,7 @@ def __init__(self, menu: str):
options=AgentTaskOptions(
can_enter_cb=self.can_enter,
before_enter_cb=before_enter_cb,
before_enter_cb_description=(
transfer_function_description=(
"Called to transfer to the order taking "
"when the user wants to take an order or modify their order."
),
Expand Down Expand Up @@ -164,7 +164,7 @@ def __init__(self):
options=AgentTaskOptions(
can_enter_cb=self.can_enter,
before_enter_cb=before_enter_cb,
before_enter_cb_description=(
transfer_function_description=(
"Called to transfer to the customer registration "
"after the order is confirmed or the user wants to update their information."
),
Expand Down Expand Up @@ -215,7 +215,7 @@ def __init__(self, menu: str):
options=AgentTaskOptions(
can_enter_cb=self.can_enter,
before_enter_cb=before_enter_cb,
before_enter_cb_description=(
transfer_function_description=(
"Called to transfer to the checkout "
"after the user confirms the order and registration."
),
Expand Down
14 changes: 8 additions & 6 deletions livekit-agents/livekit/agents/pipeline/agent_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def _default_can_enter_cb(agent: "VoicePipelineAgent") -> bool:
class AgentTaskOptions:
can_enter_cb: Callable[["VoicePipelineAgent"], bool] = _default_can_enter_cb
"""callback to check if the task can be entered"""
before_enter_cb_description: Optional[Union[str, _UseDocMarker]] = None
"""description of the before_enter callback, use `Called to transfer to {task_name}` if not provided"""
transfer_function_description: Optional[Union[str, _UseDocMarker]] = None
"""description of the transfer function, use `Called to transfer to {task_name}` if not provided"""
before_enter_cb: BeforeEnterCallback = _default_before_enter_cb
"""callback to call before entering the task"""

Expand Down Expand Up @@ -75,13 +75,15 @@ def __init__(
# transfer function
from ..pipeline import AgentCallContext

fnc_desc = (
options.before_enter_cb_description
if options.before_enter_cb_description is not None
transfer_fnc_desc = (
options.transfer_function_description
if options.transfer_function_description is not None
else f"Called to transfer to {self._task_name}"
)

@ai_callable(name=f"transfer_to_{self._task_name}", description=fnc_desc)
@ai_callable(
name=f"transfer_to_{self._task_name}", description=transfer_fnc_desc
)
async def transfer_fnc() -> Union["AgentTask", tuple["AgentTask", str]]:
agent = AgentCallContext.get_current().agent
return await self._opts.before_enter_cb(agent, self)
Expand Down

0 comments on commit a94f06d

Please sign in to comment.