sp.CustomLLMNode
Overview
The CustomLLMNode
class in the Outspeed package is designed to handle custom language model (LLM) processing within Outspeed applications.
It extends the base Node
class to provide specialized functionality for processing input streams, managing asynchronous tasks, and handling interruptions based on voice activity detection (VAD).
Creating a CustomLLMNode
To create a custom LLM node, define a class that inherits from CustomLLMNode
and implement the required methods.
Here’s an example based on the provided nodes.py
:
A CustomLLMNode
must implement the process
method to define how input data
is handled and transformed by the language model.
- The
process
method receivesinput_data
from the input stream and should return the processed output. - The node manages input and output streams asynchronously, ensuring efficient data handling.
- Interrupt streams can be set to handle tasks like voice activity detection, allowing the node to respond to specific events.
Integrating the CustomLLMNode into an Application
Once defined, the CustomLLMNode
can be integrated into an Outspeed application as follows:
Tool Lifecycle
The CustomLLMNode
manages its lifecycle through several asynchronous tasks:
- Initialization: Sets up input and output streams.
- Processing: Continuously processes incoming data from the input stream.
- Interruption Handling: Monitors the interrupt stream (e.g., VAD) to handle events like speech detection.
- Closure: Gracefully shuts down processing tasks when the node is closed.
Was this page helpful?