adamant-megabyte-75317
02/16/2025, 5:26 PMgray-monkey-83525
02/16/2025, 5:26 PMfrom livekit.agents.llm import FunctionContext, TypeInfo
from typing import Annotated, Optional
fnc_ctx = FunctionContext()
@fnc_ctx.ai_callable(
name="finalize_conversation",
description="Finalize the conversation and initiate grading/scoring."
)
async def finalize_conversation(
is_over: Annotated[bool, TypeInfo(description="Whether conversation should be considered finished.")],
hints: Annotated[int, TypeInfo(description="Number of hints requested by user")],
notes: Annotated[Optional[str], TypeInfo(description="Additional notes about the conversation")] = None
) -> str:
if is_over:
return f"Conversation ended with {hints} hints used" + (f" Notes: {notes}" if notes else "")
return "Conversation continues"
In this example, is_over
and hints
are required because they lack default values, while notes
is optional due to its default value of None
.
Sources:
- LiveKit Slack Discussion 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.