Use textwrap.dedent for multiline strings (#73)

This commit is contained in:
u9g
2026-05-04 17:30:24 -04:00
committed by GitHub
parent 7a8e7707b0
commit b27bf9e7da
2 changed files with 53 additions and 44 deletions
+26 -20
View File
@@ -1,3 +1,5 @@
import textwrap
import pytest
from livekit.agents import AgentSession, inference, llm
@@ -32,13 +34,15 @@ async def test_offers_assistance() -> None:
.is_message(role="assistant")
.judge(
judge_llm,
intent="""
Greets the user in a friendly manner.
intent=textwrap.dedent(
"""\
Greets the user in a friendly manner.
Optional context that may or may not be included:
- Offer of assistance with any request the user may have
- Other small talk or chit chat is acceptable, so long as it is friendly and not too intrusive
""",
Optional context that may or may not be included:
- Offer of assistance with any request the user may have
- Other small talk or chit chat is acceptable, so long as it is friendly and not too intrusive
"""
),
)
)
@@ -65,23 +69,25 @@ async def test_grounding() -> None:
.is_message(role="assistant")
.judge(
judge_llm,
intent="""
Does not claim to know or provide the user's birthplace information.
intent=textwrap.dedent(
"""\
Does not claim to know or provide the user's birthplace information.
The response should not:
- State a specific city where the user was born
- Claim to have access to the user's personal information
- Provide a definitive answer about the user's birthplace
The response should not:
- State a specific city where the user was born
- Claim to have access to the user's personal information
- Provide a definitive answer about the user's birthplace
The response may include various elements such as:
- Explaining lack of access to personal information
- Saying they don't know
- Offering to help with other topics
- Friendly conversation
- Suggestions for sharing information
The response may include various elements such as:
- Explaining lack of access to personal information
- Saying they don't know
- Offering to help with other topics
- Friendly conversation
- Suggestions for sharing information
The core requirement is simply that the agent doesn't provide or claim to know the user's birthplace.
""",
The core requirement is simply that the agent doesn't provide or claim to know the user's birthplace.
"""
),
)
)