Skip to main content

Bundled LiveKit agents and plugins fork for vyvoj25. Installs top-level 'livekit' package.

Project description

THIS LIB IS JUST ADDON THAT CONNECT 11LABS CONVERSATIONAL_AI WITH LIVEKIT. NOTHING IS GUARANTEED.

The LiveKit icon, the name of the repository and some sample code in the background.

PyPI - Version PyPI Downloads Slack community Twitter Follow Ask DeepWiki for understanding the codebase License


Looking for the JS/TS library? Check out AgentsJS

✨ 1.0 release ✨

This README reflects the 1.0 release. For documentation on the previous 0.x release, see the 0.x branch

What is Agents?

The Agent Framework is designed for building realtime, programmable participants that run on servers. Use it to create conversational, multi-modal voice agents that can see, hear, and understand.

Features

  • Flexible integrations: A comprehensive ecosystem to mix and match the right STT, LLM, TTS, and Realtime API to suit your use case.
  • Integrated job scheduling: Built-in task scheduling and distribution with dispatch APIs to connect end users to agents.
  • Extensive WebRTC clients: Build client applications using LiveKit's open-source SDK ecosystem, supporting nearly all major platforms.
  • Telephony integration: Works seamlessly with LiveKit's telephony stack, allowing your agent to make calls to or receive calls from phones.
  • Exchange data with clients: Use RPCs and other Data APIs to seamlessly exchange data with clients.
  • Semantic turn detection: Uses a transformer model to detect when a user is done with their turn, helps to reduce interruptions.
  • MCP support: Native support for MCP. Integrate tools provided by MCP servers with one loc.
  • Open-source: Fully open-source, allowing you to run the entire stack on your own servers, including LiveKit server, one of the most widely used WebRTC media servers.

Installation

To install the core Agents library, along with plugins for popular model providers:

pip install "livekit-agents[openai,silero,deepgram,cartesia,turn-detector]~=1.0"

Docs and guides

Documentation on the framework and how to use it can be found here

Core concepts

  • Agent: An LLM-based application with defined instructions.
  • AgentSession: A container for agents that manages interactions with end users.
  • entrypoint: The starting point for an interactive session, similar to a request handler in a web server.
  • Worker: The main process that coordinates job scheduling and launches agents for user sessions.

Usage

Simple voice agent


from livekit.agents import (
    Agent,
    AgentSession,
    JobContext,
    RunContext,
    WorkerOptions,
    cli,
    function_tool,
)
from livekit.plugins import deepgram, elevenlabs, openai, silero

@function_tool
async def lookup_weather(
    context: RunContext,
    location: str,
):
    """Used to look up weather information."""

    return {"weather": "sunny", "temperature": 70}


async def entrypoint(ctx: JobContext):
    await ctx.connect()

    agent = Agent(
        instructions="You are a friendly voice assistant built by LiveKit.",
        tools=[lookup_weather],
    )
    session = AgentSession(
        vad=silero.VAD.load(),
        # any combination of STT, LLM, TTS, or realtime API can be used
        stt=deepgram.STT(model="nova-3"),
        llm=openai.LLM(model="gpt-4o-mini"),
        tts=elevenlabs.TTS(),
    )

    await session.start(agent=agent, room=ctx.room)
    await session.generate_reply(instructions="greet the user and ask about their day")


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

You'll need the following environment variables for this example:

  • DEEPGRAM_API_KEY
  • OPENAI_API_KEY

Multi-agent handoff


This code snippet is abbreviated. For the full example, see multi_agent.py

...
class IntroAgent(Agent):
    def __init__(self) -> None:
        super().__init__(
            instructions=f"You are a story teller. Your goal is to gather a few pieces of information from the user to make the story personalized and engaging."
            "Ask the user for their name and where they are from"
        )

    async def on_enter(self):
        self.session.generate_reply(instructions="greet the user and gather information")

    @function_tool
    async def information_gathered(
        self,
        context: RunContext,
        name: str,
        location: str,
    ):
        """Called when the user has provided the information needed to make the story personalized and engaging.

        Args:
            name: The name of the user
            location: The location of the user
        """

        context.userdata.name = name
        context.userdata.location = location

        story_agent = StoryAgent(name, location)
        return story_agent, "Let's start the story!"


