I need to make a custom plugin, it's an avatar plu...
# ask-ai
m
I need to make a custom plugin, it's an avatar plugin, give me step by step guide on how to do it. The problem is that I'm stuck with local development. I want to test run the plugin that I made. I copied other providers, primary Tavus and modified it. But I have a script file, it's a test file inside the examples but when I'm trying to run it, I'm getting into a bunch of errors related to local, I mean live kit not running properly. It's connected to local host. I don't know why. How do I test my creator plugin, what's the easiest way, is there a standard way?
t
Thanks for reaching out, AI. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you test your custom avatar plugin during local development, here’s a friendly step-by-step guide: 1. Set up Local Processing: Try using a local processing provider like bitHuman, which lets you run avatar models right on your machine. You can easily load a local image or model file to get started with testing. 2. Use Built-in Mock Avatars: For a quick start, you might want to use the Audio Wave Visualization mock avatar that’s included in the examples. It’s a great way to see things in action early on. 3. Develop Your Plugin: Make sure your plugin follows the standard structure, including a well-implemented
AvatarSession
class and the proper plugin registration pattern. This helps everything run smoothly. 4. Authentication: Don’t forget to set up your environment variables with the API keys and generate LiveKit tokens for avatar participants. This step is key for secure access. 5. Testing Workflow: When you’re ready, install your plugin in development mode, then initialize an
AgentSession
and
AvatarSession
. It’s important to start the avatar session before the agent session to keep things in order. 6. Preview: Finally, test your avatar in the LiveKit Agents Playground or by integrating it with a frontend starter app for a more real-world feel. If you run into errors about LiveKit not running properly on localhost, here are a few things to double-check: • Is the LiveKit server running locally and accessible to your setup? • Have you set all the required environment variables, like your API keys, correctly? • Are you initializing the avatar session and agent session in the right order in your test script? Please feel free to reach out if you want me to walk you through any specific step or if you hit any errors—I’m here to help! Sources: Anam virtual avatar integration guide | LiveKit Docs | plugins/bey/README.md | Virtual avatar plugins | LiveKit Docs | livekit-plugins/livekit-plugins-bey/livekit/plugins/bey/__init__.py | Hedra Realtime Avatar integration guide | LiveKit Docs
m
1. Testing Workflow: When you’re ready, install your plugin in development mode, then initialize an
AgentSession
and
AvatarSession
. It’s important to start the avatar session before the agent session to keep things in order. how
t
Let's walk through how to initialize and start an
AgentSession
and
AvatarSession
for your custom plugin together. Here’s a simple step-by-step guide: 1. Initialize the AgentSession: Begin by creating an
AgentSession
with the AI components you want to use, like STT, LLM, and TTS. Here’s an example to get you started:
Copy code
session = AgentSession(
    stt=...,  # e.g., deepgram.STT(), google.STT()
    llm=...,  # e.g., openai.LLM(), mistral.LLM()
    tts=...,  # e.g., cartesia.TTS(), azure.TTS()
    vad=silero.VAD.load(),  # Optional voice activity detection
)
1. Initialize the AvatarSession: Next, create an
AvatarSession
from your plugin. Here’s an example using bitHuman:
Copy code
from livekit.plugins import bithuman

avatar = bithuman.AvatarSession(
    model_path="./albert_einstein.imx",  # Path to avatar model
)
1. Start the AvatarSession: It’s important to start the avatar session before the agent session to make sure audio routing works smoothly. Here’s how you can do that:
Copy code
await avatar.start(session, room=ctx.room)
1. Start the AgentSession: Finally, start the agent session in the room. For example:
Copy code
await session.start(
    room=ctx.room,
    agent=Agent(instructions="Talk to me!"),  # Your agent logic
)
Also, please double-check that your environment variables like
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
are set up correctly. If you have any questions or want me to clarify anything, just let me know—I’m here to help! Sources: livekit-plugins/livekit-plugins-simli/livekit/plugins/simli/avatar.py | Virtual avatar plugins | LiveKit Docs