add inactive user state in comment
This commit is contained in:
parent
f74604ef21
commit
33745b8b54
@ -22,6 +22,7 @@ from livekit.agents import (
|
|||||||
BuiltinAudioClip,
|
BuiltinAudioClip,
|
||||||
JobContext,
|
JobContext,
|
||||||
JobProcess,
|
JobProcess,
|
||||||
|
UserStateChangedEvent,
|
||||||
MetricsCollectedEvent,
|
MetricsCollectedEvent,
|
||||||
RoomInputOptions,
|
RoomInputOptions,
|
||||||
RoomOutputOptions,
|
RoomOutputOptions,
|
||||||
@ -845,6 +846,20 @@ async def launch_avatar(ctx: JobContext, avatar_dispatcher_url: str, avatar_iden
|
|||||||
|
|
||||||
|
|
||||||
async def entrypoint(ctx: JobContext, avatar_dispatcher_url: str = None, vision_backend: str = "siliconflow", llm_backend: str = "deepseek"):
|
async def entrypoint(ctx: JobContext, avatar_dispatcher_url: str = None, vision_backend: str = "siliconflow", llm_backend: str = "deepseek"):
|
||||||
|
# inactivity_task: asyncio.Task | None = None
|
||||||
|
|
||||||
|
# async def user_presence_task():
|
||||||
|
# # try to ping the user 3 times, if we get no answer, close the session
|
||||||
|
# for _ in range(3):
|
||||||
|
# await session.generate_reply(
|
||||||
|
# instructions=(
|
||||||
|
# "你礼貌的询问用户是否还在通话。"
|
||||||
|
# )
|
||||||
|
# )
|
||||||
|
# await asyncio.sleep(10)
|
||||||
|
|
||||||
|
# session.shutdown()
|
||||||
|
|
||||||
# each log entry will include these fields
|
# each log entry will include these fields
|
||||||
ctx.log_context_fields = {
|
ctx.log_context_fields = {
|
||||||
"room": ctx.room.name,
|
"room": ctx.room.name,
|
||||||
@ -975,6 +990,17 @@ async def entrypoint(ctx: JobContext, avatar_dispatcher_url: str = None, vision_
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# @session.on("user_state_changed")
|
||||||
|
# def _user_state_changed(ev: UserStateChangedEvent):
|
||||||
|
# nonlocal inactivity_task
|
||||||
|
# if ev.new_state == "away":
|
||||||
|
# inactivity_task = asyncio.create_task(user_presence_task())
|
||||||
|
# return
|
||||||
|
|
||||||
|
# # ev.new_state: listening, speaking, ..
|
||||||
|
# if inactivity_task is not None:
|
||||||
|
# inactivity_task.cancel()
|
||||||
|
|
||||||
await session.start(
|
await session.start(
|
||||||
agent=MyAgent(initial_instructions, vision_backend=vision_backend),
|
agent=MyAgent(initial_instructions, vision_backend=vision_backend),
|
||||||
room=ctx.room,
|
room=ctx.room,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user