Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT has no attribute encode #1344

Open
BrianMwas opened this issue Jan 7, 2025 · 4 comments
Open

JWT has no attribute encode #1344

BrianMwas opened this issue Jan 7, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@BrianMwas
Copy link

BrianMwas commented Jan 7, 2025

Versions
livekit==0.18.2
livekit-agents==0.12.1
livekit-api==0.8.0
livekit-plugins-deepgram==0.6.13
livekit-plugins-openai==0.10.9
livekit-plugins-silero==0.7.4
livekit-protocol==0.7.0

I am getting an issue after deploying the voice app. Here is the error am getting
{"message": "failed to connect to livekit, retrying in 4s: module 'jwt' has no attribute 'encode'", "level": "WARNING", "name": "livekit.agents", "timestamp": "2025-01-07T14:42:30.328615+00:00"}

This error is not coming from my application since am using a base logger with labels and this is clearly JSON. Here is my set up

class VoiceWorker:
    """Initialized a new thread to run voice service"""

    """Worker for handling voice interactions"""

    def __init__(self) -> None:
        """Initialize the worker"""
        self.voice_service: Optional[VoiceAgentService] = None
        self.agent: VoicePipelineAgent = None

    def prewarm(self, proc: JobProcess):
        """Prewarm silero to handle interruptions"""
        proc.userdata["vad"] = silero.VAD.load()

    async def initialize_services(self, org_id: UUID, session_id: str):
        """Initialize required services with metadata from participant"""
        try:
            # Initialize vector store
            vector_store = await VectorStoreManager.create(org_id=org_id)

            # Initialize chat service
            chat_service = ChatService(
                vector_store_manager=vector_store, org_id=org_id, session_id=session_id
            )
            await chat_service.initialize()

            # Initialize voice service
            self.voice_service = VoiceAgentService(chat_service=chat_service)

            logger.info(f"Services initialized for org {org_id}, session {session_id}")

        except Exception as e:
            logger.error(f"Failed to initialize services: {str(e)}")
            raise

    async def entrypoint(self, ctx: JobContext):
        """Main entrypoint for the voice worker"""
        try:
            logger.info(f"Connecting to room {ctx.room.name}")
            await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)

            # Wait for participant and get metadata
            participant = await ctx.wait_for_participant()
            logger.info(
                f"Starting voice assistant for participant {participant.identity}"
            )

            # Parse metadata to get org_id and session_id
            metadata = json.loads(participant.metadata)
            org_id = UUID(metadata["org_id"])
            session_id = metadata["session_id"]

            logger.info(f"Participant metadata: {metadata}")

            # Initialize services with metadata
            await self.initialize_services(org_id, session_id)

            vad = ctx.proc.userdata["vad"]
            # Create and start agent
            self.agent = await self.voice_service.create_agent(
                ctx.room, participant, vad
            )
            await self.voice_service.greet_user()

        except Exception as e:
            logger.error(f"Error in worker entrypoint: {str(e)}")
            raise

    def run(self):
        """Run the voice worker"""
        try:
            logger.info("Voice worker initialized")
            cli.run_app(
                WorkerOptions(
                    entrypoint_fnc=self.entrypoint,
                    prewarm_fnc=self.prewarm,
                    api_key=settings.LIVEKIT_API_KEY,
                    api_secret=settings.LIVEKIT_API_SECRET,
                    ws_url=settings.LIVEKIT_WS_URL,
                    initialize_process_timeout=30,
                )
            )
        except Exception as e:
            logger.error(f"Failed to run worker: {str(e)}")
            raise

    async def shutdown(self):
        """Shutdown the server"""
        logger.info("Shutting down voice worker")

And am simply calling run. Am also trying to pass unique values. For example the organisation Id. Any help is really appreciated

@BrianMwas BrianMwas added the bug Something isn't working label Jan 7, 2025
@theomonnom
Copy link
Member

Hey, this looks like an issue with the installed external dependencies.
Can you run pip freeze on the server you're having the issue

