MCPcopy Create free account
hub / github.com/livekit/agents / _make_ctx

Function _make_ctx

tests/test_chat_ctx.py:467–481  ·  view source on GitHub ↗

Build a ChatContext with messages of the given roles.

(*roles: str)

Source from the content-addressed store, hash-verified

465
466
467def _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
484def test_truncate_noop_when_under_limit():

Calls 4

add_messageMethod · 0.95
ChatContextClass · 0.90
FunctionCallClass · 0.90
FunctionCallOutputClass · 0.90

Tested by

no test coverage detected