Does dispatch look for agents in cloud or local de...
# ask-ai
c
Does dispatch look for agents in cloud or local dev?
t
Thanks for reaching out, Subham. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Dispatch can find agents in both cloud and local development environments, depending on the mode and how you’ve set things up: • When you’re in dev or start mode, agents connect to either LiveKit Cloud or your own self-hosted LiveKit server. They register as workers and wait for dispatch requests. Then, Dispatch assigns jobs to these registered workers. • In console mode, agents run completely locally without connecting to any external server. This mode is perfect for local testing and debugging. What’s great is that the same agent code you develop locally can be deployed to LiveKit Cloud without any changes, making it super easy to move from local development to cloud production. Sources: LiveKit Docs | examples/avatar_agents/README.md | Deploying to production | LiveKit Docs | Voice AI quickstart | LiveKit Docs | An open source stack for real-time multimodal AI
c
How to deploy agents and assign name to them?
t
Hey there! If you're looking to deploy agents and give them names in LiveKit, here’s a simple guide to help you out: • Deploying Agents: ◦ First, authenticate with LiveKit Cloud by running:
lk cloud auth
If you’re juggling multiple projects, you can set your default project like this:
lk project set-default "<project-name>"
◦ Next, deploy your agent with:
lk agent deploy [working-dir]
Just make sure there’s a
livekit.toml
file in that directory. For example:
lk agent deploy .
• Assigning Names to Agents: ◦ When you initialize your agent, set the
agent_name
field in the
WorkerOptions
. ◦ For Python, it looks like this:
Copy code
if __name__ == "__main__":
 agents.cli.run_app(agents.WorkerOptions(
 entrypoint_fnc=entrypoint,
 agent_name="my-telephony-agent"
 ))
◦ And for Node.js, you can do:
Copy code
new Worker({
 agentName: "my-telephony-agent",
 // other options
});
Just a heads up: named agents are great for explicit dispatch—you won’t see them automatically assigned to rooms. After you deploy, you can easily dispatch them using the LiveKit API, CLI, or client SDKs. If you have any questions or need a hand, I’m here to help! Sources: Agents telephony integration | LiveKit Docs | Dispatching agents | LiveKit Docs | protobufs/livekit_cloud_agent.proto | Agent deployment CLI reference | LiveKit Docs | Agent dispatch | LiveKit Docs
c
I am still not able to add the name to my agent. From which directory should I run my agent?
t
Hey there! Just a quick heads-up: the folder you run your agent from doesn’t actually change its name. Instead, you’ll want to set the agent’s name directly in your code when you’re initializing the
WorkerOptions
. Here’s a little example in Python to make it clearer:
Copy code
if __name__ == "__main__":
    cli.run_app(
        WorkerOptions(
            entrypoint_fnc=entrypoint,
            agent_name="my-telephony-agent"  # This is where you name your agent
        )
    )
Make sure your code has the
agent_name
field filled out to explicitly give your agent a name. The directory you’re in mainly matters for things like deploying via the CLI, but it won’t change what your agent is called. If you’re still running into trouble, no worries! Just let me know how you’re running the agent and feel free to share any bits of your code or setup. I’m here to help! Sources: Agent dispatch | LiveKit Docs | Agent deployment CLI reference | LiveKit Docs | Agents telephony integration | LiveKit Docs
c
How to add knowledge base for llms?
t
Hey there! If you want to add a knowledge base for LLMs in LiveKit, a great way to do that is by using Retrieval-Augmented Generation (RAG). Basically, you create a vector database from your documents and connect it with your agent logic. Here’s a friendly walkthrough: • Set Up RAG: Start by using the LiveKit Agents framework to build a vector database with Annoy and OpenAI embeddings. You’ll store the data in files like
index.annoy
and
metadata.pkl
. • Prepare the Knowledge Base: Run the
build_rag_data.py
script to turn your documents into embeddings. This script takes care of splitting the documents, generating embeddings, and saving everything so it’s ready for retrieval. • Implement RAG-Enabled Agent: Create an agent class that includes a
function_tool
to fetch results from the knowledge base. For example, you can use the
livekit_docs_search
tool to search the vector database and pull up relevant info. • Integrate into Workflow: Bring it all together by using the
RAGEnrichedAgent
within an
AgentSession
alongside LLM, STT, and TTS components. This lets your agent dynamically retrieve knowledge during conversations. • Optional Knowledge Ingestion: If you want, use scripts like
sync_livekit_repos.py
or
pull_kb.py
to scrape and prep documentation from places like
kb.livekit.io
. If you want to dive deeper, check out the RAG example in the LiveKit repository for detailed scripts and examples. And hey, if you hit any bumps or have a special use case, just give me a shout—I’m here to help! Sources: Large language model (LLM) integrations | LiveKit Docs | Ollama integration guide | LiveKit Docs | LangChain integration guide | LiveKit Docs | Baseten LLM integration guide | LiveKit Docs | rag/main.py
c
How to connect playground to agents hosted in lk cloud?
t
Hey there! Just wanted to check in and see what you mean by connecting the LiveKit playground to agents hosted in LiveKit Cloud. Are you trying to test how the agents work, send agents to different rooms, or maybe something else? Let me know so I can help you out better!
c
I want to test the agents. so, i want to connect a specific agent to the playground
t
Hey there! If you want to test a specific agent in the LiveKit Playground connected to LiveKit Cloud, here’s a simple way to do it: • Get your agent ready: ◦ Make sure your agent has the necessary environment variables set:
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
. ◦ Start your agent in
dev
mode by running something like
python myagent.py dev
(or the equivalent command for your language). • Jump into the hosted Playground: ◦ Head over to the hosted Agents Playground. ◦ Pop in your LiveKit server URL and a room access token to connect to your LiveKit Cloud instance and chat with your agent. • *If you prefer, you can self-host the Playground:*`LIVEKIT_API_KEY=YOUR_API_KEY LIVEKIT_API_SECRET=YOUR_API_SECRET NEXT_PUBLIC_LIVEKIT_URL=wss://YOUR_LIVEKIT_URL` ◦ Start by cloning the Playground repo:
git clone https://github.com/livekit/agents-playground.git
. ◦ Create an
.env.local
file with your LiveKit credentials like this: ◦ Then run the Playground locally with
npm run dev
and open http//localhost3000 in your browser. • Customize your Playground experience (optional): You can tweak settings like audio, video, and chat using the
NEXT_PUBLIC_APP_CONFIG
environment variable to fit what your agent can do. And that’s it! These steps will help you test your agent live in the Playground. If you hit any bumps or have questions, just give me a shout—I’m here to help! Sources: README.md | Agents playground | LiveKit Docs | Agents Playground | LiveKit Docs | README.md