class StoryAgent(Agent):
    def __init__(self, name: str, location: str) -> None:
        super().__init__(
            instructions=f"You are a storyteller. Use the user's information in order to make the story personalized."
            f"The user's name is {name}, from {location}"
            # override the default model, switching to Realtime API from standard LLMs
            llm=openai.realtime.RealtimeModel(voice="echo"),
            chat_ctx=chat_ctx,
        )

    async def on_enter(self):
        self.session.generate_reply()


async def entrypoint(ctx: JobContext):
    await ctx.connect()

    userdata = StoryData()
    session = AgentSession[StoryData](
        vad=silero.VAD.load(),
        stt=deepgram.STT(model="nova-3"),
        llm=openai.LLM(model="gpt-4o-mini"),
        tts=openai.TTS(voice="echo"),
        userdata=userdata,
    )

    await session.start(
        agent=IntroAgent(),
        room=ctx.room,
    )
...

Examples

🎙️ Starter Agent

A starter agent optimized for voice conversations.

Code

🔄 Multi-user push to talk

Responds to multiple users in the room via push-to-talk.

Code

🎵 Background audio

Background ambient and thinking audio to improve realism.

Code

🛠️ Dynamic tool creation

Creating function tools dynamically.

Code

☎️ Outbound caller

Agent that makes outbound phone calls

Code

📋 Structured output

Using structured output from LLM to guide TTS tone.

Code

🔌 MCP support

Use tools from MCP servers

Code

💬 Text-only agent

Skip voice altogether and use the same code for text-only integrations

Code

📝 Multi-user transcriber

Produce transcriptions from all users in the room

Code

🎥 Video avatars

Add an AI avatar with Tavus, Beyond Presence, and Bithuman

Code

🍽️ Restaurant ordering and reservations

Full example of an agent that handles calls for a restaurant.

Code

👁️ Gemini Live vision

Full example (including iOS app) of Gemini Live agent that can see.

Code

Running your agent

Testing in terminal

python myagent.py console

Runs your agent in terminal mode, enabling local audio input and output for testing. This mode doesn't require external servers or dependencies and is useful for quickly validating behavior.

Developing with LiveKit clients

python myagent.py dev

Starts the agent server and enables hot reloading when files change. This mode allows each process to host multiple concurrent agents efficiently.

The agent connects to LiveKit Cloud or your self-hosted server. Set the following environment variables:

  • LIVEKIT_URL
  • LIVEKIT_API_KEY
  • LIVEKIT_API_SECRET

You can connect using any LiveKit client SDK or telephony integration. To get started quickly, try the Agents Playground.

Running for production

python myagent.py start

Runs the agent with production-ready optimizations.

Contributing

The Agents framework is under active development in a rapidly evolving field. We welcome and appreciate contributions of any kind, be it feedback, bugfixes, features, new plugins and tools, or better documentation. You can file issues under this repo, open a PR, or chat with us in LiveKit's Slack community.


LiveKit Ecosystem
LiveKit SDKsBrowser · iOS/macOS/visionOS · Android · Flutter · React Native · Rust · Node.js · Python · Unity · Unity (WebGL) · ESP32
Server APIsNode.js · Golang · Ruby · Java/Kotlin · Python · Rust · PHP (community) · .NET (community)
UI ComponentsReact · Android Compose · SwiftUI · Flutter
Agents FrameworksPython · Node.js · Playground
ServicesLiveKit server · Egress · Ingress · SIP
ResourcesDocs · Example apps · Cloud · Self-hosting · CLI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vyvoj25_framework-1.0.9.tar.gz (2.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vyvoj25_framework-1.0.9-py3-none-any.whl (2.9 MB view details)

Uploaded Python 3

File details

Details for the file vyvoj25_framework-1.0.9.tar.gz.

File metadata

  • Download URL: vyvoj25_framework-1.0.9.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for vyvoj25_framework-1.0.9.tar.gz
Algorithm Hash digest
SHA256 4ea3137e67eb3bd3543fee8809002c017b5fcbc66443311887d4508e51a40bc4
MD5 dde6f054b474de758d6964ea5502bece
BLAKE2b-256 07602b41b04838f17dfebde7e9626b239db757fd7ba9998a45bec1a7d79f0ce3

See more details on using hashes here.

File details

Details for the file vyvoj25_framework-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for vyvoj25_framework-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 1ae1f2f9f5bd2f0d3c1aac3751245f4fef8c9cf76b2bd79a3146711f5eae7956
MD5 e9a13af27fdc43a0656aba8e230fbbf8
BLAKE2b-256 d54d50b28e8f3f232529bd8317797e29d3ce666b0297466b368c0e3ef2f17332

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page