-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Feat/personaplex plugin #4660
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
Open
milanperovic
wants to merge
10
commits into
livekit:main
Choose a base branch
from
milanperovic:feat/personaplex-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/personaplex plugin #4660
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c0631b2
add personaplex realtime plugin
milanperovic a4a1291
fix: harden personaplex plugin and add tests
milanperovic bc1b50f
style: fix lint, formatting, and add pdoc3 support to realtime module
milanperovic e4c80d3
fix: address PR review - wss:// support and minor cleanups
milanperovic 278b4ed
test: add SSL detection tests
milanperovic cdb7e55
test: cover use_ssl field in options dataclass test
milanperovic 546d03b
refactor: improve test naming and cleanup safety
milanperovic a8c78a1
Merge remote-tracking branch 'origin/main' into feat/personaplex-plugin
milanperovic 9392ed8
fix: implement commit_user_turn abstract method
milanperovic 4a9e8b8
fix: use fully qualified URLs in docs and sync lockfile
milanperovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # LiveKit Plugins PersonaPlex | ||
|
|
||
| Agent Framework plugin for NVIDIA PersonaPlex full-duplex conversational AI. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install livekit-plugins-personaplex | ||
| ``` | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| You need a running PersonaPlex server on a GPU machine. See https://github.com/NVIDIA/personaplex for setup. | ||
|
|
||
| Set the server URL as an environment variable: | ||
|
|
||
| ```bash | ||
| export PERSONAPLEX_URL="ws://gpu-server:8998" | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```python | ||
| from livekit.agents import Agent, AgentSession, JobContext, JobProcess, WorkerOptions, cli | ||
| from livekit.plugins import personaplex, silero | ||
|
|
||
| async def entrypoint(ctx: JobContext): | ||
| await ctx.connect() | ||
|
|
||
| session = AgentSession( | ||
| vad=ctx.proc.userdata["vad"], | ||
| llm=personaplex.RealtimeModel( | ||
| voice="NATF2", | ||
| text_prompt="You are a friendly assistant named Aria.", | ||
| ), | ||
| ) | ||
|
|
||
| await session.start( | ||
| agent=Agent(instructions="You are a friendly assistant."), | ||
| room=ctx.room, | ||
| ) | ||
|
|
||
| def prewarm(proc: JobProcess) -> None: | ||
| proc.userdata["vad"] = silero.VAD.load() | ||
|
|
||
| if __name__ == "__main__": | ||
| cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, prewarm_fnc=prewarm)) | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| ```python | ||
| personaplex.RealtimeModel( | ||
| base_url=None, # Server URL (defaults to PERSONAPLEX_URL env var, then ws://localhost:8998) | ||
| voice="NATF2", # Voice prompt (NATF0-3, NATM0-3, VARF0-4, VARM0-4) | ||
| text_prompt="You are helpful.", # System prompt / persona description | ||
| seed=None, # Optional seed for reproducibility | ||
| silence_threshold_ms=500, # Silence duration before finalizing a generation | ||
| ) | ||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| | Variable | Description | Default | | ||
| |----------|-------------|---------| | ||
| | `PERSONAPLEX_URL` | PersonaPlex server address | `ws://localhost:8998` | |
38 changes: 38 additions & 0 deletions
38
livekit-plugins/livekit-plugins-personaplex/livekit/plugins/personaplex/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| """PersonaPlex plugin for LiveKit Agents | ||
|
|
||
| Support for NVIDIA PersonaPlex full-duplex conversational AI model. | ||
| """ | ||
|
|
||
| from . import realtime | ||
| from .models import PersonaplexVoice | ||
| from .realtime.realtime_model import RealtimeModel, RealtimeSession | ||
| from .version import __version__ | ||
|
|
||
| __all__ = [ | ||
| "PersonaplexVoice", | ||
| "realtime", | ||
| "RealtimeModel", | ||
| "RealtimeSession", | ||
| "__version__", | ||
| ] | ||
|
|
||
| from livekit.agents import Plugin | ||
|
|
||
| from .log import logger | ||
|
|
||
|
|
||
| class PersonaplexPlugin(Plugin): | ||
| def __init__(self) -> None: | ||
| super().__init__(__name__, __version__, __package__, logger) | ||
|
|
||
|
|
||
| Plugin.register_plugin(PersonaplexPlugin()) | ||
|
|
||
| # Cleanup docs of unexported modules | ||
| _module = dir() | ||
| NOT_IN_ALL = [m for m in _module if m not in __all__] | ||
|
|
||
| __pdoc__: dict[str, bool] = {} | ||
|
|
||
| for n in NOT_IN_ALL: | ||
| __pdoc__[n] = False | ||
3 changes: 3 additions & 0 deletions
3
livekit-plugins/livekit-plugins-personaplex/livekit/plugins/personaplex/log.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import logging | ||
|
|
||
| logger = logging.getLogger("livekit.plugins.personaplex") |
24 changes: 24 additions & 0 deletions
24
livekit-plugins/livekit-plugins-personaplex/livekit/plugins/personaplex/models.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Literal | ||
|
|
||
| PersonaplexVoice = Literal[ | ||
| "NATF0", | ||
| "NATF1", | ||
| "NATF2", | ||
| "NATF3", | ||
| "NATM0", | ||
| "NATM1", | ||
| "NATM2", | ||
| "NATM3", | ||
| "VARF0", | ||
| "VARF1", | ||
| "VARF2", | ||
| "VARF3", | ||
| "VARF4", | ||
| "VARM0", | ||
| "VARM1", | ||
| "VARM2", | ||
| "VARM3", | ||
| "VARM4", | ||
| ] |
Empty file.
12 changes: 12 additions & 0 deletions
12
livekit-plugins/livekit-plugins-personaplex/livekit/plugins/personaplex/realtime/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| from .realtime_model import RealtimeModel, RealtimeSession | ||
|
|
||
| __all__ = ["RealtimeModel", "RealtimeSession"] | ||
|
|
||
| # Cleanup docs of unexported modules | ||
| _module = dir() | ||
| NOT_IN_ALL = [m for m in _module if m not in __all__] | ||
|
|
||
| __pdoc__: dict[str, bool] = {} | ||
|
|
||
| for n in NOT_IN_ALL: | ||
| __pdoc__[n] = False |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.