livekit-plugins-perplexity 1.5.9__py3-none-any.whl

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,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"]
File without changes
@@ -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,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,9 @@
1
+ livekit/plugins/perplexity/__init__.py,sha256=LzPCdystYOogq1AA_bM4Qvmmxmcdsgy0qCqKn3krOWw,1352
2
+ livekit/plugins/perplexity/llm.py,sha256=5pNM-zxI5zWL_zONaxesXVE3DTYsbts-QEs3VYUoEsw,2767
3
+ livekit/plugins/perplexity/log.py,sha256=WuTXNNHCzIPjv0hywIFwSVFk-ukWuMDP5TiXdCZkCAA,73
4
+ livekit/plugins/perplexity/models.py,sha256=TPihRYe2ITKlGRVBiAKoturY4NRL1uaRqigldGrCKyg,72
5
+ livekit/plugins/perplexity/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ livekit/plugins/perplexity/version.py,sha256=lmpoLDX_Rje0P3EpnRkXAn382uCZdh-zQZOk8r9IeDk,600
7
+ livekit_plugins_perplexity-1.5.9.dist-info/METADATA,sha256=hO9JRibmOVloN6KuxkmPUmKQ1zA54bsgihMVZWRkj_g,1829
8
+ livekit_plugins_perplexity-1.5.9.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
9
+ livekit_plugins_perplexity-1.5.9.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any