livekit / agents

Build real-time multimodal AI applications 🤖🎙️📹
https://docs.livekit.io/agents
Apache License 2.0
4k stars 415 forks source link

Unable to Run Assistant with livekit-agents 0.8.0.dev3 #503

Closed wezerr closed 3 months ago

wezerr commented 3 months ago

I am trying to run the assistant with the new package livekit-agents 0.8.0.dev3, but I am encountering the following error after executing the command python minimal.py start:

Traceback (most recent call last):
  File "C:\Projects\minimal-assist\minimal.py", line 3, in <module>
    from livekit.agents import JobContext, WorkerOptions, cli
  File "C:\Users\wez\AppData\Local\Programs\Python\Python312\Lib\site-packages\livekit\agents\__init__.py", line 15, in <module>
    from . import ipc, llm, stt, tokenize, transcription, tts, utils, vad, voice_assistant
  File "C:\Users\wez\AppData\Local\Programs\Python\Python312\Lib\site-packages\livekit\agents\ipc\__init__.py", line 1, in <module>
    from . import channel, proc_pool, proto, supervised_proc
  File "C:\Users\wez\AppData\Local\Programs\Python\Python312\Lib\site-packages\livekit\agents\ipc\proc_pool.py", line 4, in <module>
    from multiprocessing.context import ForkServerContext, SpawnContext
ImportError: cannot import name 'ForkServerContext' from 'multiprocessing.context' (C:\Users\wez\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\context.py)

Here is the complete code of minimal.py:

import asyncio

from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.llm import ChatContext
from livekit.agents.voice_assistant import VoiceAssistant
from livekit.plugins import deepgram, openai, silero

async def entrypoint(ctx: JobContext):
    initial_ctx = ChatContext().append(
        role="system",
        text=(
            "You are a voice assistant created by LiveKit. Your interface with users will be voice. "
            "You should use short and concise responses, and avoid usage of unpronounceable punctuation."
        ),
    )

    await ctx.connect()

    assistant = VoiceAssistant(
        vad=silero.VAD(),
        stt=deepgram.STT(),
        llm=openai.LLM(),
        tts=openai.TTS(),
        chat_ctx=initial_ctx,
    )
    assistant.start(ctx.room)

    await asyncio.sleep(1)
    await assistant.say("Hey, how can I help you today?", allow_interruptions=True)

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

requirements.txt:

livekit-agents~=0.8.0.dev3
livekit-plugins-openai~=0.6
livekit-plugins-deepgram~=0.5
livekit-plugins-elevenlabs~=0.6
livekit-plugins-silero~=0.5

If I change the version to 0.7.2, everything works correctly. Is it possible that this error is related to running the code on Windows?

theomonnom commented 3 months ago

Thanks for reporting the issue. I've just fixed it on the dev branch :)