adamant-airport-69140
02/13/2025, 4:17 PMgray-monkey-83525
02/13/2025, 4:17 PMshutdown_task
function is not explicitly mentioned in the provided data sources. However, you might be able to use a similar approach by utilizing the add_shutdown_callback
method, which allows you to define a callback function to be executed during shutdown. This method is mentioned in the context of handling shutdowns in LiveKit agents.
Would you like more details on how to use add_shutdown_callback
or any other related functionality?
Sources:
- https://docs.livekit.io/python/livekit/agents/ipc/proto.html
- https://docs.livekit.io/agents/openai/customize/parameters/
Note: I wasn’t able to find highly relevant data sources, but above are a few potentially relevant links. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.adamant-airport-69140
02/14/2025, 9:52 AMgray-monkey-83525
02/14/2025, 9:52 AMctx.shutdown
correctly, you should call it when you want to end the session or disconnect the agent from the room. This method is used to gracefully shut down the agent's job and perform any necessary cleanup. However, ctx.shutdown
does not automatically remove or delete the room itself; it only disconnects the agent from the room.
If you need to remove the room, you should use the LiveKit API to delete the room explicitly. This can be done by calling the delete_room
method from the LiveKit API client, as shown in the example below:
import os
from livekit import api
async def shutdown_hook():
lk_api = api.LiveKitAPI(
url=os.getenv('LIVEKIT_URL'),
api_key=os.getenv('LIVEKIT_API_KEY'),
api_secret=os.getenv('LIVEKIT_API_SECRET')
)
try:
delete_request = api.DeleteRoomRequest(room=room_name)
await lk_api.room.delete_room(delete_request)
print(f"Room '{room_name}' has been deleted successfully.")
except Exception as e:
print(f"Failed to delete room '{room_name}': {e}")
finally:
await lk_api.aclose()
Would you like more detailed guidance on using ctx.shutdown
or managing rooms?
Sources:
- Inside a session
- Slack discussion on shutdown 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.adamant-airport-69140
02/17/2025, 3:56 PMgray-monkey-83525
02/17/2025, 3:56 PMctx.shutdown
method. This reason can then be used within your shutdown callback function. Here's an example of how you can implement this:
async def my_shutdown_callback(reason):
print(f"Shutdown reason: {reason}")
ctx.add_shutdown_callback(lambda: my_shutdown_callback("Session ended"))
# Later in your code, when you want to shut down
ctx.shutdown(reason="Session ended")
In this example, the my_shutdown_callback
function is set up to receive a reason, and the ctx.shutdown
method is called with a specific reason. The callback will then print the reason when executed.
Would you like more details on setting up shutdown callbacks or handling shutdown reasons?
Sources:
- JobContext shutdown method 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.adamant-airport-69140
03/06/2025, 3:50 PMtall-airline-16756
03/06/2025, 3:50 PMtall-airline-16756
03/06/2025, 3:50 PMtool_choice
parameter when calling the chat
method of the LLM instance. For example:
llm.chat(
chat_ctx=chat_context,
tool_choice="required"
)
If the tool_choice
parameter is not provided during the chat
method call, it will use the default value set during the LLM's initialization. Let me know if you need further clarification! Sources: livekit.plugins.aws.llm API documentationadamant-airport-69140
03/06/2025, 4:20 PMtall-airline-16756
03/06/2025, 4:20 PMagent.fnc_ctx
and agent.tool_choice
parameters when executing an LLM function. However, these parameters are typically passed during the execution of the LLM's chat
or similar methods. If you have more details about your use case or the context, I can assist further or escalate this to a human specialist for more in-depth support.adamant-airport-69140
03/10/2025, 4:16 PM