-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(plugins): add livekit-plugins-inception for Inception AI LLM support #6146
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
Lothnic
wants to merge
3
commits into
livekit:main
Choose a base branch
from
Lothnic:feat/inception-llm-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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,23 @@ | ||
| # Inception AI plugin for LiveKit Agents | ||
|
|
||
| Support for Inception AI LLM models (e.g. `mercury-2` diffusion model) with LiveKit. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install livekit-plugins-inception | ||
| ``` | ||
|
|
||
| ## Pre-requisites | ||
|
|
||
| You'll need an API key from Inception AI. It can be set as an environment variable: `INCEPTION_API_KEY` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### LLM | ||
|
|
||
| ```python | ||
| from livekit.plugins import inception | ||
|
|
||
| llm = inception.LLM(model="mercury-2") | ||
| ``` |
43 changes: 43 additions & 0 deletions
43
livekit-plugins/livekit-plugins-inception/livekit/plugins/inception/__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,43 @@ | ||
| # Copyright 2026 LiveKit, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Inception AI plugin for LiveKit Agents | ||
|
|
||
| See https://docs.livekit.io/agents/integrations/inception/ for more information. | ||
| """ | ||
|
|
||
| from .llm import LLM as LLM | ||
| from .log import logger | ||
| from .version import __version__ as __version__ | ||
|
|
||
| __all__ = ["LLM", "__version__"] | ||
|
|
||
| from livekit.agents import Plugin | ||
|
|
||
|
|
||
| class InceptionPlugin(Plugin): | ||
| def __init__(self) -> None: | ||
| super().__init__(__name__, __version__, __package__, logger) | ||
|
|
||
|
|
||
| Plugin.register_plugin(InceptionPlugin()) | ||
|
|
||
| # Cleanup docs of unexported modules | ||
| _module = dir() | ||
| NOT_IN_ALL = [m for m in _module if m not in __all__] | ||
|
|
||
| __pdoc__ = {} | ||
|
|
||
| for n in NOT_IN_ALL: | ||
| __pdoc__[n] = False |
92 changes: 92 additions & 0 deletions
92
livekit-plugins/livekit-plugins-inception/livekit/plugins/inception/llm.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,92 @@ | ||
| # Copyright 2026 LiveKit, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
|
|
||
| import httpx | ||
| import openai | ||
| from openai.types import ReasoningEffort | ||
|
|
||
| from livekit.agents.llm import ToolChoice | ||
| from livekit.agents.types import ( | ||
| NOT_GIVEN, | ||
| NotGivenOr, | ||
| ) | ||
| from livekit.agents.utils import is_given | ||
| from livekit.plugins.openai import LLM as OpenAILLM | ||
|
|
||
| from .models import LLMModels | ||
|
|
||
|
|
||
| class LLM(OpenAILLM): | ||
| def __init__( | ||
| self, | ||
| *, | ||
| model: str | LLMModels = "mercury-2", | ||
| api_key: NotGivenOr[str] = NOT_GIVEN, | ||
| user: NotGivenOr[str] = NOT_GIVEN, | ||
| safety_identifier: NotGivenOr[str] = NOT_GIVEN, | ||
| prompt_cache_key: NotGivenOr[str] = NOT_GIVEN, | ||
| temperature: NotGivenOr[float] = NOT_GIVEN, | ||
| top_p: NotGivenOr[float] = NOT_GIVEN, | ||
| parallel_tool_calls: NotGivenOr[bool] = NOT_GIVEN, | ||
| tool_choice: NotGivenOr[ToolChoice] = NOT_GIVEN, | ||
| base_url: NotGivenOr[str] = "https://api.inceptionlabs.ai/v1", | ||
| metadata: NotGivenOr[dict[str, str]] = NOT_GIVEN, | ||
| max_completion_tokens: NotGivenOr[int] = NOT_GIVEN, | ||
| reasoning_effort: NotGivenOr[ReasoningEffort] = NOT_GIVEN, | ||
| service_tier: NotGivenOr[str] = NOT_GIVEN, | ||
| timeout: httpx.Timeout | None = None, | ||
| max_retries: NotGivenOr[int] = NOT_GIVEN, | ||
| client: openai.AsyncClient | None = None, | ||
| ): | ||
| """Create a new instance of Inception AI LLM. | ||
|
|
||
| ``api_key`` must be set to your Inception AI API key, either using the argument or by setting | ||
| the ``INCEPTION_API_KEY`` environmental variable. | ||
| """ | ||
| super().__init__( | ||
| model=model, | ||
| api_key=_get_api_key(api_key), | ||
| base_url=base_url, | ||
| client=client, | ||
| user=user, | ||
| safety_identifier=safety_identifier, | ||
| prompt_cache_key=prompt_cache_key, | ||
| temperature=temperature, | ||
| top_p=top_p, | ||
| parallel_tool_calls=parallel_tool_calls, | ||
| tool_choice=tool_choice, | ||
| reasoning_effort=reasoning_effort, | ||
| service_tier=service_tier, | ||
| timeout=timeout, | ||
| max_retries=max_retries, | ||
| metadata=metadata, | ||
| max_completion_tokens=max_completion_tokens, | ||
| ) | ||
|
|
||
| @property | ||
| def provider(self) -> str: | ||
| return "InceptionAI" | ||
|
|
||
|
|
||
| def _get_api_key(key: NotGivenOr[str]) -> str: | ||
| inception_api_key = key if is_given(key) else os.environ.get("INCEPTION_API_KEY") | ||
| if not inception_api_key: | ||
| raise ValueError( | ||
| "INCEPTION_API_KEY is required, either as argument or set INCEPTION_API_KEY environmental variable" # noqa: E501 | ||
| ) | ||
| return inception_api_key |
4 changes: 4 additions & 0 deletions
4
livekit-plugins/livekit-plugins-inception/livekit/plugins/inception/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,4 @@ | ||
| # Simple logger for the plugin | ||
| import logging | ||
|
|
||
| logger = logging.getLogger("livekit.plugins.inception") |
6 changes: 6 additions & 0 deletions
6
livekit-plugins/livekit-plugins-inception/livekit/plugins/inception/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,6 @@ | ||
| from typing import Literal | ||
|
|
||
| LLMModels = Literal[ | ||
| "mercury-2", | ||
| "mercury-edit-2", | ||
| ] |
1 change: 1 addition & 0 deletions
1
livekit-plugins/livekit-plugins-inception/livekit/plugins/inception/py.typed
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 @@ | ||
| # Marker file for PEP 561. |
15 changes: 15 additions & 0 deletions
15
livekit-plugins/livekit-plugins-inception/livekit/plugins/inception/version.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,15 @@ | ||
| # Copyright 2026 LiveKit, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| __version__ = "1.6.0" | ||
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,42 @@ | ||
| [build-system] | ||
| requires = ["hatchling"] | ||
| build-backend = "hatchling.build" | ||
|
|
||
| [project] | ||
| name = "livekit-plugins-inception" | ||
| dynamic = ["version"] | ||
| description = "Agent Framework plugin for Inception AI LLM models." | ||
| readme = "README.md" | ||
| license = "Apache-2.0" | ||
| requires-python = ">=3.10.0" | ||
| authors = [{ name = "LiveKit", email = "hello@livekit.io" }] | ||
| keywords = ["webrtc", "realtime", "audio", "video", "livekit", "inception", "llm"] | ||
| classifiers = [ | ||
| "Intended Audience :: Developers", | ||
| "License :: OSI Approved :: Apache Software License", | ||
| "Topic :: Multimedia :: Sound/Audio", | ||
| "Topic :: Multimedia :: Video", | ||
| "Topic :: Scientific/Engineering :: Artificial Intelligence", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3 :: Only", | ||
| ] | ||
| dependencies = ["livekit-agents[openai]>=1.6.1"] | ||
|
|
||
| [project.urls] | ||
| Documentation = "https://docs.livekit.io" | ||
| Website = "https://livekit.io/" | ||
| Source = "https://github.com/livekit/agents" | ||
|
|
||
| [tool.hatch.version] | ||
| path = "livekit/plugins/inception/version.py" | ||
|
|
||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["livekit"] | ||
|
|
||
| [tool.hatch.build.targets.sdist] | ||
| include = ["/livekit"] | ||
|
|
||
| [tool.uv] | ||
| exclude-newer = "7 days" | ||
| exclude-newer-package = { livekit-agents = "0 days" } |
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
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,35 @@ | ||
| """Tests for Inception AI LLM plugin configuration and behavior.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| from livekit.plugins.inception import LLM | ||
|
|
||
| # Let's write the test cleanly. | ||
| pytestmark = pytest.mark.plugin("inception") | ||
|
|
||
|
|
||
| def test_default_model_and_base_url(monkeypatch: pytest.MonkeyPatch) -> None: | ||
| monkeypatch.setenv("INCEPTION_API_KEY", "test-key") | ||
| llm = LLM() | ||
| assert llm.model == "mercury-2" | ||
| # AsyncClient stores the configured base URL on _base_url. | ||
| assert str(llm._client.base_url).startswith("https://api.inceptionlabs.ai/v1") | ||
|
|
||
|
|
||
| def test_missing_api_key_raises(monkeypatch: pytest.MonkeyPatch) -> None: | ||
| monkeypatch.delenv("INCEPTION_API_KEY", raising=False) | ||
| with pytest.raises(ValueError, match="INCEPTION_API_KEY"): | ||
| LLM() | ||
|
|
||
|
|
||
| def test_provider_name(monkeypatch: pytest.MonkeyPatch) -> None: | ||
| monkeypatch.setenv("INCEPTION_API_KEY", "test-key") | ||
| assert ( | ||
| LLM().provider == "InceptionAI" | ||
| ) # In our class we returned super().provider which is "OpenAI" or did we override it? Let's check! | ||
| # Wait, did our LLM override provider? | ||
| # In services.py of groq, LLM does NOT override provider. It inherits OpenAILLM. But wait! OpenAILLM.provider is "openai". | ||
| # Wait, let's check what Groq LLM returns for provider, or what Cerebras LLM returns. | ||
| # Let's check if OpenAILLM has a provider property we should override. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚩 Plugin version 1.6.0 is behind the rest of the ecosystem at 1.6.1
The inception plugin's
version.pysets__version__ = "1.6.0"while all other recently-created plugins (Cerebras, Groq, etc.) andlivekit-agentsitself are at1.6.1. Per CONTRIBUTING.md, versions are managed by a bot before release, so this likely gets fixed automatically. However, if this plugin were published as-is, it would be the only 1.6.0 package in the ecosystem while depending onlivekit-agents[openai]>=1.6.1.Was this helpful? React with 👍 or 👎 to provide feedback.