LiveKit BlingFire Bindings
livekit-blingfire provides Python bindings for the BlingFire text processing library, specifically designed to integrate with livekit-agents. It offers efficient sentence splitting and tokenization capabilities, typically used to enhance the text processing pipeline within LiveKit's AI agents. The library is part of the broader LiveKit Agents ecosystem and sees releases that often align with major livekit-agents updates, ensuring compatibility and leveraging new features.
Warnings
- gotcha BlingFire, the underlying library, has native components. While `livekit-blingfire` typically distributes pre-compiled wheels for common platforms, installing on less common architectures or Python versions might require a C++ compiler and associated build tools for the `blingfire` dependency.
- gotcha The `llm.sentence_splitter.set_splitter()` method globally configures the sentence splitter for all `livekit.agents.llm` operations within the current process. If you are running multiple agents or plugins that require different sentence splitting behaviors, this global setting could lead to unexpected interactions or race conditions.
- gotcha Compatibility with `livekit-agents` versions is crucial. `livekit-blingfire` specifies `livekit-agents (>=1.0.0,<2.0.0)`. Installing incompatible versions of `livekit-agents` can lead to runtime errors or unexpected behavior due to API changes.
Install
-
pip install livekit-blingfire
Imports
- BlingFireSentenceSplitter
from livekit.plugins.blingfire import BlingFireSentenceSplitter
- BlingFireTokenizer
from livekit.plugins.blingfire import BlingFireTokenizer
Quickstart
from livekit.plugins.blingfire import BlingFireSentenceSplitter
from livekit.agents import llm
# Set BlingFire as the default sentence splitter for LLM operations
llm.sentence_splitter.set_splitter(BlingFireSentenceSplitter())
# Example usage of the splitter (typically used internally by agents)
text = "Hello, world! How are you doing? This is a test."
splitter = llm.sentence_splitter.get_splitter()
sentences = splitter.split(text)
for s in sentences:
print(f"- {s}")