You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the user closes the browser tab or clicks disconnect, I expect a command to kill the current process (PID). However, upon checking, I only see the process being terminated but no actual disconnect happening. This leads to resource consumption, causing the system to slow down and disconnect when new users join the room.
LLM
None
Transcription Services
None
Synthesis Services
None
Telephony Services
None
Conversation Type and Platform
No response
Steps to Reproduce
User click connect the room
Live kit server get the log
User meet the agent
User close the tab or click disconnect
Live kit server receive Request leave from agent but the current PID not be killed
4-5 users do the same 5 first steps
6th user wait too long to connect and disconnect while talk
Expected Behavior
When user close the tab or click disconnect, the current PID of this user must be stop or killed
Screenshots
import asyncio
import os
import re
from datetime import datetime
from livekit.agents import JobContext, JobRequest, WorkerOptions, cli
from loguru import logger
from pydantic_settings import BaseSettings, SettingsConfigDict
from vocode.logging import configure_pretty_logging
from vocode.streaming.agent.chat_gpt_agent import ChatGPTAgent
from vocode.streaming.livekit.livekit_conversation import LiveKitConversation
from vocode.streaming.output_device.livekit_output_device import LiveKitOutputDevice
from vocode.streaming.models.events import Event, EventType, Sender
from vocode.streaming.utils.events_manager import EventsManager
from vocode.streaming.models.transcript import TranscriptCompleteEvent, TranscriptEvent
from utils.helpers import get_room_info
from utils.constant import SYSTEM_PROMPT
import json
import time
from utils.agents import create_llm_agent, create_transcriber_agent, create_synthesizer_agent
from utils.mongo_logger import insert_log
from datetime import datetime
class CustomEventsManager(EventsManager):
def init(self, agent: ChatGPTAgent = None):
super().init([EventType.TRANSCRIPT_COMPLETE, EventType.TRANSCRIPT, EventType.PHONE_CALL_ENDED])
if agent:
self.agent = agent
async def handle_event(self, event: Event):
if isinstance(event, TranscriptCompleteEvent):
conversation_dict = {"system": self.agent.agent_config.prompt_preamble}
print("The call has finished, the transcript was", event.transcript)
for eventlog in event.transcript.event_logs:
if eventlog.sender == Sender.BOT:
conversation_dict['assistant'] = eventlog.text
elif eventlog.sender == Sender.HUMAN:
conversation_dict['user'] = eventlog.text
# add timestamp
conversation_dict['timestamp'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
insert_log(conversation_dict)
# logger.info(f"Event received: {event}, {type(event)}")
# logger.info(f"prompt_preamble: {self.agent.agent_config.prompt_preamble}")
# logger.info(f"actions: {self.agent.functions}")
class Settings(BaseSettings):
livekit_api_key: str = "ENTER_YOUR_LIVE_KIT_API_KEY"
livekit_api_secret: str = "ENTER_YOUR_LIVE_KIT_API_SECRET"
livekit_ws_url: str = "ENTER_YOUR_LIVE_KIT_WS_URL"
# This means a .env file can be used to overload these settings
# ex: "OPENAI_API_KEY=my_key" will set openai_api_key over the default above
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore",
)
Brief Description
When the user closes the browser tab or clicks disconnect, I expect a command to kill the current process (PID). However, upon checking, I only see the process being terminated but no actual disconnect happening. This leads to resource consumption, causing the system to slow down and disconnect when new users join the room.
LLM
None
Transcription Services
None
Synthesis Services
None
Telephony Services
None
Conversation Type and Platform
No response
Steps to Reproduce
Expected Behavior
Screenshots
import asyncio
import os
import re
from datetime import datetime
from livekit.agents import JobContext, JobRequest, WorkerOptions, cli
from loguru import logger
from pydantic_settings import BaseSettings, SettingsConfigDict
from vocode.logging import configure_pretty_logging
from vocode.streaming.agent.chat_gpt_agent import ChatGPTAgent
from vocode.streaming.livekit.livekit_conversation import LiveKitConversation
from vocode.streaming.output_device.livekit_output_device import LiveKitOutputDevice
from vocode.streaming.models.events import Event, EventType, Sender
from vocode.streaming.utils.events_manager import EventsManager
from vocode.streaming.models.transcript import TranscriptCompleteEvent, TranscriptEvent
from utils.helpers import get_room_info
from utils.constant import SYSTEM_PROMPT
import json
import time
from utils.agents import create_llm_agent, create_transcriber_agent, create_synthesizer_agent
from utils.mongo_logger import insert_log
from datetime import datetime
class CustomEventsManager(EventsManager):
def init(self, agent: ChatGPTAgent = None):
super().init([EventType.TRANSCRIPT_COMPLETE, EventType.TRANSCRIPT, EventType.PHONE_CALL_ENDED])
if agent:
self.agent = agent
class Settings(BaseSettings):
async def wait_for_termination(conversation: LiveKitConversation, ctx: JobContext):
await conversation.wait_for_termination()
await conversation.terminate()
await ctx.room.disconnect()
async def entrypoint(ctx: JobContext):
global SYSTEM_PROMPT
LOCAL_SYSTEM_PROMPT = SYSTEM_PROMPT.format(rooms_info=get_room_info(), time=datetime.now().strftime("%Y-%m-%d"))
async def request_fnc(req: JobRequest) -> None:
logger.info(f"received request {req}")
await req.accept(entrypoint)
if name == "main":
settings = Settings()
cli.run_app(
WorkerOptions(
request_fnc,
api_key=settings.livekit_api_key,
api_secret=settings.livekit_api_secret,
ws_url=settings.livekit_ws_url,
)
)
The text was updated successfully, but these errors were encountered: