1111 MetricsCollectedEvent ,
1212 RunContext ,
1313 cli ,
14+ inference ,
1415 metrics ,
1516 room_io ,
1617)
@@ -36,7 +37,7 @@ def __init__(self) -> None:
3637 "you will speak english to the user" ,
3738 )
3839
39- async def on_enter (self ):
40+ async def on_enter (self ) -> None :
4041 # when the agent is added to the session, it'll generate a reply
4142 # according to its instructions
4243 # Keep it uninterruptible so the client has time to calibrate AEC (Acoustic Echo Cancellation).
@@ -47,7 +48,7 @@ async def on_enter(self):
4748 @function_tool
4849 async def lookup_weather (
4950 self , context : RunContext , location : str , latitude : str , longitude : str
50- ):
51+ ) -> str :
5152 """Called when the user asks for weather related information.
5253 Ensure the user's location (city or region) is provided.
5354 When given a location, please estimate the latitude and longitude of the location and
@@ -67,20 +68,20 @@ async def lookup_weather(
6768server = AgentServer ()
6869
6970
70- def prewarm (proc : JobProcess ):
71+ def prewarm (proc : JobProcess ) -> None :
7172 proc .userdata ["vad" ] = silero .VAD .load ()
7273
7374
7475server .setup_fnc = prewarm
7576
7677
7778@server .rtc_session ()
78- async def entrypoint (ctx : JobContext ):
79+ async def entrypoint (ctx : JobContext ) -> None :
7980 # each log entry will include these fields
8081 ctx .log_context_fields = {
8182 "room" : ctx .room .name ,
8283 }
83- session = AgentSession (
84+ session : AgentSession = AgentSession (
8485 # Speech-to-text (STT) is your agent's ears, turning the user's speech into text that the LLM can understand
8586 # See all available models at https://docs.livekit.io/agents/models/stt/
8687 stt = "deepgram/nova-3" ,
@@ -94,6 +95,7 @@ async def entrypoint(ctx: JobContext):
9495 # See more at https://docs.livekit.io/agents/build/turns
9596 turn_detection = MultilingualModel (),
9697 vad = ctx .proc .userdata ["vad" ],
98+ bargein_detector = inference .BargeinDetector (),
9799 # allow the LLM to generate a response while waiting for the end of turn
98100 # See more at https://docs.livekit.io/agents/build/audio/#preemptive-generation
99101 preemptive_generation = True ,
@@ -107,11 +109,11 @@ async def entrypoint(ctx: JobContext):
107109 usage_collector = metrics .UsageCollector ()
108110
109111 @session .on ("metrics_collected" )
110- def _on_metrics_collected (ev : MetricsCollectedEvent ):
112+ def _on_metrics_collected (ev : MetricsCollectedEvent ) -> None :
111113 metrics .log_metrics (ev .metrics )
112114 usage_collector .collect (ev .metrics )
113115
114- async def log_usage ():
116+ async def log_usage () -> None :
115117 summary = usage_collector .get_summary ()
116118 logger .info (f"Usage: { summary } " )
117119
0 commit comments