Build a ChatContext with messages of the given roles.
(*roles: str)
| 465 | |
| 466 | |
| 467 | def _make_ctx(*roles: str): |
| 468 | """Build a ChatContext with messages of the given roles.""" |
| 469 | from livekit.agents.llm import ChatContext |
| 470 | |
| 471 | ctx = ChatContext() |
| 472 | for role in roles: |
| 473 | if role == "function_call": |
| 474 | ctx.items.append(FunctionCall(name="fn", call_id="c1", arguments="{}")) |
| 475 | elif role == "function_call_output": |
| 476 | ctx.items.append( |
| 477 | FunctionCallOutput(name="fn", call_id="c1", output="{}", is_error=False) |
| 478 | ) |
| 479 | else: |
| 480 | ctx.add_message(role=role, content=f"msg-{role}") |
| 481 | return ctx |
| 482 | |
| 483 | |
| 484 | def test_truncate_noop_when_under_limit(): |
no test coverage detected