mirror of
https://github.com/livekit/agents.git
synced 2026-12-06 04:18:36 +00:00
30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
"""Static agent and workflow instruction authoring."""
|
|
|
|
import pytest
|
|
|
|
from livekit.agents.beta.workflows import WarmTransfer, WorkflowInstructions
|
|
|
|
pytestmark = pytest.mark.unit
|
|
|
|
|
|
def test_workflow_sections_produce_static_agent_instructions() -> None:
|
|
transfer = WarmTransfer(
|
|
"+15550100",
|
|
sip_trunk_id="trunk",
|
|
instructions=WorkflowInstructions(
|
|
persona="You are the desk.", extra="Confirm the booking."
|
|
),
|
|
)
|
|
instructions = transfer._agent.instructions
|
|
assert isinstance(instructions, str)
|
|
assert "You are the desk." in instructions
|
|
assert "Confirm the booking." in instructions
|
|
assert instructions.count("You are the desk.") == 1
|
|
for placeholder in ("{persona}", "{extra}", "{_conversation_history}"):
|
|
assert placeholder not in instructions
|
|
|
|
|
|
def test_fixed_workflow_instructions_replace_the_template() -> None:
|
|
transfer = WarmTransfer("+15550100", sip_trunk_id="trunk", instructions="Fixed text.")
|
|
assert transfer._agent.instructions == "Fixed text."
|