livekit-plugins-perplexity 1.5.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,180 @@
1
+ **/.vscode
2
+ **/.DS_Store
3
+ .env
4
+
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # poetry
102
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106
+ #poetry.lock
107
+
108
+ # pdm
109
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110
+ #pdm.lock
111
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112
+ # in version control.
113
+ # https://pdm.fming.dev/#use-with-ide
114
+ .pdm.toml
115
+
116
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117
+ __pypackages__/
118
+
119
+ # Celery stuff
120
+ celerybeat-schedule
121
+ celerybeat.pid
122
+
123
+ # SageMath parsed files
124
+ *.sage.py
125
+
126
+ # Environments
127
+ .env
128
+ .venv
129
+ env/
130
+ venv/
131
+ ENV/
132
+ env.bak/
133
+ venv.bak/
134
+
135
+ # Spyder project settings
136
+ .spyderproject
137
+ .spyproject
138
+
139
+ # Rope project settings
140
+ .ropeproject
141
+
142
+ # mkdocs documentation
143
+ /site
144
+
145
+ # mypy
146
+ .mypy_cache/
147
+ .dmypy.json
148
+ dmypy.json
149
+
150
+ # trunk
151
+ .trunk/
152
+
153
+ # Pyre type checker
154
+ .pyre/
155
+
156
+ # pytype static type analyzer
157
+ .pytype/
158
+
159
+ # Cython debug symbols
160
+ cython_debug/
161
+
162
+ # PyCharm
163
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
164
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
165
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
166
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
167
+ .idea/
168
+
169
+ node_modules
170
+
171
+ credentials.json
172
+ pyrightconfig.json
173
+ docs/
174
+
175
+ # Database files
176
+ *.db
177
+
178
+
179
+ # Examples for development
180
+ examples/dev/*
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: livekit-plugins-perplexity
3
+ Version: 1.5.9
4
+ Summary: Perplexity LLM plugin for LiveKit Agents
5
+ Project-URL: Documentation, https://docs.livekit.io
6
+ Project-URL: Website, https://livekit.io/
7
+ Project-URL: Source, https://github.com/livekit/agents
8
+ Author-email: LiveKit <hello@livekit.io>
9
+ License-Expression: Apache-2.0
10
+ Keywords: ai,audio,livekit,perplexity,realtime,video,voice
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Topic :: Multimedia :: Sound/Audio
17
+ Classifier: Topic :: Multimedia :: Video
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.10.0
20
+ Requires-Dist: livekit-agents[openai]>=1.5.9
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Perplexity plugin for LiveKit Agents
24
+
25
+ Support for [Perplexity](https://www.perplexity.ai/) LLMs via the OpenAI-compatible
26
+ chat completions endpoint at `https://api.perplexity.ai`.
27
+
28
+ See [https://docs.livekit.io/agents/models/llm/perplexity/](https://docs.livekit.io/agents/models/llm/perplexity/) for more information.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install livekit-plugins-perplexity
34
+ ```
35
+
36
+ ## Pre-requisites
37
+
38
+ You'll need an API key from Perplexity. It can be passed directly or set as the
39
+ `PERPLEXITY_API_KEY` environment variable.
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ from livekit.plugins import perplexity
45
+
46
+ llm = perplexity.LLM(
47
+ model="sonar-pro",
48
+ # api_key picked up from PERPLEXITY_API_KEY if omitted
49
+ )
50
+ ```
51
+
52
+ The plugin reuses the OpenAI plugin's chat completions transport with
53
+ `base_url="https://api.perplexity.ai"` and forwards an `X-Pplx-Integration`
54
+ attribution header on every outgoing request.
@@ -0,0 +1,32 @@
1
+ # Perplexity plugin for LiveKit Agents
2
+
3
+ Support for [Perplexity](https://www.perplexity.ai/) LLMs via the OpenAI-compatible
4
+ chat completions endpoint at `https://api.perplexity.ai`.
5
+
6
+ See [https://docs.livekit.io/agents/models/llm/perplexity/](https://docs.livekit.io/agents/models/llm/perplexity/) for more information.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pip install livekit-plugins-perplexity
12
+ ```
13
+
14
+ ## Pre-requisites
15
+
16
+ You'll need an API key from Perplexity. It can be passed directly or set as the
17
+ `PERPLEXITY_API_KEY` environment variable.
18
+
19
+ ## Usage
20
+
21
+ ```python
22
+ from livekit.plugins import perplexity
23
+
24
+ llm = perplexity.LLM(
25
+ model="sonar-pro",
26
+ # api_key picked up from PERPLEXITY_API_KEY if omitted
27
+ )
28
+ ```
29
+
30
+ The plugin reuses the OpenAI plugin's chat completions transport with
31
+ `base_url="https://api.perplexity.ai"` and forwards an `X-Pplx-Integration`
32
+ attribution header on every outgoing request.
@@ -0,0 +1,46 @@
1
+ # Copyright 2026 LiveKit, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Perplexity plugin for LiveKit Agents
16
+
17
+ Wraps Perplexity's OpenAI-compatible chat completions endpoint at
18
+ ``https://api.perplexity.ai`` so it can be used as a drop-in LLM for LiveKit
19
+ voice agents.
20
+ """
21
+
22
+ from livekit.agents import Plugin
23
+
24
+ from .llm import LLM
25
+ from .log import logger
26
+ from .models import PerplexityChatModels
27
+ from .version import __version__
28
+
29
+ __all__ = ["LLM", "PerplexityChatModels", "logger", "__version__"]
30
+
31
+
32
+ class PerplexityPlugin(Plugin):
33
+ def __init__(self) -> None:
34
+ super().__init__(__name__, __version__, __package__, logger)
35
+
36
+
37
+ Plugin.register_plugin(PerplexityPlugin())
38
+
39
+ # Cleanup docs of unexported modules
40
+ _module = dir()
41
+ NOT_IN_ALL = [m for m in _module if m not in __all__]
42
+
43
+ __pdoc__ = {}
44
+
45
+ for n in NOT_IN_ALL:
46
+ __pdoc__[n] = False
@@ -0,0 +1,86 @@
1
+ # Copyright 2026 LiveKit, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ import os
18
+
19
+ import httpx
20
+ import openai
21
+
22
+ from livekit.agents.llm import ToolChoice
23
+ from livekit.agents.types import (
24
+ NOT_GIVEN,
25
+ NotGivenOr,
26
+ )
27
+ from livekit.agents.utils import is_given
28
+ from livekit.plugins.openai import LLM as OpenAILLM
29
+
30
+ from .models import PerplexityChatModels
31
+ from .version import __version__
32
+
33
+ PERPLEXITY_BASE_URL = "https://api.perplexity.ai"
34
+ _ATTRIBUTION_HEADER = {"X-Pplx-Integration": f"livekit-agents/{__version__}"}
35
+
36
+
37
+ class LLM(OpenAILLM):
38
+ def __init__(
39
+ self,
40
+ *,
41
+ model: str | PerplexityChatModels = "sonar-pro",
42
+ api_key: NotGivenOr[str] = NOT_GIVEN,
43
+ base_url: NotGivenOr[str] = PERPLEXITY_BASE_URL,
44
+ client: openai.AsyncClient | None = None,
45
+ user: NotGivenOr[str] = NOT_GIVEN,
46
+ temperature: NotGivenOr[float] = NOT_GIVEN,
47
+ parallel_tool_calls: NotGivenOr[bool] = NOT_GIVEN,
48
+ tool_choice: NotGivenOr[ToolChoice] = NOT_GIVEN,
49
+ top_p: NotGivenOr[float] = NOT_GIVEN,
50
+ timeout: httpx.Timeout | None = None,
51
+ ):
52
+ """
53
+ Create a new instance of Perplexity LLM.
54
+
55
+ ``api_key`` must be set to your Perplexity API key, either using the argument or by
56
+ setting the ``PERPLEXITY_API_KEY`` environmental variable.
57
+ """
58
+ api_key = api_key if is_given(api_key) else os.environ.get("PERPLEXITY_API_KEY", "")
59
+ if not api_key:
60
+ raise ValueError(
61
+ "PERPLEXITY_API_KEY is required, either as argument or set "
62
+ "PERPLEXITY_API_KEY environmental variable"
63
+ )
64
+
65
+ super().__init__(
66
+ model=model,
67
+ api_key=api_key,
68
+ base_url=base_url,
69
+ client=client,
70
+ user=user,
71
+ temperature=temperature,
72
+ parallel_tool_calls=parallel_tool_calls,
73
+ tool_choice=tool_choice,
74
+ top_p=top_p,
75
+ timeout=timeout,
76
+ extra_headers=_ATTRIBUTION_HEADER,
77
+ _strict_tool_schema=False,
78
+ )
79
+
80
+ @property
81
+ def model(self) -> str:
82
+ return self._opts.model
83
+
84
+ @property
85
+ def provider(self) -> str:
86
+ return "Perplexity"
@@ -0,0 +1,3 @@
1
+ import logging
2
+
3
+ logger = logging.getLogger("livekit.plugins.perplexity")
@@ -0,0 +1,3 @@
1
+ from typing import Literal
2
+
3
+ PerplexityChatModels = Literal["sonar-pro"]
@@ -0,0 +1,15 @@
1
+ # Copyright 2026 LiveKit, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ __version__ = "1.5.9"
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "livekit-plugins-perplexity"
7
+ dynamic = ["version"]
8
+ description = "Perplexity LLM plugin for LiveKit Agents"
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ requires-python = ">=3.10.0"
12
+ authors = [{ name = "LiveKit", email = "hello@livekit.io" }]
13
+ keywords = ["voice", "ai", "realtime", "audio", "video", "livekit", "perplexity"]
14
+ classifiers = [
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: Apache Software License",
17
+ "Topic :: Multimedia :: Sound/Audio",
18
+ "Topic :: Multimedia :: Video",
19
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3 :: Only",
23
+ ]
24
+ dependencies = [
25
+ "livekit-agents[openai]>=1.5.9",
26
+ ]
27
+
28
+ [project.urls]
29
+ Documentation = "https://docs.livekit.io"
30
+ Website = "https://livekit.io/"
31
+ Source = "https://github.com/livekit/agents"
32
+
33
+ [tool.hatch.version]
34
+ path = "livekit/plugins/perplexity/version.py"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["livekit"]
38
+
39
+ [tool.hatch.build.targets.sdist]
40
+ include = ["/livekit"]
41
+
42
+ [tool.uv]
43
+ exclude-newer = "7 days"
44
+ exclude-newer-package = { livekit = "0 days", livekit-agents = "0 days" }