@BrianMwas
Copy link
Author

Here's my pip freeze
aiobotocore==2.15.2
aiodns==3.2.0
aiofiles==22.1.0
aiohappyeyeballs==2.4.3
aiohttp==3.10.10
aioitertools==0.12.0
aiosignal==1.3.1
alembic==1.13.3
annotated-types==0.7.0
anyio==4.6.2.post1
asyncio==3.4.3
asyncpg==0.30.0
attrs==24.2.0
av==14.0.1
beautifulsoup4==4.12.3
black==24.10.0
blis==1.1.0
bm25s==0.2.5
boto3==1.35.36
botocore==1.35.36
build==1.2.2.post1
catalogue==2.0.10
certifi==2024.8.30
cffi==1.17.1
cfgv==3.4.0
charset-normalizer==3.4.0
click==8.1.7
cloudpathlib==0.20.0
cohere==5.13.3
coloredlogs==15.0.1
confection==0.1.5
coverage==7.6.4
cryptography==43.0.3
cymem==2.0.10
dataclasses-json==0.6.7
Deprecated==1.2.14
dirtyjson==1.0.8
distlib==0.3.9
distro==1.9.0
dnspython==2.7.0
email_validator==2.2.0
fastapi==0.115.2
fastavro==1.9.7
fastembed==0.4.1
filelock==3.16.1
filetype==1.2.0
flake8==7.1.1
flatbuffers==24.3.25
frozenlist==1.4.1
fsspec==2024.10.0
greenlet==3.1.1
grpcio==1.67.0
grpcio-tools==1.67.0
h11==0.14.0
h2==4.1.0
hpack==4.0.0
httpcore==1.0.6
httptools==0.6.4
httpx==0.27.2
httpx-sse==0.4.0
huggingface-hub==0.26.1
humanfriendly==10.0
hyperframe==6.0.1
identify==2.6.1
idna==3.10
iniconfig==2.0.0
isort==5.13.2
Jinja2==3.1.4
jiter==0.6.1
jmespath==1.0.1
joblib==1.4.2
jsonpatch==1.33
jsonpointer==3.0.0
jwt==1.3.1
langchain-core==0.3.12
langcodes==3.5.0
langgraph==0.2.39
langgraph-checkpoint==2.0.1
langgraph-sdk==0.1.33
langsmith==0.1.137
language_data==1.3.0
livekit==0.18.2
livekit-agents==0.12.1
livekit-api==0.8.0
livekit-plugins-deepgram==0.6.13
livekit-plugins-openai==0.10.9
livekit-plugins-silero==0.7.4
livekit-protocol==0.7.0
llama-cloud==0.1.5
llama-index==0.12.0
llama-index-agent-openai==0.4.0
llama-index-cli==0.4.0
llama-index-core==0.12.0
llama-index-embeddings-fastembed==0.3.0
llama-index-embeddings-openai==0.3.0
llama-index-indices-managed-llama-cloud==0.6.1
llama-index-legacy==0.9.48.post3
llama-index-llms-groq==0.3.0
llama-index-llms-openai==0.3.0
llama-index-llms-openai-like==0.3.0
llama-index-multi-modal-llms-openai==0.3.0
llama-index-postprocessor-cohere-rerank==0.3.0
llama-index-program-openai==0.3.0
llama-index-question-gen-openai==0.3.0
llama-index-readers-file==0.4.0
llama-index-readers-llama-parse==0.4.0
llama-index-readers-s3==0.4.0
llama-index-retrievers-bm25==0.5.0
llama-index-storage-chat-store-upstash==0.2.0
llama-index-tools-tavily-research==0.3.0
llama-index-vector-stores-qdrant==0.4.0
llama-parse==0.5.11
loguru==0.7.2
Mako==1.3.6
marisa-trie==1.2.1
markdown-it-py==3.0.0
MarkupSafe==3.0.2
marshmallow==3.23.0
mccabe==0.7.0
mdurl==0.1.2
mmh3==4.1.0
mpmath==1.3.0
msgpack==1.1.0
multidict==6.1.0
murmurhash==1.0.11
mypy==1.9.0
mypy-extensions==1.0.0
nest-asyncio==1.6.0
networkx==3.4.2
nltk==3.9.1
nodeenv==1.9.1
numpy==1.26.4
onnx==1.17.0
onnxruntime==1.19.2
openai==1.52.1
orjson==3.10.10
packaging==24.1
pandas==2.2.3
parameterized==0.9.0
pathspec==0.12.1
pillow==10.4.0
pip-tools==7.4.1
platformdirs==4.3.6
pluggy==1.5.0
portalocker==2.10.1
pre_commit==4.0.1
preshed==3.0.9
propcache==0.2.0
protobuf==5.28.3
psutil==5.9.8
psycopg2-binary==2.9.10
py_rust_stemmers==0.1.1
pycares==4.5.0
pycodestyle==2.12.1
pycparser==2.22
pydantic==2.9.2
pydantic-settings==2.6.0
pydantic_core==2.23.4
pyflakes==3.2.0
Pygments==2.18.0
PyJWT==2.10.1
pypdf==5.1.0
pyproject_hooks==1.2.0
PyStemmer==2.2.0.3
pytest==8.3.3
pytest-asyncio==0.24.0
pytest-cov==5.0.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-multipart==0.0.17
pytz==2024.2
PyYAML==6.0.2
qdrant-client==1.12.0
regex==2024.9.11
requests==2.32.3
requests-toolbelt==1.0.0
rich==13.9.4
s3fs==2024.10.0
s3transfer==0.10.3
safetensors==0.4.5
scipy==1.14.1
setuptools==75.2.0
shellingham==1.5.4
six==1.16.0
smart-open==7.1.0
sniffio==1.3.1
soupsieve==2.6
spacy==3.8.3
spacy-legacy==3.0.12
spacy-loggers==1.0.5
SQLAlchemy==2.0.36
srsly==2.5.0
starlette==0.40.0
striprtf==0.0.26
sympy==1.13.1
tavily-python==0.5.0
tenacity==8.5.0
thinc==8.3.3
tiktoken==0.8.0
tokenizers==0.20.1
torch==2.5.1
tqdm==4.66.5
transformers==4.46.3
typer==0.15.1
types-aiofiles==22.1.0
types-protobuf==4.25.0.20240417
types-requests==2.32.0.20241016
typing-inspect==0.9.0
typing_extensions==4.12.2
tzdata==2024.2
upstash-redis==1.2.0
urllib3==2.2.3
uvicorn==0.32.0
uvloop==0.21.0
virtualenv==20.27.0
wasabi==1.1.3
watchfiles==0.24.0
weasel==0.4.1
websockets==14.1
wheel==0.44.0
wrapt==1.16.0
yarl==1.16.0

@BrianMwas
Copy link
Author

Might it be because of the PyJWT?

@BrianMwas
Copy link
Author

So I remove it but started getting the job to initialize
For example the following logs
{
"message": "job process initialized",
"level": "INFO",
"name": "livekit.agents",
"pid": 89,
"timestamp": "2025-01-08T07:52:59.946612+00:00"
}

and then it switches back to initializing
{
"message": "initializing job process",
"level": "INFO",
"name": "livekit.agents",
"pid": 124,
"timestamp": "2025-01-08T07:53:04.900331+00:00"
}

Am getting the following after the logs above and keeps logging it over and over again
{
"message": "process memory usage is high",
"level": "WARNING",
"name": "livekit.agents",
"memory_usage_mb": 652.90625,
"memory_warn_mb": 300,
"memory_limit_mb": 0,
"pid": 89,
"timestamp": "2025-01-08T07:53:09.948219+00:00"
}
Am running my server on a 96 GB ram, I feel this is enough. Not sure what am doing wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants